7424 lines
239 KiB
Plaintext
7424 lines
239 KiB
Plaintext
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Configurations\XAiApiConfiguration.cs
|
|
|
|
using xAiModels.Models;
|
|
using xAiModels.Constants;
|
|
|
|
namespace xAiModels.Configurations
|
|
{
|
|
public class XAiApiConfiguration
|
|
{
|
|
/// <summary>
|
|
/// Model Providers ...
|
|
/// </summary>
|
|
public XAiModelDescriptor[] Models { get; set; } = [];
|
|
|
|
/// <summary>
|
|
/// Each User must Has a Default Project, this is Title Resource Identifier ...
|
|
/// </summary>
|
|
public string DefaultProjectTitleResource { get; set; } = XAiModelsConstants.DefaultXAiProjectTitleResourceID;
|
|
|
|
/// <summary>
|
|
/// Each User must Has a Default Project, this is Description Resource Identifier ...
|
|
/// </summary>
|
|
public string DefaultProjectDescriptionResource { get; set; } = XAiModelsConstants.DefaultXAiProjectDescriptionResourceID;
|
|
|
|
/// <summary>
|
|
/// Each User must Has a Default Conversation, this is Title Resource Identifier ... ...
|
|
/// </summary>
|
|
public string DefaultConversationTitleResource { get; set; } = XAiModelsConstants.DefaultXAiConversationTitleResourceID;
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Configurations\XAiModelMappersProfile.cs
|
|
|
|
using AutoMapper;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Configurations
|
|
{
|
|
public class XAiModelMappersProfile : Profile
|
|
{
|
|
public XAiModelMappersProfile()
|
|
{
|
|
//
|
|
// XAiMessage ...
|
|
CreateMap<XAiMessage, XAiMessageDto>();
|
|
|
|
//
|
|
// XAiProject ...
|
|
CreateMap<XAiProject, XAiProjectDto>();
|
|
|
|
//
|
|
// XAiConversation ...
|
|
CreateMap<XAiConversation, XAiConversationDto>();
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Configurations\Entities\XAiConversationEntityConfiguration.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace xAiModels.Configurations.Entities
|
|
{
|
|
public class XAiConversationEntityConfiguration : XBaseEntityTypeConfiguration<XAiConversation, Guid>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<XAiConversation> builder)
|
|
{
|
|
builder.ToTable(XAiModelsConstants.XAiConversationTable);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Configurations\Entities\XAiMessageEntityConfiguration.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace xAiModels.Configurations.Entities
|
|
{
|
|
public class XAiMessageEntityConfiguration : XBaseEntityTypeConfiguration<XAiMessage, Guid>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<XAiMessage> builder)
|
|
{
|
|
builder.ToTable(XAiModelsConstants.XAiMessageTable);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Configurations\Entities\XAiProjectEntityConfiguration.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace xAiModels.Configurations.Entities
|
|
{
|
|
public class XAiProjectEntityConfiguration : XBaseEntityTypeConfiguration<XAiProject, Guid>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<XAiProject> builder)
|
|
{
|
|
builder.ToTable(XAiModelsConstants.XAiProjectTable);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\ConfigurationNodeNames.cs
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
public partial struct ConfigurationNodeNames
|
|
{
|
|
public const string AI_API_NODE = "AiApiConfiguration";
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiChatRole.cs
|
|
|
|
using xExceptions.Attributes;
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
public struct XAiChatRoles
|
|
{
|
|
public const string None = "none";
|
|
public const string User = "user";
|
|
public const string Tool = "tool";
|
|
public const string System = "system";
|
|
public const string Assistant = "assistant";
|
|
}
|
|
|
|
public enum XAiChatRole
|
|
{
|
|
[StringValue(XAiChatRoles.None)]
|
|
None,
|
|
[StringValue(XAiChatRoles.User)]
|
|
User,
|
|
[StringValue(XAiChatRoles.Tool)]
|
|
Tool,
|
|
[StringValue(XAiChatRoles.System)]
|
|
System,
|
|
[StringValue(XAiChatRoles.Assistant)]
|
|
Assistant,
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiDataProviderConstants.cs
|
|
|
|
using xExceptions.Attributes;
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
public struct XAiDataProviderConstants
|
|
{
|
|
public const string XDefaultAiProjectSuffix = "DefAiPrj";
|
|
public const string XDefaultAiConversationSuffix = "DefAiCnv";
|
|
}
|
|
|
|
public enum XAiDataProviderHubActions
|
|
{
|
|
//
|
|
// Project ...
|
|
[StringValue("ProjectCreated")]
|
|
ProjectCreated,
|
|
|
|
[StringValue("ProjectUpdated")]
|
|
ProjectUpdated,
|
|
|
|
[StringValue("ProjectRemoved")]
|
|
ProjectRemoved,
|
|
|
|
//
|
|
// Conversation ...
|
|
[StringValue("ConversationCreated")]
|
|
ConversationCreated,
|
|
|
|
[StringValue("ConversationUpdated")]
|
|
ConversationUpdated,
|
|
|
|
[StringValue("ConversationRemoved")]
|
|
ConversationRemoved,
|
|
|
|
//
|
|
// Message ...
|
|
[StringValue("MessageCreated")]
|
|
MessageCreated,
|
|
|
|
[StringValue("MessageUpdated")]
|
|
MessageUpdated,
|
|
|
|
[StringValue("MessageRemoved")]
|
|
MessageRemoved,
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiModelProviderType.cs
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
/// <summary>
|
|
/// Specifiy Provider Type ...
|
|
/// </summary>
|
|
public enum XAiModelProviderType
|
|
{
|
|
None,
|
|
OpenAI,
|
|
Ollama,
|
|
DeepSeek,
|
|
HuggingFace
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiModelsConstants.cs
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
public struct XAiModelsConstants
|
|
{
|
|
//
|
|
// Service Extensions Log Tag ...
|
|
public const string XAiModelsDILogTag = "XAiModels";
|
|
|
|
//
|
|
// Table Mapping Identifiers ...
|
|
public const string XAiMessageTable = "AiMessages";
|
|
public const string XAiProjectTable = "AiProjects";
|
|
public const string XAiConversationTable = "AiConversations";
|
|
|
|
//
|
|
// GraphQL Collection Mappings ...
|
|
public const string XAiMessageSingleName = "aiMessage";
|
|
public const string XAiProjectSingleName = "aiProject";
|
|
public const string XAiConversationSignleName = "aiConversation";
|
|
|
|
public const string XAiMessageCollectionName = "aiMessages";
|
|
public const string XAiProjectCollectionName = "AiProjectsa";
|
|
public const string XAiConversationCollectionName = "aiConversations";
|
|
|
|
//
|
|
// Hubs ...
|
|
public const string XAiMessageDtoHub = "aiMessageDto";
|
|
public const string XAiMessageEntityHub = "aiMessageEntity";
|
|
|
|
public const string XAiProjectDtoHub = "aiProjectDto";
|
|
public const string XAiProjectEntityHub = "aiProjectEntity";
|
|
|
|
public const string XAiConversationDtoHub = "aiConversationDto";
|
|
public const string XAiConversationEntityHub = "aiConversationEntity";
|
|
|
|
//
|
|
// Resource Provider Identifiers ...
|
|
public const string XAiProjectTitleIdentifier = "AiPrjT";
|
|
public const string XAiProjectDescriptionIdentifier = "AiPrjD";
|
|
public const string XAiConversationTitleIdentifier = "AiCnvrT";
|
|
|
|
//
|
|
// EF Repositories Helper Extensions ...
|
|
public const string GetXAiMessageEFRepositoryDescriptor = "GetXAiMessageEFRepositoryDescriptor";
|
|
public const string GetXAiProjectEFRepositoryDescriptor = "GetXAiProjectEFRepositoryDescriptor";
|
|
public const string GetXAiConversationEFRepositoryDescriptor = "GetXAiConversationEFRepositoryDescriptor";
|
|
|
|
//
|
|
public const string DefaultXAiProjectTitleResourceID = "XAiPrjT";
|
|
public const string DefaultXAiConversationTitleResourceID = "XAiCnvT";
|
|
public const string DefaultXAiProjectDescriptionResourceID = "XAiPrjD";
|
|
|
|
//
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\DI\XDIHelperExtension.cs
|
|
|
|
using System;
|
|
using xDataService.Db;
|
|
using xPushService.DI;
|
|
using xDataService.DI;
|
|
using xCommons.Helpers;
|
|
using xAiModels.Helpers;
|
|
using xDataService.Models;
|
|
using xAiModels.Providers;
|
|
using xAiModels.Constants;
|
|
using xCommons.Extensions;
|
|
using xPushService.Helpers;
|
|
using xAiModels.Interfaces;
|
|
using xExceptions.Constants;
|
|
using xDataService.Constants;
|
|
using xAiModels.Providers.Dtos;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using xAiModels.Providers.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
using xAiModels.Providers.Enrichers;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace xAiModels.DI
|
|
{
|
|
/// <summary>
|
|
/// Service Registration Extensions Classes ...
|
|
/// </summary>
|
|
public static class XDIHelperExtension
|
|
{
|
|
/// <summary>
|
|
/// Register Service ...
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <param name="repositoryType"></param>
|
|
/// <param name="lifeTime"></param>
|
|
public static void AddXAiDataService(
|
|
this IServiceCollection services,
|
|
XRepositoryType repositoryType,
|
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
|
)
|
|
{
|
|
AddAiDataService(
|
|
contextType: null,
|
|
services: services,
|
|
lifeTime: lifeTime,
|
|
repositoryType: repositoryType
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Register Service ...
|
|
/// </summary>
|
|
/// <typeparam name="TContext"></typeparam>
|
|
/// <param name="services"></param>
|
|
/// <param name="repositoryType"></param>
|
|
/// <param name="lifeTime"></param>
|
|
public static void AddXAiDataService<TContext>(
|
|
this IServiceCollection services,
|
|
XRepositoryType repositoryType,
|
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
|
)
|
|
where TContext : XDbContext
|
|
{
|
|
AddAiDataService(
|
|
services: services,
|
|
lifeTime: lifeTime,
|
|
contextType: typeof(TContext),
|
|
repositoryType: repositoryType
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Use XSubCategoryService Middleware ...
|
|
/// </summary>
|
|
/// <param name="app"></param>
|
|
/// <param name="isDevelopmentEnvironment"></param>
|
|
public static void UseXAiDataService(
|
|
this IApplicationBuilder app,
|
|
bool isDevelopmentEnvironment = false
|
|
)
|
|
{
|
|
//
|
|
#region Using Hubs ...
|
|
//
|
|
var pushHelper = new XPushServiceHelper();
|
|
|
|
//
|
|
// XAiMessage ...
|
|
pushHelper.AddHub<XAiMessageDtoHub>(XAiModelsConstants.XAiMessageDtoHub);
|
|
pushHelper.AddHub<XAiMessageEntityHub>(XAiModelsConstants.XAiMessageEntityHub);
|
|
|
|
//
|
|
// XAiProject ...
|
|
pushHelper.AddHub<XAiProjectDtoHub>(XAiModelsConstants.XAiProjectDtoHub);
|
|
pushHelper.AddHub<XAiProjectEntityHub>(XAiModelsConstants.XAiProjectEntityHub);
|
|
|
|
//
|
|
// XAiConversation ...
|
|
pushHelper.AddHub<XAiConversationDtoHub>(XAiModelsConstants.XAiConversationDtoHub);
|
|
pushHelper.AddHub<XAiConversationEntityHub>(XAiModelsConstants.XAiConversationEntityHub);
|
|
|
|
//
|
|
app.UseXPushService(pushHelper);
|
|
#endregion
|
|
|
|
//
|
|
// Using XAiConversation Repository Descriptor ...
|
|
if (!aiConversationDescriptor.IsNull())
|
|
{
|
|
//
|
|
app.UseXRepository(
|
|
descriptor: aiConversationDescriptor,
|
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
|
);
|
|
}
|
|
|
|
//
|
|
// Using XAiMessage Repository Descriptor ...
|
|
if (!aiMessageDescriptor.IsNull())
|
|
{
|
|
//
|
|
app.UseXRepository(
|
|
descriptor: aiMessageDescriptor,
|
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
|
);
|
|
}
|
|
|
|
//
|
|
// Using XAiProject Repository Descriptor ...
|
|
if (!aiProjectDescriptor.IsNull())
|
|
{
|
|
//
|
|
app.UseXRepository(
|
|
descriptor: aiProjectDescriptor,
|
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
|
);
|
|
}
|
|
|
|
//
|
|
// Create an Scope for Services Acces ...
|
|
// Handle Seeding Category/SubCategory Resources ...
|
|
// TODO: Enable Seeding if Required ...
|
|
// using (var scope = app.ApplicationServices.CreateScope())
|
|
// {
|
|
// //
|
|
// // Retrieve Configuratuions ...
|
|
// var aiMessageProvider = scope.ServiceProvider.GetService<IXAiMessageServiceProvider>();
|
|
// var aiProjectProvider = scope.ServiceProvider.GetService<IXAiProjectServiceProvider>();
|
|
// var aiConversationProvider = scope.ServiceProvider.GetService<IXAiConversationServiceProvider>();
|
|
// var configuration = scope.ServiceProvider.GetService<XAiDataServiceServiceConfiguration>();
|
|
// if (!configuration.IsNullOrDefault() &&
|
|
// !categoryProvider.IsNullOrDefault() &&
|
|
// !subaiConversationDescriptor.IsNullOrDefault()
|
|
// )
|
|
// {
|
|
// //
|
|
// // Logging ...
|
|
// Log("Start Seeding ...");
|
|
|
|
// //
|
|
// // Count Data in Category ...
|
|
// var hasCategory = (categoryProvider.Count().GetAwaiter().GetResult()) > 0;
|
|
// var hasSubCategory = (subCategoryProvider.Count().GetAwaiter().GetResult()) > 0;
|
|
|
|
// //
|
|
// // Seed Category Resources ...
|
|
// var canSeed =
|
|
// !hasCategory &&
|
|
// configuration.Categories.HasChild();
|
|
// if (canSeed)
|
|
// {
|
|
// //
|
|
// // Loop through Provided items ...
|
|
// foreach (var cat in configuration.Categories)
|
|
// {
|
|
// //
|
|
// try
|
|
// {
|
|
// //
|
|
// Log($"Start Seeding Category: {cat.Titles.Locales.ToArray()[0].Value} ...");
|
|
|
|
// //
|
|
// categoryProvider.Refresh(
|
|
// resource: cat,
|
|
// userInfo: null,
|
|
// connectionId: null,
|
|
// cancellationToken: default
|
|
// )
|
|
// .GetAwaiter()
|
|
// .GetResult();
|
|
|
|
// //
|
|
// Log($"Seeding Category: {cat.Titles.Locales.ToArray()[0].Value} Finished Successfully ...");
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// Log($"Seeding Category: {cat.Titles.Locales.ToArray()[0].Value} Failed due: {ex.Message} ...");
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// // Seed SubCategory Resources ...
|
|
// canSeed =
|
|
// !hasSubCategory &&
|
|
// configuration.SubCategories.HasChild();
|
|
// if (canSeed)
|
|
// {
|
|
// //
|
|
// // Loop through Provided items ...
|
|
// foreach (var subcat in configuration.SubCategories)
|
|
// {
|
|
// //
|
|
// try
|
|
// {
|
|
// //
|
|
// Log($"Start Seeding SubCategory: {subcat.Titles.Locales.ToArray()[0].Value} ...");
|
|
|
|
// //
|
|
// subCategoryProvider.Refresh(
|
|
// userInfo: null,
|
|
// resource: subcat,
|
|
// connectionId: null,
|
|
// cancellationToken: default
|
|
// )
|
|
// .GetAwaiter()
|
|
// .GetResult();
|
|
|
|
// //
|
|
// Log($"Seeding SubCategory: {subcat.Titles.Locales.ToArray()[0].Value} Finished Successfully ...");
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// Log($"Seeding SubCategory: {subcat.Titles.Locales.ToArray()[0].Value} Failed due: {ex.Message} ...");
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// Log("Finish Seeding ...");
|
|
// }
|
|
// }
|
|
}
|
|
|
|
//
|
|
#region Private ...
|
|
private static XRepositoryDescriptor aiMessageDescriptor = null;
|
|
private static XRepositoryDescriptor aiProjectDescriptor = null;
|
|
private static XRepositoryDescriptor aiConversationDescriptor = null;
|
|
|
|
/// <summary>
|
|
/// a LogTag for Service ...
|
|
/// </summary>
|
|
private static string XLogTag = XAiModelsConstants.XAiModelsDILogTag;
|
|
|
|
/// <summary>
|
|
/// print a log in Console ...
|
|
/// </summary>
|
|
/// <param name="message"></param>
|
|
private static void Log(string message)
|
|
{
|
|
Console.WriteLine($"{XLogTag} => {message}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Register Service ...
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <param name="repositoryType"></param>
|
|
/// <param name="contextType"></param>
|
|
/// <param name="lifeTime"></param>
|
|
private static void AddAiDataService(
|
|
IServiceCollection services,
|
|
XRepositoryType repositoryType,
|
|
Type contextType = null,
|
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
|
)
|
|
{
|
|
//
|
|
var exception = XException.InvalidArgs.ToException(); ;
|
|
|
|
//
|
|
// Services ...
|
|
var isServicesExists = !services.IsNull();
|
|
if (!isServicesExists)
|
|
{
|
|
//
|
|
Log("Service Registration failed, services not provided ...");
|
|
throw exception;
|
|
}
|
|
|
|
//
|
|
// Lifetime ...
|
|
var isLifetimeExists = !lifeTime.IsNull();
|
|
if (!isLifetimeExists)
|
|
{
|
|
//
|
|
Log("Service Registration failed, lifetime not provided ...");
|
|
throw exception;
|
|
}
|
|
|
|
//
|
|
// Validate Repository Type ...
|
|
var isRepositoryTypeValid =
|
|
(repositoryType == XRepositoryType.EF &&
|
|
!contextType.IsNull()) ||
|
|
((repositoryType == XRepositoryType.Mongo ||
|
|
repositoryType == XRepositoryType.InMemory) &&
|
|
contextType.IsNull());
|
|
if (!isRepositoryTypeValid)
|
|
{
|
|
//
|
|
Log("Service Registration failed, Invalid Repository Type and Context Type ...");
|
|
throw exception;
|
|
}
|
|
|
|
//
|
|
// Maske Instance of Repository Descriptor
|
|
// Based on Provided Type ...
|
|
switch (repositoryType)
|
|
{
|
|
//
|
|
case XRepositoryType.EF:
|
|
//
|
|
// XAiMessage ...
|
|
aiMessageDescriptor = typeof(XAiModelsHelper)
|
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
|
args: null,
|
|
runtimeType: contextType,
|
|
methodName: XAiModelsConstants.GetXAiMessageEFRepositoryDescriptor
|
|
);
|
|
|
|
//
|
|
// XAiProject ...
|
|
aiProjectDescriptor = typeof(XAiModelsHelper)
|
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
|
args: null,
|
|
runtimeType: contextType,
|
|
methodName: XAiModelsConstants.GetXAiProjectEFRepositoryDescriptor
|
|
);
|
|
|
|
//
|
|
// XAiConversation ...
|
|
aiConversationDescriptor = typeof(XAiModelsHelper)
|
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
|
args: null,
|
|
runtimeType: contextType,
|
|
methodName: XAiModelsConstants.GetXAiConversationEFRepositoryDescriptor
|
|
);
|
|
break;
|
|
|
|
//
|
|
case XRepositoryType.Mongo:
|
|
//
|
|
// XAiMessage ...
|
|
aiMessageDescriptor = XAiModelsHelper.GetXAiMessageMongoRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiProject ...
|
|
aiProjectDescriptor = XAiModelsHelper.GetXAiProjectMongoRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiConversation ...
|
|
aiConversationDescriptor = XAiModelsHelper.GetXAiConversationMongoRepositoryDescriptor();
|
|
break;
|
|
|
|
//
|
|
case XRepositoryType.InMemory:
|
|
//
|
|
// XAiMessage ...
|
|
aiMessageDescriptor = XAiModelsHelper.GetXAiMessageInMemoryRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiProject ...
|
|
aiProjectDescriptor = XAiModelsHelper.GetXAiProjectInMemoryRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiConversation ...
|
|
aiConversationDescriptor = XAiModelsHelper.GetXAiConversationInMemoryRepositoryDescriptor();
|
|
break;
|
|
}
|
|
|
|
//
|
|
#region Register Repository Descriptor ...
|
|
//
|
|
// XAiMessage ...
|
|
if (!aiMessageDescriptor.IsNull())
|
|
{
|
|
//
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: aiMessageDescriptor
|
|
);
|
|
}
|
|
|
|
//
|
|
// XAiProject ...
|
|
if (!aiProjectDescriptor.IsNull())
|
|
{
|
|
//
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: aiProjectDescriptor
|
|
);
|
|
}
|
|
|
|
//
|
|
// XAiConversation ...
|
|
if (!aiConversationDescriptor.IsNull())
|
|
{
|
|
//
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: aiConversationDescriptor
|
|
);
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Register Services ...
|
|
//
|
|
#region AiMessage ...
|
|
//
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiMessageServiceProvider), typeof(XAiMessageServiceProvider), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiMessageRepositoryService), typeof(XAiMessageRepositoryService), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiMessageRepositoryProvider), typeof(XAiMessageRepositoryProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
// Enrichers ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiMessageEnricher), typeof(XAiMessageEnricher), lifeTime)
|
|
);
|
|
#endregion
|
|
|
|
//
|
|
#region AiProject ...
|
|
//
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiProjectServiceProvider), typeof(XAiProjectServiceProvider), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiProjectRepositoryService), typeof(XAiProjectRepositoryService), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiProjectRepositoryProvider), typeof(XAiProjectRepositoryProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
// Resource Providers ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiProjectTitleResourceProvider), typeof(XAiProjectTitleResourceProvider), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiProjectDescriptionResourceProvider), typeof(XAiProjectDescriptionResourceProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
// Enrichers ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiProjectEnricher), typeof(XAiProjectEnricher), lifeTime)
|
|
);
|
|
#endregion
|
|
|
|
//
|
|
#region AiConversation ...
|
|
//
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiConversationServiceProvider), typeof(XAiConversationServiceProvider), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiConversationRepositoryService), typeof(XAiConversationRepositoryService), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiConversationRepositoryProvider), typeof(XAiConversationRepositoryProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
// Resource Providers ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiConversationTitleResourceProvider), typeof(XAiConversationTitleResourceProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
// Enrichers ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiConversationEnricher), typeof(XAiConversationEnricher), lifeTime)
|
|
);
|
|
#endregion
|
|
#endregion
|
|
|
|
//
|
|
// Data Provider ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiDataProvider), typeof(XAiDataProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
Log("Service Regitration Succeed ...");
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Extensions\ChatResponseExtensions.cs
|
|
|
|
using xCommons.Extensions;
|
|
using Microsoft.Extensions.AI;
|
|
|
|
namespace xAiModels.Extensions
|
|
{
|
|
public static class ChatResponseExtensions
|
|
{
|
|
/// <summary>
|
|
/// Validate a Chat Response ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this ChatResponse source)
|
|
{
|
|
//
|
|
var result =
|
|
source is not null &&
|
|
!source.IsNullOrDefault() &&
|
|
!string.IsNullOrWhiteSpace(source.Text) &&
|
|
source.FinishReason == ChatFinishReason.Stop;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Extensions\ChatRoleExtensions.cs
|
|
|
|
using xAiModels.Constants;
|
|
using xCommons.Extensions;
|
|
using Microsoft.Extensions.AI;
|
|
|
|
namespace xAiModels.Extensions
|
|
{
|
|
/// <summary>
|
|
/// Extensions for ChatRole ...
|
|
/// </summary>
|
|
public static class ChatRoleExtensions
|
|
{
|
|
/// <summary>
|
|
/// Normalize an String to Propper Chat Role Value ...
|
|
/// <see cref="XAiChatRoles"/>>
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static string GetChatRoleTitle(this string source)
|
|
{
|
|
//
|
|
var result = XAiChatRoles.None;
|
|
|
|
//
|
|
if (source.ToNormalString() == XAiChatRoles.None.ToNormalString())
|
|
{
|
|
result = XAiChatRoles.None;
|
|
}
|
|
else if (source.ToNormalString() == XAiChatRoles.User.ToNormalString())
|
|
{
|
|
result = XAiChatRoles.User;
|
|
}
|
|
else if (source.ToNormalString() == XAiChatRoles.Tool.ToNormalString())
|
|
{
|
|
result = XAiChatRoles.Tool;
|
|
}
|
|
else if (source.ToNormalString() == XAiChatRoles.System.ToNormalString())
|
|
{
|
|
result = XAiChatRoles.System;
|
|
}
|
|
else if (source.ToNormalString() == XAiChatRoles.Assistant.ToNormalString())
|
|
{
|
|
result = XAiChatRoles.Assistant;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get Chat Role Title from Chat Role Class ...
|
|
/// <see cref="XAiChatRoles"/>
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static string GetRole(this ChatRole source)
|
|
{
|
|
//
|
|
var result = source.Value
|
|
.GetChatRoleTitle();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generate Chat Role Class Based on role Title ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static ChatRole ToChatRole(this string source)
|
|
{
|
|
//
|
|
var role = source.GetChatRoleTitle();
|
|
ChatRole result = new ChatRole(role);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generate Chat Role Class Based on role Title ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static ChatRole ToChatRole(this XAiChatRole source)
|
|
{
|
|
//
|
|
var role = source.GetStringValue();
|
|
ChatRole result = new ChatRole(role);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Extract Chat Role Enum from Chat Role ...
|
|
/// <see cref="ChatRole"/>
|
|
/// <see cref="XAiChatRole"/>
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static XAiChatRole ToChatRole(this ChatRole source)
|
|
{
|
|
//
|
|
var role = source
|
|
.GetRole()
|
|
.GetChatRoleTitle();
|
|
|
|
//
|
|
XAiChatRole result = XAiChatRole.User;
|
|
|
|
//
|
|
if (role == XAiChatRoles.User)
|
|
{
|
|
result = XAiChatRole.User;
|
|
}
|
|
else if (role == XAiChatRoles.Tool)
|
|
{
|
|
result = XAiChatRole.Tool;
|
|
}
|
|
else if (role == XAiChatRoles.System)
|
|
{
|
|
result = XAiChatRole.System;
|
|
}
|
|
else if (role == XAiChatRoles.Assistant)
|
|
{
|
|
result = XAiChatRole.Assistant;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate an String as Chat Role ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this string source)
|
|
{
|
|
//
|
|
var result =
|
|
source != XAiChatRoles.None &&
|
|
source.ToNormalString() != XAiChatRoles.None.ToNormalString();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate Role ...
|
|
/// <see cref="XAiChatRole"/>>
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this XAiChatRole source)
|
|
{
|
|
//
|
|
var result = source != XAiChatRole.None;
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate Role ...
|
|
/// <see cref="ChatRole"/>>
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this ChatRole source)
|
|
{
|
|
//
|
|
var role = source.ToChatRole();
|
|
var result = role.IsValid();
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Extensions\XAiApiConfigurationExtensions.cs
|
|
|
|
using System.Linq;
|
|
using xAiModels.Models;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Configurations;
|
|
|
|
namespace xAiModels.Extensions
|
|
{
|
|
public static class XAiApiConfigurationExtensions
|
|
{
|
|
/// <summary>
|
|
/// Validate Api Configuration ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this XAiApiConfiguration source)
|
|
{
|
|
return
|
|
!source.IsNullOrDefault() &&
|
|
source.Models.HasChild();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve Default Model Descriptor ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static XAiModelDescriptor GetDefaultModel(this XAiApiConfiguration source)
|
|
{
|
|
//
|
|
XAiModelDescriptor result = null;
|
|
|
|
//
|
|
if (source.IsValid())
|
|
{
|
|
result = source.Models.First();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Extensions\XAiModelsExtensions.cs
|
|
|
|
using System.Linq;
|
|
using xAiModels.Models;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Extensions
|
|
{
|
|
/// <summary>
|
|
/// Extensions Methods for XAiModels ...
|
|
/// </summary>
|
|
public static class XAiModelsExtensions
|
|
{
|
|
/// <summary>
|
|
/// Validate a Project for Add Or Update ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValidForAddOrUpdate(this XAiProject source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.OwnerId.IsNullOrEmpty() &&
|
|
!source.Title.IsNullOrEmpty() &&
|
|
!source.Prompt.IsNullOrEmpty();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
public static bool IsValidForAddOrUpdate(this XAiProjectDto source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.OwnerId.IsNullOrEmpty() &&
|
|
!source.Title.IsNullOrEmpty() &&
|
|
!source.Prompt.IsNullOrEmpty();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate a Conversation for Add Or Update ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValidForAddOrUpdate(this XAiConversation source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.OwnerId.IsNullOrEmpty() &&
|
|
!source.Title.IsNullOrEmpty() &&
|
|
!source.ProjectId.IsNull() &&
|
|
!source.ProjectId.IsDefaultGuid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
public static bool IsValidForAddOrUpdate(this XAiConversationDto source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.OwnerId.IsNullOrEmpty() &&
|
|
!source.Title.IsNullOrEmpty() &&
|
|
!source.ProjectId.IsNull() &&
|
|
!source.ProjectId.IsDefaultGuid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate a Message for Add Or Update ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValidForAddOrUpdate(this XAiMessage source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.OwnerId.IsNullOrEmpty() &&
|
|
source.Role.IsValid() &&
|
|
!source.ConversationId.IsNull() &&
|
|
!source.ConversationId.IsDefaultGuid() &&
|
|
!source.Content.IsNullOrEmpty();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
public static bool IsValidForAddOrUpdate(this XAiMessageDto source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.OwnerId.IsNullOrEmpty() &&
|
|
source.Role.IsValid() &&
|
|
!source.ConversationId.IsNull() &&
|
|
!source.ConversationId.IsDefaultGuid() &&
|
|
!source.Content.IsNullOrEmpty();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate a Model Descriptor ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this XAiModelDescriptor source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.Name.IsNullOrEmpty() &&
|
|
!source.Url.IsNullOrEmpty() &&
|
|
source.Url.IsValidUrl() &&
|
|
!source.LLM.IsNullOrEmpty() &&
|
|
source.Provider != Constants.XAiModelProviderType.None;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate Specified Param ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this XAiPromptParam source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.Name.IsNullOrEmpty() &&
|
|
!source.Param.IsNullOrEmpty();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate Specified Prompt ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this XAiPromptDescriptor source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.Name.IsNullOrEmpty() &&
|
|
!source.Template.IsNullOrEmpty();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (source.Params.HasChild())
|
|
{
|
|
result =
|
|
result &&
|
|
source.Params.All(x => x.IsValid());
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Helpers\XAiModelsHelper.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
using xDataService.Db;
|
|
using xDataService.Models;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Providers.GraphQL;
|
|
using xAiModels.Providers.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Helpers
|
|
{
|
|
public static class XAiModelsHelper
|
|
{
|
|
//
|
|
#region XAiConversation ...
|
|
//
|
|
#region EF Repository Descriptor Provider(s) ...
|
|
public static XEFRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationEFRepository<TContext>,
|
|
TContext
|
|
> GetXAiConversationEFRepositoryDescriptor<TContext>()
|
|
where TContext : XDbContext
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationEFRepository<TContext>,
|
|
TContext
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XEFRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationEFRepository<TContext>,
|
|
TContext,
|
|
IXAiConversationSeeder,
|
|
TSeederImplementation
|
|
> GetXAiConversationEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
|
where TContext : XDbContext
|
|
where TSeederImplementation : XBaseDbSeeder<XAiConversation, Guid>
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationEFRepository<TContext>,
|
|
TContext,
|
|
IXAiConversationSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Mongo Repository Descriptor Provider(s) ...
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationMongoRepository
|
|
> GetXAiConversationMongoRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationMongoRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationMongoRepository,
|
|
IXAiConversationSeeder,
|
|
TSeederImplementation
|
|
> GetXAiConversationMongoRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiConversation, Guid>
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationMongoRepository,
|
|
IXAiConversationSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region InMemory Repository Descriptor Provider(s) ...
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationInMemoryRepository
|
|
> GetXAiConversationInMemoryRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationInMemoryRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationInMemoryRepository,
|
|
IXAiConversationSeeder,
|
|
TSeederImplementation
|
|
> GetXAiConversationInMemoryRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiConversation, Guid>
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiConversation,
|
|
Guid,
|
|
IXAiConversationKeyGenerator,
|
|
XAiConversationKeyGenerator,
|
|
IXAiConversationRepositoryEvents,
|
|
XAiConversationRepositoryEvents,
|
|
XAiConversationGraphType,
|
|
GuidGraphType,
|
|
XAiConversationGraphQuery,
|
|
IXAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphQLTypeHelper,
|
|
XAiConversationGraphSchema,
|
|
IXAiConversationRepository,
|
|
XAiConversationInMemoryRepository,
|
|
IXAiConversationSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
//
|
|
#region XAiMessage ...
|
|
//
|
|
#region EF Repository Descriptor Provider(s) ...
|
|
public static XEFRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageEFRepository<TContext>,
|
|
TContext
|
|
> GetXAiMessageEFRepositoryDescriptor<TContext>()
|
|
where TContext : XDbContext
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageEFRepository<TContext>,
|
|
TContext
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XEFRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageEFRepository<TContext>,
|
|
TContext,
|
|
IXAiMessageSeeder,
|
|
TSeederImplementation
|
|
> GetXAiMessageEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
|
where TContext : XDbContext
|
|
where TSeederImplementation : XBaseDbSeeder<XAiMessage, Guid>
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageEFRepository<TContext>,
|
|
TContext,
|
|
IXAiMessageSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Mongo Repository Descriptor Provider(s) ...
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageMongoRepository
|
|
> GetXAiMessageMongoRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageMongoRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageMongoRepository,
|
|
IXAiMessageSeeder,
|
|
TSeederImplementation
|
|
> GetXAiMessageMongoRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiMessage, Guid>
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageMongoRepository,
|
|
IXAiMessageSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region InMemory Repository Descriptor Provider(s) ...
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageInMemoryRepository
|
|
> GetXAiMessageInMemoryRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageInMemoryRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageInMemoryRepository,
|
|
IXAiMessageSeeder,
|
|
TSeederImplementation
|
|
> GetXAiMessageInMemoryRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiMessage, Guid>
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiMessage,
|
|
Guid,
|
|
IXAiMessageKeyGenerator,
|
|
XAiMessageKeyGenerator,
|
|
IXAiMessageRepositoryEvents,
|
|
XAiMessageRepositoryEvents,
|
|
XAiMessageGraphType,
|
|
GuidGraphType,
|
|
XAiMessageGraphQuery,
|
|
IXAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphQLTypeHelper,
|
|
XAiMessageGraphSchema,
|
|
IXAiMessageRepository,
|
|
XAiMessageInMemoryRepository,
|
|
IXAiMessageSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
//
|
|
#region XAiProject ...
|
|
//
|
|
#region EF Repository Descriptor Provider(s) ...
|
|
public static XEFRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectEFRepository<TContext>,
|
|
TContext
|
|
> GetXAiProjectEFRepositoryDescriptor<TContext>()
|
|
where TContext : XDbContext
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectEFRepository<TContext>,
|
|
TContext
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XEFRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectEFRepository<TContext>,
|
|
TContext,
|
|
IXAiProjectSeeder,
|
|
TSeederImplementation
|
|
> GetXAiProjectEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
|
where TContext : XDbContext
|
|
where TSeederImplementation : XBaseDbSeeder<XAiProject, Guid>
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectEFRepository<TContext>,
|
|
TContext,
|
|
IXAiProjectSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Mongo Repository Descriptor Provider(s) ...
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectMongoRepository
|
|
> GetXAiProjectMongoRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectMongoRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectMongoRepository,
|
|
IXAiProjectSeeder,
|
|
TSeederImplementation
|
|
> GetXAiProjectMongoRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiProject, Guid>
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectMongoRepository,
|
|
IXAiProjectSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region InMemory Repository Descriptor Provider(s) ...
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectInMemoryRepository
|
|
> GetXAiProjectInMemoryRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectInMemoryRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectInMemoryRepository,
|
|
IXAiProjectSeeder,
|
|
TSeederImplementation
|
|
> GetXAiProjectInMemoryRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiProject, Guid>
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiProject,
|
|
Guid,
|
|
IXAiProjectKeyGenerator,
|
|
XAiProjectKeyGenerator,
|
|
IXAiProjectRepositoryEvents,
|
|
XAiProjectRepositoryEvents,
|
|
XAiProjectGraphType,
|
|
GuidGraphType,
|
|
XAiProjectGraphQuery,
|
|
IXAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphQLTypeHelper,
|
|
XAiProjectGraphSchema,
|
|
IXAiProjectRepository,
|
|
XAiProjectInMemoryRepository,
|
|
IXAiProjectSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\IXAiConversationTitleResourceProvider.cs
|
|
|
|
using xStringService.Interfaces;
|
|
|
|
namespace xAiModels.Interfaces
|
|
{
|
|
public interface IXAiConversationTitleResourceProvider : IXOwnedItemResourceProvider
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\IXAiDataProvider.cs
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// All Data Manipulation Requirements ...
|
|
/// </summary>
|
|
public interface IXAiDataProvider
|
|
{
|
|
//
|
|
#region Loaders ...
|
|
/// <summary>
|
|
/// Load Projects List of Specified Owner ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiProjectDto>> LoadProjects(
|
|
string ownerId,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Load List of Conversations for Specified Project ...
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
|
Guid projectId,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Load Messages of Specified Conversation ...
|
|
/// </summary>
|
|
/// <param name="conversationId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiMessageDto>> LoadMessages(
|
|
Guid conversationId,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
|
|
//
|
|
#region Creator/Adders ...
|
|
/// <summary>
|
|
/// Create Project ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="item"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiProjectDto> CreateProject(
|
|
string ownerId,
|
|
XAiProjectDto item = null,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Create Conversation ...
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="item"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiConversationDto> CreateConversation(
|
|
Guid projectId,
|
|
XAiConversationDto item = null,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Add Message ...
|
|
/// </summary>
|
|
/// <param name="conversationId"></param>
|
|
/// <param name="item"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiMessageDto> AddMessage(
|
|
Guid conversationId,
|
|
XAiMessageDto item,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\IXAiProjectDescriptionResourceProvider.cs
|
|
|
|
using xStringService.Interfaces;
|
|
|
|
namespace xAiModels.Interfaces
|
|
{
|
|
public interface IXAiProjectDescriptionResourceProvider : IXOwnedItemResourceProvider
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\IXAiProjectTitleResourceProvider.cs
|
|
|
|
using xStringService.Interfaces;
|
|
|
|
namespace xAiModels.Interfaces
|
|
{
|
|
public interface IXAiProjectTitleResourceProvider : IXOwnedItemResourceProvider
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiConversationDtoHub.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiConversationDtoHub : IXBaseDtoHub<XAiConversation, XAiConversationDto, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiConversationRepositoryService.cs
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiConversationRepositoryService : IXBaseRepositoryService<XAiConversation, XAiConversationDto, Guid>
|
|
{
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiConversationDto> Enrich(
|
|
XAiConversation source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiConversationDto> Enrich(
|
|
XAiConversationDto source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversation> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversationDto> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiConversationServiceProvider.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Providers.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiConversationServiceProvider : IXBaseDtoProvider<XAiConversation, XAiConversationDto, Guid, XAiConversationDtoHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiMessageDtoHub.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiMessageDtoHub : IXBaseDtoHub<XAiMessage, XAiMessageDto, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiMessageRepositoryService.cs
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiMessageRepositoryService : IXBaseRepositoryService<XAiMessage, XAiMessageDto, Guid>
|
|
{
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiMessageDto> Enrich(
|
|
XAiMessage source,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiMessageDto> Enrich(
|
|
XAiMessageDto source,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessage> sources,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessageDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiMessageServiceProvider.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Providers.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiMessageServiceProvider : IXBaseDtoProvider<XAiMessage, XAiMessageDto, Guid, XAiMessageDtoHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiProjectDtoHub.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiProjectDtoHub : IXBaseDtoHub<XAiProject, XAiProjectDto, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiProjectRepositoryService.cs
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiProjectRepositoryService : IXBaseRepositoryService<XAiProject, XAiProjectDto, Guid>
|
|
{
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiProjectDto> Enrich(
|
|
XAiProject source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiProjectDto> Enrich(
|
|
XAiProjectDto source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProject> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProjectDto> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiProjectServiceProvider.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Providers.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiProjectServiceProvider : IXBaseDtoProvider<XAiProject, XAiProjectDto, Guid, XAiProjectDtoHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Enrichers\IXAiConversationEnricher.cs
|
|
|
|
using System.Threading;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Interfaces.Enrichers
|
|
{
|
|
/// <summary>
|
|
/// Ai Conversation Enricher ...
|
|
/// </summary>
|
|
public interface IXAiConversationEnricher
|
|
{
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiConversationDto> Enrich(
|
|
XAiConversation source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiConversationDto> Enrich(
|
|
XAiConversationDto source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversation> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversationDto> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Enrichers\IXAiMessageEnricher.cs
|
|
|
|
using System.Threading;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Interfaces.Enrichers
|
|
{
|
|
public interface IXAiMessageEnricher
|
|
{
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiMessageDto> Enrich(
|
|
XAiMessage source,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiMessageDto> Enrich(
|
|
XAiMessageDto source,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessage> sources,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessageDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Enrichers\IXAiProjectEnricher.cs
|
|
|
|
using System.Threading;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Interfaces.Enrichers
|
|
{
|
|
public interface IXAiProjectEnricher
|
|
{
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiProjectDto> Enrich(
|
|
XAiProject source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiProjectDto> Enrich(
|
|
XAiProjectDto source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProject> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProjectDto> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiConversationEntityHub : IXBaseEntityHub<XAiConversation, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiConversationGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XAiConversation, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationKeyGenerator.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiConversationKeyGenerator : IXKeyGenerator<XAiConversation, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiConversationRepository : IXBaseRepository<XAiConversation, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationRepositoryEvents.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiConversationRepositoryEvents : IXBaseRepositoryEvents<XAiConversation>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Providers.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiConversationRepositoryProvider : IXBaseEntityProvider<XAiConversation, Guid, XAiConversationEntityHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationSeeder.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiConversationSeeder : IXBaseDbSeeder<XAiConversation, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiDocumentEntityHub.cs
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiDocumentEntityHub
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMessageEntityHub : IXBaseEntityHub<XAiMessage, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMessageGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XAiMessage, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageKeyGenerator.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMessageKeyGenerator : IXKeyGenerator<XAiMessage, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMessageRepository : IXBaseRepository<XAiMessage, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageRepositoryEvents.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMessageRepositoryEvents : IXBaseRepositoryEvents<XAiMessage>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Providers.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMessageRepositoryProvider : IXBaseEntityProvider<XAiMessage, Guid, XAiMessageEntityHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageSeeder.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMessageSeeder : IXBaseDbSeeder<XAiMessage, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiProjectEntityHub : IXBaseEntityHub<XAiProject, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiProjectGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XAiProject, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectKeyGenerator.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiProjectKeyGenerator : IXKeyGenerator<XAiProject, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiProjectRepository : IXBaseRepository<XAiProject, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectRepositoryEvents.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiProjectRepositoryEvents : IXBaseRepositoryEvents<XAiProject>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Providers.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiProjectRepositoryProvider : IXBaseEntityProvider<XAiProject, Guid, XAiProjectEntityHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectSeeder.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiProjectSeeder : IXBaseDbSeeder<XAiProject, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiModelDescriptor.cs
|
|
|
|
using xAiModels.Constants;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
/// <summary>
|
|
/// Describe a Provided Model ...
|
|
/// </summary>
|
|
public class XAiModelDescriptor
|
|
{
|
|
/// <summary>
|
|
/// Provider Name ...
|
|
/// </summary>
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// LLM Provider Url ...
|
|
/// </summary>
|
|
public string Url { get; set; }
|
|
|
|
/// <summary>
|
|
/// Model Name ...
|
|
/// </summary>
|
|
public string LLM { get; set; }
|
|
|
|
/// <summary>
|
|
/// Api Key for Connection ...
|
|
/// </summary>
|
|
public string ApiKey { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specified Model Provider Type ...
|
|
/// </summary>
|
|
public XAiModelProviderType Provider { get; set; } = XAiModelProviderType.Ollama;
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiPromptDescriptor.cs
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
/// <summary>
|
|
/// Describe Specified Prompt ...
|
|
/// </summary>
|
|
public class XAiPromptDescriptor
|
|
{
|
|
/// <summary>
|
|
/// Prompt Name ...
|
|
/// </summary>
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// Prompt Template ...
|
|
/// </summary>
|
|
public string Template { get; set; }
|
|
|
|
/// <summary>
|
|
/// Prompt Description ...
|
|
/// </summary>
|
|
public string Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// Prompt Template Params ...
|
|
/// </summary>
|
|
public XAiPromptParam[] Params { get; set; } = [];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Specified a Prompt Param ...
|
|
/// </summary>
|
|
public class XAiPromptParam
|
|
{
|
|
/// <summary>
|
|
/// Param Name ...
|
|
/// </summary>
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// Param Identifier ...
|
|
/// </summary>
|
|
public string Param { get; set; }
|
|
|
|
/// <summary>
|
|
/// Parma Description ...
|
|
/// </summary>
|
|
public string Description { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\Dtos\XAiConversationDto.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using xModels.Dtos;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Models.Dtos
|
|
{
|
|
/// <summary>
|
|
/// Conversation Describe ...
|
|
/// </summary>
|
|
public class XAiConversationDto : XBaseGuidIDEntityDto
|
|
{
|
|
/// <summary>
|
|
/// User Identifier ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Owner Info ...
|
|
/// </summary>
|
|
public virtual XPersonDto Owner { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Conversation Title Resource ID ...
|
|
/// </summary>
|
|
public string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// All Exists Title Locale Resources ...
|
|
/// </summary>
|
|
public virtual XResourceDto TitleResource { get; set; }
|
|
|
|
/// <summary>
|
|
/// Created Time ...
|
|
/// </summary>
|
|
public DateTime CreatedOn { get; set; }
|
|
|
|
/// <summary>
|
|
/// Updated Time ...
|
|
/// </summary>
|
|
public DateTime UpdatedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Conversation Messages ...
|
|
/// </summary>
|
|
public virtual IEnumerable<XAiMessageDto> Messages { get; set; } = [];
|
|
|
|
/// <summary>
|
|
/// Project ID ...
|
|
/// </summary>
|
|
public Guid ProjectId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Project Title Resource ID ...
|
|
/// </summary>
|
|
public virtual string ProjectTitle { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Project Description Resource ID ...
|
|
/// </summary>
|
|
public virtual string ProjectDescription { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Project Title Locale Resources ...
|
|
/// </summary>
|
|
public virtual XResourceDto ProjectTitleResource { get; set; }
|
|
|
|
/// <summary>
|
|
/// Project Description Locale Resources ...
|
|
/// </summary>
|
|
public virtual XResourceDto ProjectDescriptionResource { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\Dtos\XAiMessageDto.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using xModels.Dtos;
|
|
using xAiModels.Constants;
|
|
using xCommons.Extensions;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace xAiModels.Models.Dtos
|
|
{
|
|
public class XAiMessageDto : XBaseGuidIDEntityDto
|
|
{
|
|
/// <summary>
|
|
/// User Identifier ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Owner Info ...
|
|
/// </summary>
|
|
public virtual XPersonDto Owner { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Message of Chat ...
|
|
/// </summary>
|
|
public string Content { get; set; }
|
|
|
|
/// <summary>
|
|
/// Role of Message ...
|
|
/// </summary>
|
|
public XAiChatRole Role { get; set; }
|
|
|
|
/// <summary>
|
|
/// Created Time ...
|
|
/// </summary>
|
|
public DateTime CreatedOn { get; set; }
|
|
|
|
/// <summary>
|
|
/// Updated Time ...
|
|
/// </summary>
|
|
public DateTime UpdatedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Conversation Id ...
|
|
/// </summary>
|
|
public Guid ConversationId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Conversation Info ...
|
|
/// </summary>
|
|
public virtual string ConversationTitle { get; set; } = null;
|
|
public virtual XResourceDto ConversationTitleResouce { get; set; } = null;
|
|
|
|
//
|
|
#region Meta Data Property ...
|
|
private string _metadata;
|
|
|
|
/// <summary>
|
|
/// Meta Data of Message ...
|
|
/// </summary>
|
|
[NotMapped]
|
|
public IDictionary<string, object> Metadata { get; private set; } = null;
|
|
|
|
/// <summary>
|
|
/// Meta Data of MEssage in Json ...
|
|
/// </summary>
|
|
public string MetaDatas
|
|
{
|
|
//
|
|
get => _metadata;
|
|
|
|
//
|
|
set
|
|
{
|
|
//
|
|
// Converts Json String to Dictionary ...
|
|
if (!value.IsNullOrEmpty())
|
|
{
|
|
Metadata = value.FromJSON<IDictionary<string, object>>();
|
|
}
|
|
|
|
//
|
|
_metadata = value;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\Dtos\XAiProjectDto.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using xModels.Dtos;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Models.Dtos
|
|
{
|
|
/// <summary>
|
|
/// Describe a Project ...
|
|
/// </summary>
|
|
public class XAiProjectDto : XBaseGuidIDEntityDto
|
|
{
|
|
/// <summary>
|
|
/// User Identifier ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Owner Info ...
|
|
/// </summary>
|
|
public virtual XPersonDto Owner { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Title of Project ...
|
|
/// </summary>
|
|
public string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// All Exists Title Locale Resources ...
|
|
/// </summary>
|
|
public virtual XResourceDto TitleResource { get; set; }
|
|
|
|
/// <summary>
|
|
/// Description of Project ...
|
|
/// </summary>
|
|
public string Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// All Exists Description Locale Resources ...
|
|
/// </summary>
|
|
public virtual XResourceDto DescriptionResource { get; set; }
|
|
|
|
/// <summary>
|
|
/// a Prompt for Project Start ...
|
|
/// </summary>
|
|
public string Prompt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Created Time ...
|
|
/// </summary>
|
|
public DateTime CreatedOn { get; set; }
|
|
|
|
/// <summary>
|
|
/// Updated Time ...
|
|
/// </summary>
|
|
public DateTime UpdatedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Conversations ...
|
|
/// </summary>
|
|
public virtual IList<XAiConversationDto> Conversations { get; set; } = [];
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\Entities\XAiConversation.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace xAiModels.Models.Entities
|
|
{
|
|
/// <summary>
|
|
/// Conversation Describe ...
|
|
/// </summary>
|
|
public class XAiConversation : XBaseGuidIDEntity
|
|
{
|
|
/// <summary>
|
|
/// User Identifier ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Title of Conversation ...
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// Created Time ...
|
|
/// </summary>
|
|
public DateTime CreatedOn { get; set; }
|
|
|
|
/// <summary>
|
|
/// Updated Time ...
|
|
/// </summary>
|
|
public DateTime UpdatedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Project ID ...
|
|
/// </summary>
|
|
[Required]
|
|
public Guid ProjectId { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\Entities\XAiDocument.cs
|
|
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using xModels.Base;
|
|
|
|
namespace xAiModels.Models.Entities
|
|
{
|
|
/// <summary>
|
|
/// Represents an embedd document in the AI system.
|
|
/// </summary>
|
|
public class XAiDocument : XBaseGuidIDEntity
|
|
{
|
|
/// <summary>
|
|
/// User Identifier ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Title of Document ...
|
|
/// </summary>
|
|
[StringLength(255)]
|
|
public string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// Content of Document ...
|
|
/// </summary>
|
|
public string Content { get; set; }
|
|
|
|
/// <summary>
|
|
/// Hash of the Document Content ...
|
|
/// </summary>
|
|
public string ContentHash { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Embedding Model Identifier ...
|
|
/// </summary>
|
|
public string EmbeddingModel { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Dimensions of the Embedding ...
|
|
/// </summary>
|
|
public int Dimensions { get; set; }
|
|
|
|
/// <summary>
|
|
/// Vector representation of the Document ...
|
|
/// </summary>
|
|
public byte[] Vector { get; set; } = [];
|
|
|
|
/// <summary>
|
|
/// Created Time ...
|
|
/// </summary>
|
|
public DateTime CreatedOn { get; set; }
|
|
|
|
/// <summary>
|
|
/// Updated Time ...
|
|
/// </summary>
|
|
public DateTime UpdatedAt { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\Entities\XAiMessage.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using xAiModels.Constants;
|
|
using xCommons.Extensions;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace xAiModels.Models.Entities
|
|
{
|
|
/// <summary>
|
|
/// Message Model of Ai ...
|
|
/// </summary>
|
|
public class XAiMessage : XBaseGuidIDEntity
|
|
{
|
|
/// <summary>
|
|
/// User Identifier ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Message of Chat ...
|
|
/// </summary>
|
|
[Required]
|
|
public string Content { get; set; }
|
|
|
|
/// <summary>
|
|
/// Role of Message ...
|
|
/// </summary>
|
|
public XAiChatRole Role { get; set; }
|
|
|
|
/// <summary>
|
|
/// Created Time ...
|
|
/// </summary>
|
|
public DateTime CreatedOn { get; set; }
|
|
|
|
/// <summary>
|
|
/// Updated Time ...
|
|
/// </summary>
|
|
public DateTime UpdatedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Conversation Id ...
|
|
/// </summary>
|
|
[StringLength(255)]
|
|
public Guid ConversationId { get; set; }
|
|
|
|
//
|
|
#region Meta Data Property ...
|
|
private string _metadata;
|
|
|
|
/// <summary>
|
|
/// Meta Data of Message ...
|
|
/// </summary>
|
|
[NotMapped]
|
|
public IDictionary<string, object> Metadata { get; private set; } = null;
|
|
|
|
/// <summary>
|
|
/// Meta Data of MEssage in Json ...
|
|
/// </summary>
|
|
public string MetaDatas
|
|
{
|
|
//
|
|
get => _metadata;
|
|
|
|
//
|
|
set
|
|
{
|
|
//
|
|
// Converts Json String to Dictionary ...
|
|
if (!value.IsNullOrEmpty())
|
|
{
|
|
Metadata = value.FromJSON<IDictionary<string, object>>();
|
|
}
|
|
|
|
//
|
|
_metadata = value;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\Entities\XAiProject.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace xAiModels.Models.Entities
|
|
{
|
|
/// <summary>
|
|
/// Describe a Project ...
|
|
/// </summary>
|
|
public class XAiProject : XBaseGuidIDEntity
|
|
{
|
|
/// <summary>
|
|
/// User Identifier ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Title of Project ...
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// Description of Project ...
|
|
/// </summary>
|
|
[StringLength(1000)]
|
|
public string Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// a Prompt for Project Start ...
|
|
/// </summary>
|
|
public string Prompt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Created Time ...
|
|
/// </summary>
|
|
public DateTime CreatedOn { get; set; }
|
|
|
|
/// <summary>
|
|
/// Updated Time ...
|
|
/// </summary>
|
|
public DateTime UpdatedAt { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\XAiConversationEntityRegisterar.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using xAiModels.Configurations.Entities;
|
|
|
|
namespace xAiModels.Providers
|
|
{
|
|
public class XAiConversationEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
|
|
{
|
|
public XAiConversationEntityRegisterar()
|
|
: base(nameof(XAiConversationEntityRegisterar))
|
|
{
|
|
//
|
|
// Add Entity ...
|
|
AddEntity<XAiConversation, Guid>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure Entities ...
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
|
{
|
|
//
|
|
// Configure Entity Using Provided ...
|
|
modelBuilder
|
|
.ApplyConfigurationsFromAssembly(typeof(XAiConversationEntityConfiguration).Assembly);
|
|
|
|
//
|
|
base.ConfigureEntities(modelBuilder);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\XAiConversationTitleResourceProvider.cs
|
|
|
|
using xAiModels.Constants;
|
|
using xAiModels.Interfaces;
|
|
using xCommons.Configurations;
|
|
using xStringService.Providers;
|
|
using xStringService.Interfaces.Dtos;
|
|
|
|
namespace xAiModels.Providers
|
|
{
|
|
public class XAiConversationTitleResourceProvider : XBaseOwnedItemResourceProvider, IXAiConversationTitleResourceProvider
|
|
{
|
|
public XAiConversationTitleResourceProvider(
|
|
XAppConfiguration appConfig,
|
|
IXStringServiceProvider stringProvider
|
|
) : base(
|
|
appConfig: appConfig,
|
|
stringProvider: stringProvider,
|
|
item: XAiModelsConstants.XAiConversationTitleIdentifier
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\XAiDataProvider.cs
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using xModels.Dtos;
|
|
using System.Threading;
|
|
using xAiModels.Constants;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Extensions;
|
|
using xAiModels.Interfaces;
|
|
using xAiModels.Models.Dtos;
|
|
using xExceptions.Constants;
|
|
using System.Threading.Tasks;
|
|
using xCommons.Configurations;
|
|
using xAiModels.Providers.Hubs;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xStringService.Interfaces;
|
|
using System.Collections.Generic;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace xAiModels.Providers
|
|
{
|
|
/// <summary>
|
|
/// All Data Manipulation Requirements ...
|
|
/// </summary>
|
|
public class XAiDataProvider : IXAiDataProvider
|
|
{
|
|
//
|
|
#region Properties ...
|
|
private readonly IXStringProvider stringProvider;
|
|
private readonly XAppConfiguration appConfiguration;
|
|
private readonly IHubContext<XAiDataProviderHub> hub;
|
|
private readonly IXAiMessageRepositoryService messageRepositoryService;
|
|
private readonly IXAiProjectRepositoryService projectRepositoryService;
|
|
private readonly IXAiProjectTitleResourceProvider projectTitleResourceProvider;
|
|
private readonly IXAiConversationRepositoryService conversationRepositoryService;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
|
#endregion
|
|
|
|
public XAiDataProvider(
|
|
IXStringProvider stringProvider,
|
|
XAppConfiguration appConfiguration,
|
|
IHubContext<XAiDataProviderHub> hub,
|
|
IXAiMessageRepositoryService messageRepositoryService,
|
|
IXAiProjectRepositoryService projectRepositoryService,
|
|
IXAiProjectTitleResourceProvider projectTitleResourceProvider,
|
|
IXAiConversationRepositoryService conversationRepositoryService,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider,
|
|
IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider
|
|
)
|
|
{
|
|
this.hub = hub;
|
|
this.stringProvider = stringProvider;
|
|
this.appConfiguration = appConfiguration;
|
|
this.messageRepositoryService = messageRepositoryService;
|
|
this.projectRepositoryService = projectRepositoryService;
|
|
this.projectTitleResourceProvider = projectTitleResourceProvider;
|
|
this.conversationRepositoryService = conversationRepositoryService;
|
|
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
|
this.projectDescriptionResourceProvider = projectDescriptionResourceProvider;
|
|
}
|
|
|
|
//
|
|
#region Loaders ...
|
|
/// <summary>
|
|
/// Load Projects List of Specified Owner ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiProjectDto>> LoadProjects(
|
|
string ownerId,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (ownerId.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Handle Default Project and Conversation ...
|
|
bool hasDefault = await HasDefaultProject(
|
|
ownerId: ownerId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!hasDefault)
|
|
{
|
|
//
|
|
await CreateDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: null,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Retrieve Project List ...
|
|
var result = await projectRepositoryService.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
// fillConversations: fillConversations,
|
|
predicate: x => x.OwnerId == ownerId,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
// fillConversationMessages: fillConversationMessages
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load List of Conversations for Specified Project ...
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
|
Guid projectId,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (projectId.IsNull() ||
|
|
projectId.IsDefaultGuid()
|
|
)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Retrieve Conversation's List ...
|
|
var result = await conversationRepositoryService.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: false,
|
|
// fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken,
|
|
predicate: x => x.ProjectId == projectId,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load Messages of Specified Conversation ...
|
|
/// </summary>
|
|
/// <param name="conversationId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiMessageDto>> LoadMessages(
|
|
Guid conversationId,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (conversationId.IsNull() ||
|
|
conversationId.IsDefaultGuid()
|
|
)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Retrieve Message Lists of Specified Conversation ...
|
|
var result = await messageRepositoryService.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn),
|
|
predicate: x => x.ConversationId == conversationId
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Creator/Adders ...
|
|
public async Task<XAiProjectDto> CreateProject(
|
|
string ownerId,
|
|
XAiProjectDto item = null,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (ownerId.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Check Project Provided or not ...
|
|
var hasProject = !item.IsNullOrDefault();
|
|
|
|
//
|
|
// Normalize Provided Project ...
|
|
if (hasProject)
|
|
{
|
|
//
|
|
item.CreatedOn = DateTime.UtcNow;
|
|
|
|
//
|
|
// Validate Item ...
|
|
if (!item.IsValidForAddOrUpdate())
|
|
{
|
|
XException.InvalidData.Throw();
|
|
}
|
|
}
|
|
|
|
//
|
|
XAiProjectDto result = null;
|
|
|
|
//
|
|
// Create Provided Project ...
|
|
if (hasProject)
|
|
{
|
|
//
|
|
result = await projectRepositoryService.AddAsync(
|
|
item: item,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Handling Send Push Notification ...
|
|
if (!result.IsNullOrDefault() &&
|
|
!connectionId.IsNullOrEmpty()
|
|
)
|
|
{
|
|
//
|
|
await SendPush(
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken,
|
|
payLoad: item.ToJSON(camelCase: true),
|
|
action: XAiDataProviderHubActions.ProjectCreated.GetStringValue()
|
|
);
|
|
}
|
|
}
|
|
//
|
|
// Check Default Project ...
|
|
else
|
|
{
|
|
//
|
|
// Check Default Project Exists or not ...
|
|
var hasDefault = await HasDefaultProject(
|
|
ownerId: ownerId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// If Default Project Exists, Throw Exception ...
|
|
if (hasDefault)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Create and Retrive Default Project ...
|
|
result = await GetDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
if (result.IsNullOrDefault())
|
|
{
|
|
XException.ActionFailed.Throw();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public async Task<XAiConversationDto> CreateConversation(
|
|
Guid projectId,
|
|
XAiConversationDto item = null,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (projectId.IsNull() ||
|
|
projectId.IsDefaultGuid())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Handle Proejct ...
|
|
XAiProjectDto project = await projectRepositoryService.GetAsync(
|
|
id: projectId,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
// fillConversations: false,
|
|
// fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (project.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
// Check Conversation Provided or not ...
|
|
var hasConversation = !item.IsNullOrDefault();
|
|
|
|
//
|
|
// Normalize Conversation if Provided ...
|
|
if (hasConversation)
|
|
{
|
|
//
|
|
item.ProjectId = project.Id;
|
|
item.CreatedOn = DateTime.UtcNow;
|
|
|
|
//
|
|
// Validate Item ...
|
|
if (!item.IsValidForAddOrUpdate())
|
|
{
|
|
XException.InvalidData.Throw();
|
|
}
|
|
}
|
|
|
|
//
|
|
XAiConversationDto result = null;
|
|
|
|
//
|
|
// Create Provided Conversation ...
|
|
if (hasConversation)
|
|
{
|
|
//
|
|
result = await conversationRepositoryService.AddAsync(
|
|
item: item,
|
|
saveChanges: true,
|
|
// fillMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Handling Send Push Notification ...
|
|
if (!result.IsNullOrDefault() &&
|
|
!connectionId.IsNullOrEmpty()
|
|
)
|
|
{
|
|
//
|
|
await SendPush(
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken,
|
|
payLoad: item.ToJSON(camelCase: true),
|
|
action: XAiDataProviderHubActions.ConversationCreated.GetStringValue()
|
|
);
|
|
}
|
|
}
|
|
//
|
|
// Check Default Conversation ...
|
|
else
|
|
{
|
|
//
|
|
// Check Default Conversation Exists or not ...
|
|
var hasDefault = await HasDefaultConversation(
|
|
projectId: project.Id,
|
|
ownerId: project.OwnerId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// If Default Project Exists, Throw Exception ...
|
|
if (hasDefault)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Create and Retrive Default Conversation ...
|
|
result = await GetDefaultConversation(
|
|
projectId: project.Id,
|
|
ownerId: project.OwnerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
if (result.IsNullOrDefault())
|
|
{
|
|
XException.ActionFailed.Throw();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public async Task<XAiMessageDto> AddMessage(
|
|
Guid conversationId,
|
|
XAiMessageDto item,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (item.IsNullOrDefault() ||
|
|
conversationId.IsNull() ||
|
|
conversationId.IsDefaultGuid()
|
|
)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Normalize ...
|
|
item.CreatedOn = DateTime.UtcNow;
|
|
item.ConversationId = conversationId;
|
|
|
|
//
|
|
// Validate Item ...
|
|
if (!item.IsValidForAddOrUpdate())
|
|
{
|
|
XException.InvalidData.Throw();
|
|
}
|
|
|
|
//
|
|
var result = await messageRepositoryService.AddAsync(
|
|
item: item,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Handling Send Push Notification ...
|
|
if (!result.IsNullOrDefault() &&
|
|
!connectionId.IsNullOrEmpty()
|
|
)
|
|
{
|
|
//
|
|
await SendPush(
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken,
|
|
payLoad: item.ToJSON(camelCase: true),
|
|
action: XAiDataProviderHubActions.MessageCreated.GetStringValue()
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Updaters ...
|
|
#endregion
|
|
|
|
//
|
|
#region Private ...
|
|
/// <summary>
|
|
/// Check Default Project Exists or not ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
private async Task<bool> HasDefaultProject(
|
|
string ownerId,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
var result = !ownerId.IsNullOrEmpty();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Default Owner Exists or not ...
|
|
result = !(await stringProvider.FindOne(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x =>
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToNormalString()) &&
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.XAiProjectTitleIdentifier
|
|
.ToNormalString()) &&
|
|
x.TranslatedValue
|
|
.ToNormalString()
|
|
.Contains(XAiDataProviderConstants.XDefaultAiProjectSuffix)
|
|
))
|
|
.IsNullOrDefault();
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve Default Project of Specified Owner ...
|
|
/// Create it if not Handled ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
private async Task<XAiProjectDto> GetDefaultProject(
|
|
string ownerId,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Check Default Project Exists or noit ...
|
|
var isExists = await HasDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!isExists)
|
|
{
|
|
//
|
|
await CreateDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
var resource = await stringProvider.FindOne(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x =>
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToNormalString()) &&
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.XAiProjectTitleIdentifier
|
|
.ToNormalString()) &&
|
|
x.TranslatedValue
|
|
.ToNormalString()
|
|
.Contains(XAiDataProviderConstants.XDefaultAiProjectSuffix)
|
|
);
|
|
if (resource.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
var result = await projectRepositoryService.FindOneAsync(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x => x.Title
|
|
.Equals(
|
|
resource.ResourceTitle,
|
|
StringComparison.InvariantCultureIgnoreCase
|
|
)
|
|
);
|
|
if (result.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create Default Project for Specified Owner ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
private async Task CreateDefaultProject(
|
|
string ownerId,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
if (ownerId.IsNullOrEmpty())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
var defaultLang = appConfiguration.DefaultLanguage;
|
|
|
|
//
|
|
// Check Default Owner Exists or not ...
|
|
var isExists = await HasDefaultProject(
|
|
ownerId: ownerId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (isExists)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Create Default ...
|
|
var item = new XAiProjectDto()
|
|
{
|
|
OwnerId = ownerId,
|
|
CreatedOn = DateTime.UtcNow,
|
|
Title = Guid.NewGuid().ToString(),
|
|
Description = Guid.NewGuid().ToString(),
|
|
};
|
|
item = await projectRepositoryService.AddAsync(
|
|
item: item,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Prepare Tile and Description Resource Ids ...
|
|
var titleResource = await projectTitleResourceProvider.AddOrUpdateLocale(
|
|
owner: ownerId,
|
|
identifier: item.Id,
|
|
locale: new XLocaleResourceDto
|
|
{
|
|
Language = defaultLang,
|
|
Value = XAiDataProviderConstants.XDefaultAiProjectSuffix
|
|
},
|
|
cancellationToken: cancellationToken
|
|
);
|
|
var descriptionResource = await projectDescriptionResourceProvider.AddOrUpdateLocale(
|
|
owner: ownerId,
|
|
identifier: item.Id,
|
|
new XLocaleResourceDto
|
|
{
|
|
Language = defaultLang,
|
|
Value = XAiDataProviderConstants.XDefaultAiProjectSuffix
|
|
},
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (titleResource.IsNullOrDefault() ||
|
|
descriptionResource.IsNullOrDefault()
|
|
)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Update Project Resources ...
|
|
item.Title = titleResource.Resource;
|
|
item.Description = descriptionResource.Resource;
|
|
item = await projectRepositoryService.UpdateAsync(
|
|
id: item.Id,
|
|
item: item,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Sending Push ...
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await SendPush(
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken,
|
|
payLoad: item.ToJSON(camelCase: true),
|
|
action: XAiDataProviderHubActions.ProjectCreated.GetStringValue()
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check Default Conversation Exists or not ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
private async Task<bool> HasDefaultConversation(
|
|
string ownerId,
|
|
Guid projectId,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
var result = !ownerId.IsNullOrEmpty();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Prepare Project ...
|
|
XAiProjectDto project = null;
|
|
if (projectId.IsNull() ||
|
|
projectId.IsDefaultGuid()
|
|
)
|
|
{
|
|
//
|
|
project = await GetDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
project = await projectRepositoryService.GetAsync(
|
|
id: project.Id,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
// fillConversations: false,
|
|
// fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
if (project.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
// Check Default Owner Exists or not ...
|
|
var resource = await stringProvider.FindOne(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x =>
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToNormalString()) &&
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier
|
|
.ToNormalString()) &&
|
|
x.TranslatedValue
|
|
.ToNormalString()
|
|
.Contains(XAiDataProviderConstants.XDefaultAiConversationSuffix)
|
|
);
|
|
result = !resource.IsNullOrDefault();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = !(await conversationRepositoryService.FindOneAsync(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x =>
|
|
x.ProjectId == projectId &&
|
|
x.Title == resource.ResourceTitle
|
|
))
|
|
.IsNullOrDefault();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check Default Conversation Exists or not ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
private async Task CreateDefaultConversation(
|
|
string ownerId,
|
|
Guid projectId,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
var isValid = !ownerId.IsNullOrEmpty();
|
|
if (!isValid)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
var defaultLang = appConfiguration.DefaultLanguage;
|
|
|
|
//
|
|
// Prepare Project ...
|
|
XAiProjectDto project = null;
|
|
if (projectId.IsNull() ||
|
|
projectId.IsDefaultGuid()
|
|
)
|
|
{
|
|
//
|
|
project = await GetDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
project = await projectRepositoryService.GetAsync(
|
|
id: project.Id,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
// fillConversations: false,
|
|
// fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
if (project.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
// Check Default Owner Exists or not ...
|
|
isValid = await HasDefaultConversation(
|
|
ownerId: ownerId,
|
|
projectId: project.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (isValid)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Create Default Conversation ...
|
|
var item = new XAiConversationDto
|
|
{
|
|
OwnerId = ownerId,
|
|
ProjectId = project.Id,
|
|
CreatedOn = DateTime.UtcNow,
|
|
Title = Guid.NewGuid().ToString()
|
|
};
|
|
item = await conversationRepositoryService.AddAsync(
|
|
item: item,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Prepare Title Resource Ids ...
|
|
var titleResource = await conversationTitleResourceProvider.AddOrUpdateLocale(
|
|
owner: ownerId,
|
|
identifier: item.Id,
|
|
locale: new XLocaleResourceDto
|
|
{
|
|
Language = defaultLang,
|
|
Value = XAiDataProviderConstants.XDefaultAiConversationSuffix
|
|
},
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (titleResource.IsNullOrDefault())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Update Conversation Resources ...
|
|
item.Title = titleResource.Resource;
|
|
item = await conversationRepositoryService.UpdateAsync(
|
|
item: item,
|
|
id: item.Id,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Sending Push ...
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await SendPush(
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken,
|
|
payLoad: item.ToJSON(camelCase: true),
|
|
action: XAiDataProviderHubActions.ConversationCreated.GetStringValue()
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve Default Conversation of Specified Owner ...
|
|
/// Create it if not Handled ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
private async Task<XAiConversationDto> GetDefaultConversation(
|
|
string ownerId,
|
|
Guid projectId,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (ownerId.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Prepare Project ...
|
|
XAiProjectDto project = null;
|
|
if (projectId.IsNull() ||
|
|
projectId.IsDefaultGuid()
|
|
)
|
|
{
|
|
//
|
|
project = await GetDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
project = await projectRepositoryService.GetAsync(
|
|
id: project.Id,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
// fillConversations: false,
|
|
// fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
if (project.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
// Check Default Conversation Exists or noit ...
|
|
var isExists = await HasDefaultConversation(
|
|
ownerId: ownerId,
|
|
projectId: project.Id,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!isExists)
|
|
{
|
|
//
|
|
await CreateDefaultConversation(
|
|
ownerId: ownerId,
|
|
projectId: project.Id,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Detect Conversation Resource ...
|
|
var resource = await stringProvider.FindOne(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x =>
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToNormalString()) &&
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.XAiProjectTitleIdentifier
|
|
.ToNormalString()) &&
|
|
x.TranslatedValue
|
|
.ToNormalString()
|
|
.Contains(XAiDataProviderConstants.XDefaultAiProjectSuffix)
|
|
);
|
|
if (resource.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
// Find Default Conversation ...
|
|
var result = await conversationRepositoryService.FindOneAsync(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x => x.Title
|
|
.Equals(
|
|
resource.ResourceTitle,
|
|
StringComparison.InvariantCultureIgnoreCase
|
|
) &&
|
|
x.ProjectId == project.Id
|
|
);
|
|
if (result.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Normalize and Validate Language ...
|
|
/// </summary>
|
|
/// <param name="language"></param>
|
|
/// <returns></returns>
|
|
private string NormalizeAndValidateLanguage(string language)
|
|
{
|
|
//
|
|
if (language.IsNullOrEmpty())
|
|
{
|
|
language = appConfiguration.DefaultLanguage;
|
|
}
|
|
|
|
//
|
|
if (language.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
return language;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Send Custom Push Message ...
|
|
/// </summary>
|
|
/// <param name="action"></param>
|
|
/// <param name="payLoad"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task SendPush(
|
|
string action,
|
|
string payLoad,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
try
|
|
{
|
|
//
|
|
// Collect Allowed Actions ...
|
|
var actions = new List<string>
|
|
{
|
|
XAiDataProviderHubActions.ProjectCreated.GetStringValue(),
|
|
XAiDataProviderHubActions.ProjectUpdated.GetStringValue(),
|
|
XAiDataProviderHubActions.ProjectRemoved.GetStringValue(),
|
|
XAiDataProviderHubActions.MessageCreated.GetStringValue(),
|
|
XAiDataProviderHubActions.MessageUpdated.GetStringValue(),
|
|
XAiDataProviderHubActions.MessageRemoved.GetStringValue(),
|
|
XAiDataProviderHubActions.ConversationCreated.GetStringValue(),
|
|
XAiDataProviderHubActions.ConversationUpdated.GetStringValue(),
|
|
XAiDataProviderHubActions.ConversationRemoved.GetStringValue(),
|
|
};
|
|
|
|
//
|
|
// Validate Args ...
|
|
var isValid =
|
|
!action.IsNullOrEmpty() &&
|
|
actions.Contains(action);
|
|
if (!isValid)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Retrieve Connection Id ...
|
|
var clients = hub.Clients.All;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
clients = hub.Clients.AllExcept(connectionId);
|
|
}
|
|
|
|
//
|
|
await clients.SendAsync(
|
|
action,
|
|
payLoad,
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
catch { }
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\XAiMessageEntityRegisterar.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using xAiModels.Configurations.Entities;
|
|
|
|
namespace xAiModels.Providers
|
|
{
|
|
public class XAiMessageEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
|
|
{
|
|
public XAiMessageEntityRegisterar()
|
|
: base(nameof(XAiMessageEntityRegisterar))
|
|
{
|
|
//
|
|
// Add Entity ...
|
|
AddEntity<XAiMessage, Guid>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure Entities ...
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
|
{
|
|
//
|
|
// Configure Entity Using Provided ...
|
|
modelBuilder
|
|
.ApplyConfigurationsFromAssembly(typeof(XAiMessageEntityConfiguration).Assembly);
|
|
|
|
//
|
|
base.ConfigureEntities(modelBuilder);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\XAiProjectDescriptionResourceProvider.cs
|
|
|
|
using xAiModels.Constants;
|
|
using xAiModels.Interfaces;
|
|
using xCommons.Configurations;
|
|
using xStringService.Providers;
|
|
using xStringService.Interfaces.Dtos;
|
|
|
|
namespace xAiModels.Providers
|
|
{
|
|
public class XAiProjectDescriptionResourceProvider : XBaseOwnedItemResourceProvider, IXAiProjectDescriptionResourceProvider
|
|
{
|
|
public XAiProjectDescriptionResourceProvider(
|
|
XAppConfiguration appConfig,
|
|
IXStringServiceProvider stringProvider
|
|
) : base(
|
|
appConfig: appConfig,
|
|
stringProvider: stringProvider,
|
|
item: XAiModelsConstants.XAiProjectDescriptionIdentifier
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\XAiProjectEntityRegisterar.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using xAiModels.Configurations.Entities;
|
|
|
|
namespace xAiModels.Providers
|
|
{
|
|
public class XAiProjectEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
|
|
{
|
|
public XAiProjectEntityRegisterar()
|
|
: base(nameof(XAiProjectEntityRegisterar))
|
|
{
|
|
//
|
|
// Add Entity ...
|
|
AddEntity<XAiProject, Guid>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure Entities ...
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
|
{
|
|
//
|
|
// Configure Entity Using Provided ...
|
|
modelBuilder
|
|
.ApplyConfigurationsFromAssembly(typeof(XAiProjectEntityConfiguration).Assembly);
|
|
|
|
//
|
|
base.ConfigureEntities(modelBuilder);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\XAiProjectTitleResourceProvider.cs
|
|
|
|
using xAiModels.Constants;
|
|
using xAiModels.Interfaces;
|
|
using xCommons.Configurations;
|
|
using xStringService.Providers;
|
|
using xStringService.Interfaces.Dtos;
|
|
|
|
namespace xAiModels.Providers
|
|
{
|
|
public class XAiProjectTitleResourceProvider : XBaseOwnedItemResourceProvider, IXAiProjectTitleResourceProvider
|
|
{
|
|
public XAiProjectTitleResourceProvider(
|
|
XAppConfiguration appConfig,
|
|
IXStringServiceProvider stringProvider
|
|
) : base(
|
|
appConfig: appConfig,
|
|
stringProvider: stringProvider,
|
|
item: XAiModelsConstants.XAiProjectTitleIdentifier
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiConversationDtoHub.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiConversationDtoHub : XBaseDtoHub<XAiConversation, XAiConversationDto, Guid>, IXAiConversationDtoHub
|
|
{
|
|
public XAiConversationDtoHub(
|
|
ILogger<XAiConversationDtoHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiConversationRepositoryService.cs
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using xModels.Dtos;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Interfaces;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xDataService.Providers;
|
|
using xAiModels.Configurations;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using xIdentityService.Extensions;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiConversationRepositoryService : XBaseRepositoryService<XAiConversation, XAiConversationDto, Guid>, IXAiConversationRepositoryService
|
|
{
|
|
private readonly IXIdentityProvider identityProvider;
|
|
private readonly IXAiConversationRepository repository;
|
|
private readonly IXAiProjectTitleResourceProvider projectTitleResourceProvider;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
|
|
|
public XAiConversationRepositoryService(
|
|
IXIdentityProvider identityProvider,
|
|
IXAiConversationRepository repository,
|
|
IXAiProjectTitleResourceProvider projectTitleResourceProvider,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider,
|
|
IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider
|
|
) : base(
|
|
repository,
|
|
mapperProfiles:
|
|
[
|
|
new XAiModelMappersProfile()
|
|
]
|
|
)
|
|
{
|
|
this.repository = repository;
|
|
this.identityProvider = identityProvider;
|
|
this.projectTitleResourceProvider = projectTitleResourceProvider;
|
|
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
|
this.projectDescriptionResourceProvider = projectDescriptionResourceProvider;
|
|
}
|
|
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiConversationDto> Enrich(
|
|
XAiConversation source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Mapping Default ...
|
|
var result = Mapper.Map<XAiConversationDto>(source);
|
|
result = await Enrich(
|
|
source: result,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiConversationDto> Enrich(
|
|
XAiConversationDto source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Handdle Owner ...
|
|
XPersonDto owner = null;
|
|
if (!source.OwnerId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
// Try to Retrieve User Info ...
|
|
var device = identityProvider.GetDevice();
|
|
var userInfo = await identityProvider.GetUserInfo(
|
|
device: device,
|
|
userSelectByParam: source.OwnerId
|
|
);
|
|
owner = userInfo.ToXPersonDto();
|
|
}
|
|
|
|
//
|
|
// Handle Title Resource ...
|
|
XResourceDto titleResource = null;
|
|
if (!source.Title.IsNullOrEmpty())
|
|
{
|
|
//
|
|
titleResource = await conversationTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Handle Project Info ...
|
|
XResourceDto projectTitleResource = null;
|
|
XResourceDto projectDescriptionResource = null;
|
|
if (!source.ProjectId.IsDefaultGuid())
|
|
{
|
|
//
|
|
projectTitleResource = await projectTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.ProjectId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
projectDescriptionResource = await projectDescriptionResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.ProjectId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Attach Extracted Items ...
|
|
var result = Mapper.Map<XAiConversationDto>(source, options =>
|
|
{
|
|
//
|
|
options.Items[nameof(source.Owner)] = owner;
|
|
options.Items[nameof(source.TitleResource)] = titleResource;
|
|
options.Items[nameof(source.ProjectTitleResource)] = projectTitleResource;
|
|
options.Items[nameof(source.ProjectDescriptionResource)] = projectDescriptionResource;
|
|
});
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversation> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversationDto> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiConversationServiceProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiConversationServiceProvider : XBaseDtoProvider<XAiConversation, XAiConversationDto, Guid, XAiConversationDtoHub>, IXAiConversationServiceProvider
|
|
{
|
|
public XAiConversationServiceProvider(
|
|
IHubContext<XAiConversationDtoHub> hub,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXAiConversationRepositoryService service,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
dataConfiguration,
|
|
service,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiMessageDtoHub.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiMessageDtoHub : XBaseDtoHub<XAiMessage, XAiMessageDto, Guid>, IXAiMessageDtoHub
|
|
{
|
|
public XAiMessageDtoHub(
|
|
ILogger<XAiMessageDtoHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiMessageRepositoryService.cs
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using xModels.Dtos;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Interfaces;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xDataService.Providers;
|
|
using xAiModels.Configurations;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using xIdentityService.Extensions;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiMessageRepositoryService : XBaseRepositoryService<XAiMessage, XAiMessageDto, Guid>, IXAiMessageRepositoryService
|
|
{
|
|
private readonly IXIdentityProvider identityProvider;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
|
|
public XAiMessageRepositoryService(
|
|
IXAiMessageRepository repository,
|
|
IXIdentityProvider identityProvider,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider
|
|
) : base(
|
|
repository,
|
|
mapperProfiles:
|
|
[
|
|
new XAiModelMappersProfile()
|
|
]
|
|
)
|
|
{
|
|
this.identityProvider = identityProvider;
|
|
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
|
}
|
|
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiMessageDto> Enrich(
|
|
XAiMessage source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Mapping Default ...
|
|
var result = Mapper.Map<XAiMessageDto>(source);
|
|
result = await Enrich(
|
|
source: result,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiMessageDto> Enrich(
|
|
XAiMessageDto source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Handdle Owner ...
|
|
XPersonDto owner = null;
|
|
if (!source.OwnerId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
// Try to Retrieve User Info ...
|
|
var device = identityProvider.GetDevice();
|
|
var userInfo = await identityProvider.GetUserInfo(
|
|
device: device,
|
|
userSelectByParam: source.OwnerId
|
|
);
|
|
owner = userInfo.ToXPersonDto();
|
|
}
|
|
|
|
//
|
|
// Hanlde Conversation Title ...
|
|
string conversationTitle = string.Empty;
|
|
XResourceDto conversationTitleResource = null;
|
|
if (!source.ConversationId.IsDefaultGuid())
|
|
{
|
|
//
|
|
conversationTitleResource = await conversationTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.ConversationId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!conversationTitleResource.IsNullOrDefault())
|
|
{
|
|
conversationTitle = conversationTitleResource.Resource;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Attach Extracted Items ...
|
|
var result = Mapper.Map<XAiMessageDto>(source, options =>
|
|
{
|
|
//
|
|
options.Items[nameof(source.Owner)] = owner;
|
|
options.Items[nameof(source.ConversationTitle)] = conversationTitle;
|
|
options.Items[nameof(source.ConversationTitleResouce)] = conversationTitleResource;
|
|
});
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessage> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(x, cancellationToken));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessageDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(x, cancellationToken));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiMessageServiceProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiMessageServiceProvider : XBaseDtoProvider<XAiMessage, XAiMessageDto, Guid, XAiMessageDtoHub>, IXAiMessageServiceProvider
|
|
{
|
|
public XAiMessageServiceProvider(
|
|
IHubContext<XAiMessageDtoHub> hub,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXAiMessageRepositoryService service,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
dataConfiguration,
|
|
service,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiProjectDtoHub.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiProjectDtoHub : XBaseDtoHub<XAiProject, XAiProjectDto, Guid>, IXAiProjectDtoHub
|
|
{
|
|
public XAiProjectDtoHub(
|
|
ILogger<XAiProjectDtoHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiProjectRepositoryService.cs
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using xModels.Dtos;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Interfaces;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xDataService.Providers;
|
|
using xAiModels.Configurations;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using xIdentityService.Extensions;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiProjectRepositoryService : XBaseRepositoryService<XAiProject, XAiProjectDto, Guid>, IXAiProjectRepositoryService
|
|
{
|
|
private readonly IXIdentityProvider identityProvider;
|
|
private readonly IXAiMessageRepository messageRepository;
|
|
private readonly IXAiConversationRepository conversationRepository;
|
|
private readonly IXAiProjectTitleResourceProvider projectTitleResourceProvider;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
|
|
|
public XAiProjectRepositoryService(
|
|
IXAiProjectRepository repository,
|
|
IXIdentityProvider identityProvider,
|
|
IXAiMessageRepository messageRepository,
|
|
IXAiConversationRepository conversationRepository,
|
|
IXAiProjectTitleResourceProvider projectTitleResourceProvider,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider,
|
|
IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider
|
|
) : base(
|
|
repository,
|
|
mapperProfiles:
|
|
[
|
|
new XAiModelMappersProfile()
|
|
]
|
|
)
|
|
{
|
|
//
|
|
this.identityProvider = identityProvider;
|
|
this.messageRepository = messageRepository;
|
|
this.conversationRepository = conversationRepository;
|
|
this.projectTitleResourceProvider = projectTitleResourceProvider;
|
|
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
|
this.projectDescriptionResourceProvider = projectDescriptionResourceProvider;
|
|
}
|
|
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> Enrich(
|
|
XAiProject source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Mapping Default ...
|
|
var result = Mapper.Map<XAiProjectDto>(source);
|
|
result = await Enrich(
|
|
source: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> Enrich(
|
|
XAiProjectDto source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Handle Owner ...
|
|
XPersonDto owner = null;
|
|
if (!source.OwnerId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
// Try to Retrieve User Info ...
|
|
var device = identityProvider.GetDevice();
|
|
var userInfo = await identityProvider.GetUserInfo(
|
|
device: device,
|
|
userSelectByParam: source.OwnerId
|
|
);
|
|
owner = userInfo.ToXPersonDto();
|
|
}
|
|
|
|
//
|
|
// Handle Title ...
|
|
XResourceDto titleResource = null;
|
|
if (!source.Title.IsNullOrEmpty())
|
|
{
|
|
//
|
|
titleResource = await projectTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Handle Description ...
|
|
XResourceDto descriptionResource = null;
|
|
if (!source.Description.IsNullOrEmpty())
|
|
{
|
|
//
|
|
descriptionResource = await projectDescriptionResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Handle Conversations ...
|
|
IEnumerable<XAiConversationDto> conversations = [];
|
|
if (fillConversations)
|
|
{
|
|
//
|
|
// Reading Entities ...
|
|
var entitiies = await conversationRepository.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
predicate: x => x.ProjectId == source.Id,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
|
|
//
|
|
// Converts to Dto Enumerable ...
|
|
conversations = entitiies
|
|
.MapConvert<XAiConversationDto, XAiConversation>();
|
|
|
|
//
|
|
// Handle Conversation Enrichment ...
|
|
foreach (var conversation in conversations)
|
|
{
|
|
//
|
|
// Handle Owner ...
|
|
if (!conversation.OwnerId.IsNullOrEmpty())
|
|
{
|
|
conversation.Owner = owner;
|
|
}
|
|
|
|
//
|
|
// Handle Title Resource ...
|
|
if (!conversation.Title.IsNullOrEmpty())
|
|
{
|
|
//
|
|
conversation.TitleResource = await conversationTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: conversation.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Handle Project Info ...
|
|
if (!conversation.ProjectId.IsDefaultGuid())
|
|
{
|
|
conversation.ProjectTitle = source.Title;
|
|
conversation.ProjectTitleResource = titleResource;
|
|
conversation.ProjectDescription = source.Description;
|
|
conversation.ProjectDescriptionResource = descriptionResource;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Handle Fill Messages ...
|
|
if (fillConversationMessages)
|
|
{
|
|
//
|
|
foreach (var conversation in conversations)
|
|
{
|
|
//
|
|
IEnumerable<XAiMessageDto> messages = [];
|
|
|
|
//
|
|
// Retrieve Message Entities ...
|
|
var messageEntities = await messageRepository.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn),
|
|
predicate: x => x.ConversationId == conversation.Id
|
|
);
|
|
if (messageEntities.HasChild())
|
|
{
|
|
//
|
|
// Converts to Message ...
|
|
messages = messageEntities
|
|
.MapConvert<XAiMessageDto, XAiMessage>();
|
|
|
|
//
|
|
// Ennrich Messages ...
|
|
foreach (var message in messages)
|
|
{
|
|
//
|
|
// Handle Owner ...
|
|
if (!message.OwnerId.IsNullOrEmpty())
|
|
{
|
|
message.Owner = owner;
|
|
}
|
|
|
|
//
|
|
// Handle Conversation ...
|
|
if (!message.ConversationId.IsDefaultGuid())
|
|
{
|
|
message.ConversationTitle = conversation.Title;
|
|
message.ConversationTitleResouce = conversation.TitleResource;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
conversation.Messages = [.. messages];
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Attach Extracted Items ...
|
|
var result = Mapper.Map<XAiProjectDto>(source, options =>
|
|
{
|
|
//
|
|
options.Items[nameof(source.Owner)] = owner;
|
|
options.Items[nameof(source.Conversations)] = conversations;
|
|
options.Items[nameof(source.TitleResource)] = titleResource;
|
|
options.Items[nameof(source.DescriptionResource)] = descriptionResource;
|
|
});
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProject> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
cancellationToken: cancellationToken,
|
|
fillConversations: fillConversations,
|
|
fillConversationMessages: fillConversationMessages
|
|
));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProjectDto> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
cancellationToken: cancellationToken,
|
|
fillConversations: fillConversations,
|
|
fillConversationMessages: fillConversationMessages
|
|
));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiProjectServiceProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiProjectServiceProvider : XBaseDtoProvider<XAiProject, XAiProjectDto, Guid, XAiProjectDtoHub>, IXAiProjectServiceProvider
|
|
{
|
|
public XAiProjectServiceProvider(
|
|
IHubContext<XAiProjectDtoHub> hub,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXAiProjectRepositoryService service,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
dataConfiguration,
|
|
service,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Enrichers\XAiConversationEnricher.cs
|
|
|
|
using System.Linq;
|
|
using xModels.Dtos;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Interfaces;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using xIdentityService.Extensions;
|
|
using xAiModels.Interfaces.Entities;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
|
|
namespace xAiModels.Providers.Enrichers
|
|
{
|
|
public class XAiConversationEnricher : IXAiConversationEnricher
|
|
{
|
|
private readonly IXIdentityProvider identityProvider;
|
|
private readonly IXAiConversationRepository repository;
|
|
private readonly IXAiProjectTitleResourceProvider projectTitleResourceProvider;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
|
|
|
public XAiConversationEnricher(
|
|
IXIdentityProvider identityProvider,
|
|
IXAiConversationRepository repository,
|
|
IXAiProjectTitleResourceProvider projectTitleResourceProvider,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider,
|
|
IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider
|
|
)
|
|
{
|
|
//
|
|
this.repository = repository;
|
|
this.identityProvider = identityProvider;
|
|
this.projectTitleResourceProvider = projectTitleResourceProvider;
|
|
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
|
this.projectDescriptionResourceProvider = projectDescriptionResourceProvider;
|
|
}
|
|
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiConversationDto> Enrich(
|
|
XAiConversation source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Mapping Default ...
|
|
var result = source.MapConvert<XAiConversationDto, XAiConversation>();
|
|
result = await Enrich(
|
|
source: result,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiConversationDto> Enrich(
|
|
XAiConversationDto source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Handdle Owner ...
|
|
XPersonDto owner = null;
|
|
if (!source.OwnerId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
// Try to Retrieve User Info ...
|
|
var device = identityProvider.GetDevice();
|
|
var userInfo = await identityProvider.GetUserInfo(
|
|
device: device,
|
|
userSelectByParam: source.OwnerId
|
|
);
|
|
owner = userInfo.ToXPersonDto();
|
|
}
|
|
|
|
//
|
|
// Handle Title Resource ...
|
|
XResourceDto titleResource = null;
|
|
if (!source.Title.IsNullOrEmpty())
|
|
{
|
|
//
|
|
titleResource = await conversationTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Handle Project Info ...
|
|
XResourceDto projectTitleResource = null;
|
|
XResourceDto projectDescriptionResource = null;
|
|
if (!source.ProjectId.IsDefaultGuid())
|
|
{
|
|
//
|
|
projectTitleResource = await projectTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.ProjectId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
projectDescriptionResource = await projectDescriptionResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.ProjectId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Attach Extracted Items ...
|
|
var result = source.MapConvert<XAiConversationDto, XAiConversationDto>();
|
|
result.Owner = owner;
|
|
result.TitleResource = titleResource;
|
|
result.ProjectTitleResource = projectTitleResource;
|
|
result.ProjectDescriptionResource = projectDescriptionResource;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversation> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversationDto> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Enrichers\XAiMessageEnricher.cs
|
|
|
|
using System.Linq;
|
|
using xModels.Dtos;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Interfaces;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using xIdentityService.Extensions;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
|
|
namespace xAiModels.Providers.Enrichers
|
|
{
|
|
public class XAiMessageEnricher : IXAiMessageEnricher
|
|
{
|
|
private readonly IXIdentityProvider identityProvider;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
|
|
public XAiMessageEnricher(
|
|
IXIdentityProvider identityProvider,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider
|
|
)
|
|
{
|
|
this.identityProvider = identityProvider;
|
|
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
|
}
|
|
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiMessageDto> Enrich(
|
|
XAiMessage source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Mapping Default ...
|
|
var result = source.MapConvert<XAiMessageDto, XAiMessage>();
|
|
result = await Enrich(
|
|
source: result,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiMessageDto> Enrich(
|
|
XAiMessageDto source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Handdle Owner ...
|
|
XPersonDto owner = null;
|
|
if (!source.OwnerId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
// Try to Retrieve User Info ...
|
|
var device = identityProvider.GetDevice();
|
|
var userInfo = await identityProvider.GetUserInfo(
|
|
device: device,
|
|
userSelectByParam: source.OwnerId
|
|
);
|
|
owner = userInfo.ToXPersonDto();
|
|
}
|
|
|
|
//
|
|
// Hanlde Conversation Title ...
|
|
string conversationTitle = string.Empty;
|
|
XResourceDto conversationTitleResource = null;
|
|
if (!source.ConversationId.IsDefaultGuid())
|
|
{
|
|
//
|
|
conversationTitleResource = await conversationTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.ConversationId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!conversationTitleResource.IsNullOrDefault())
|
|
{
|
|
conversationTitle = conversationTitleResource.Resource;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Attach Extracted Items ...
|
|
var result = source.MapConvert<XAiMessageDto, XAiMessageDto>();
|
|
result.Owner = owner;
|
|
result.ConversationTitle = conversationTitle;
|
|
result.ConversationTitleResouce = conversationTitleResource;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessage> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(x, cancellationToken));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessageDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(x, cancellationToken));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Enrichers\XAiProjectEnricher.cs
|
|
|
|
using System.Linq;
|
|
using xModels.Dtos;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Interfaces;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using xIdentityService.Extensions;
|
|
using xAiModels.Interfaces.Entities;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
|
|
namespace xAiModels.Providers.Enrichers
|
|
{
|
|
public class XAiProjectEnricher : IXAiProjectEnricher
|
|
{
|
|
private readonly IXIdentityProvider identityProvider;
|
|
private readonly IXAiMessageRepository messageRepository;
|
|
private readonly IXAiConversationRepository conversationRepository;
|
|
private readonly IXAiProjectTitleResourceProvider projectTitleResourceProvider;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
|
|
|
public XAiProjectEnricher(
|
|
IXIdentityProvider identityProvider,
|
|
IXAiMessageRepository messageRepository,
|
|
IXAiConversationRepository conversationRepository,
|
|
IXAiProjectTitleResourceProvider projectTitleResourceProvider,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider,
|
|
IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider
|
|
)
|
|
{
|
|
//
|
|
this.identityProvider = identityProvider;
|
|
this.messageRepository = messageRepository;
|
|
this.conversationRepository = conversationRepository;
|
|
this.projectTitleResourceProvider = projectTitleResourceProvider;
|
|
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
|
this.projectDescriptionResourceProvider = projectDescriptionResourceProvider;
|
|
}
|
|
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> Enrich(
|
|
XAiProject source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Mapping Default ...
|
|
var result = source.MapConvert<XAiProjectDto, XAiProject>();
|
|
result = await Enrich(
|
|
source: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiProjectDto> Enrich(
|
|
XAiProjectDto source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Handle Owner ...
|
|
XPersonDto owner = null;
|
|
if (!source.OwnerId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
// Try to Retrieve User Info ...
|
|
var device = identityProvider.GetDevice();
|
|
var userInfo = await identityProvider.GetUserInfo(
|
|
device: device,
|
|
userSelectByParam: source.OwnerId
|
|
);
|
|
owner = userInfo.ToXPersonDto();
|
|
}
|
|
|
|
//
|
|
// Handle Title ...
|
|
XResourceDto titleResource = null;
|
|
if (!source.Title.IsNullOrEmpty())
|
|
{
|
|
//
|
|
titleResource = await projectTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Handle Description ...
|
|
XResourceDto descriptionResource = null;
|
|
if (!source.Description.IsNullOrEmpty())
|
|
{
|
|
//
|
|
descriptionResource = await projectDescriptionResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: source.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Handle Conversations ...
|
|
IEnumerable<XAiConversationDto> conversations = [];
|
|
if (fillConversations)
|
|
{
|
|
//
|
|
// Reading Entities ...
|
|
var entitiies = await conversationRepository.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
predicate: x => x.ProjectId == source.Id,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
|
|
//
|
|
// Converts to Dto Enumerable ...
|
|
conversations = entitiies
|
|
.MapConvert<XAiConversationDto, XAiConversation>();
|
|
|
|
//
|
|
// Handle Conversation Enrichment ...
|
|
foreach (var conversation in conversations)
|
|
{
|
|
//
|
|
// Handle Owner ...
|
|
if (!conversation.OwnerId.IsNullOrEmpty())
|
|
{
|
|
conversation.Owner = owner;
|
|
}
|
|
|
|
//
|
|
// Handle Title Resource ...
|
|
if (!conversation.Title.IsNullOrEmpty())
|
|
{
|
|
//
|
|
conversation.TitleResource = await conversationTitleResourceProvider.GetResource(
|
|
owner: source.OwnerId,
|
|
identifier: conversation.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Handle Project Info ...
|
|
if (!conversation.ProjectId.IsDefaultGuid())
|
|
{
|
|
conversation.ProjectTitle = source.Title;
|
|
conversation.ProjectTitleResource = titleResource;
|
|
conversation.ProjectDescription = source.Description;
|
|
conversation.ProjectDescriptionResource = descriptionResource;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Handle Fill Messages ...
|
|
if (fillConversationMessages)
|
|
{
|
|
//
|
|
foreach (var conversation in conversations)
|
|
{
|
|
//
|
|
IEnumerable<XAiMessageDto> messages = [];
|
|
|
|
//
|
|
// Retrieve Message Entities ...
|
|
var messageEntities = await messageRepository.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn),
|
|
predicate: x => x.ConversationId == conversation.Id
|
|
);
|
|
if (messageEntities.HasChild())
|
|
{
|
|
//
|
|
// Converts to Message ...
|
|
messages = messageEntities
|
|
.MapConvert<XAiMessageDto, XAiMessage>();
|
|
|
|
//
|
|
// Ennrich Messages ...
|
|
foreach (var message in messages)
|
|
{
|
|
//
|
|
// Handle Owner ...
|
|
if (!message.OwnerId.IsNullOrEmpty())
|
|
{
|
|
message.Owner = owner;
|
|
}
|
|
|
|
//
|
|
// Handle Conversation ...
|
|
if (!message.ConversationId.IsDefaultGuid())
|
|
{
|
|
message.ConversationTitle = conversation.Title;
|
|
message.ConversationTitleResouce = conversation.TitleResource;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
conversation.Messages = [.. messages];
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Attach Extracted Items ...
|
|
var result = source.MapConvert<XAiProjectDto, XAiProjectDto>();
|
|
result.Owner = owner;
|
|
result.TitleResource = titleResource;
|
|
result.Conversations = [.. conversations];
|
|
result.DescriptionResource = descriptionResource;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProject> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
cancellationToken: cancellationToken,
|
|
fillConversations: fillConversations,
|
|
fillConversationMessages: fillConversationMessages
|
|
));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProjectDto> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
cancellationToken: cancellationToken,
|
|
fillConversations: fillConversations,
|
|
fillConversationMessages: fillConversationMessages
|
|
));
|
|
|
|
//
|
|
var result = await Task.WhenAll(tasks);
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiConversationEFRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Db;
|
|
using xDataService.Providers;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiConversationEFRepository<TContext> : XBaseEFRepository<XAiConversation, Guid, TContext>, IXAiConversationRepository
|
|
where TContext : XDbContext
|
|
{
|
|
public XAiConversationEFRepository(
|
|
IXUnitOfWorks<TContext> unitOfWorks,
|
|
XDataServiceConfiguration configuration,
|
|
IXAiConversationKeyGenerator keyGenerator = null,
|
|
IXAiConversationRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
unitOfWorks,
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiConversationEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiConversationEntityHub : XBaseEntityHub<XAiConversation, Guid>, IXAiConversationEntityHub
|
|
{
|
|
public XAiConversationEntityHub(
|
|
ILogger<XAiConversationEntityHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiConversationInMemoryRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiConversationInMemoryRepository : XBaseInMemoryRepository<XAiConversation, Guid>, IXAiConversationRepository
|
|
{
|
|
public XAiConversationInMemoryRepository(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiConversationKeyGenerator keyGenerator = null,
|
|
IXAiConversationRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiConversationKeyGenerator.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiConversationKeyGenerator : XGuidKeyGenerator<XAiConversation>, IXAiConversationKeyGenerator
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiConversationMongoRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiConversationMongoRepository : XBaseMongoRepository<XAiConversation, Guid>, IXAiConversationRepository
|
|
{
|
|
public XAiConversationMongoRepository(
|
|
XDataBaseConfiguration dbConfiguration,
|
|
XDataServiceConfiguration configuration,
|
|
string collectionName = null,
|
|
IXAiConversationKeyGenerator keyGenerator = null,
|
|
IXAiConversationRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
dbConfiguration,
|
|
configuration,
|
|
collectionName,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiConversationRepositoryEvents.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiConversationRepositoryEvents : XBaseRepositoryEvents<XAiConversation>, IXAiConversationRepositoryEvents
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiConversationRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiConversationRepositoryProvider : XBaseEntityProvider<XAiConversation, Guid, XAiConversationEntityHub>, IXAiConversationRepositoryProvider
|
|
{
|
|
public XAiConversationRepositoryProvider(
|
|
IHubContext<XAiConversationEntityHub> hub,
|
|
IXAiConversationRepository repository,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
repository,
|
|
dataConfiguration,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiConversationSeederBase.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public abstract class XAiConversationSeederBase : XBaseDbSeeder<XAiConversation, Guid>, IXAiConversationSeeder
|
|
{
|
|
protected XAiConversationSeederBase(
|
|
string entity,
|
|
string database,
|
|
IXAiConversationRepository repository,
|
|
XDataServiceConfiguration dataServiceConfiguration
|
|
) : base(
|
|
entity,
|
|
database,
|
|
repository,
|
|
dataServiceConfiguration
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMessageEFRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Db;
|
|
using xDataService.Providers;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMessageEFRepository<TContext> : XBaseEFRepository<XAiMessage, Guid, TContext>, IXAiMessageRepository
|
|
where TContext : XDbContext
|
|
{
|
|
public XAiMessageEFRepository(
|
|
IXUnitOfWorks<TContext> unitOfWorks,
|
|
XDataServiceConfiguration configuration,
|
|
IXAiMessageKeyGenerator keyGenerator = null,
|
|
IXAiMessageRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
unitOfWorks,
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMessageEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMessageEntityHub : XBaseEntityHub<XAiMessage, Guid>, IXAiMessageEntityHub
|
|
{
|
|
public XAiMessageEntityHub(
|
|
ILogger<XAiMessageEntityHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMessageInMemoryRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMessageInMemoryRepository : XBaseInMemoryRepository<XAiMessage, Guid>, IXAiMessageRepository
|
|
{
|
|
public XAiMessageInMemoryRepository(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiMessageKeyGenerator keyGenerator = null,
|
|
IXAiMessageRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMessageKeyGenerator.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMessageKeyGenerator : XGuidKeyGenerator<XAiMessage>, IXAiMessageKeyGenerator
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMessageMongoRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMessageMongoRepository : XBaseMongoRepository<XAiMessage, Guid>, IXAiMessageRepository
|
|
{
|
|
public XAiMessageMongoRepository(
|
|
XDataBaseConfiguration dbConfiguration,
|
|
XDataServiceConfiguration configuration,
|
|
string collectionName = null,
|
|
IXAiMessageKeyGenerator keyGenerator = null,
|
|
IXAiMessageRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
dbConfiguration,
|
|
configuration,
|
|
collectionName,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMessageRepositoryEvents.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMessageRepositoryEvents : XBaseRepositoryEvents<XAiMessage>, IXAiMessageRepositoryEvents
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMessageRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMessageRepositoryProvider : XBaseEntityProvider<XAiMessage, Guid, XAiMessageEntityHub>, IXAiMessageRepositoryProvider
|
|
{
|
|
public XAiMessageRepositoryProvider(
|
|
IHubContext<XAiMessageEntityHub> hub,
|
|
IXAiMessageRepository repository,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
repository,
|
|
dataConfiguration,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMessageSeederBase.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public abstract class XAiMessageSeederBase : XBaseDbSeeder<XAiMessage, Guid>, IXAiMessageSeeder
|
|
{
|
|
protected XAiMessageSeederBase(
|
|
string entity,
|
|
string database,
|
|
IXAiMessageRepository repository,
|
|
XDataServiceConfiguration dataServiceConfiguration
|
|
) : base(
|
|
entity,
|
|
database,
|
|
repository,
|
|
dataServiceConfiguration
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiProjectEFRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Db;
|
|
using xDataService.Providers;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiProjectEFRepository<TContext> : XBaseEFRepository<XAiProject, Guid, TContext>, IXAiProjectRepository
|
|
where TContext : XDbContext
|
|
{
|
|
public XAiProjectEFRepository(
|
|
IXUnitOfWorks<TContext> unitOfWorks,
|
|
XDataServiceConfiguration configuration,
|
|
IXAiProjectKeyGenerator keyGenerator = null,
|
|
IXAiProjectRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
unitOfWorks,
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiProjectEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiProjectEntityHub : XBaseEntityHub<XAiProject, Guid>, IXAiProjectEntityHub
|
|
{
|
|
public XAiProjectEntityHub(
|
|
ILogger<XAiProjectEntityHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiProjectInMemoryRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiProjectInMemoryRepository : XBaseInMemoryRepository<XAiProject, Guid>, IXAiProjectRepository
|
|
{
|
|
public XAiProjectInMemoryRepository(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiProjectKeyGenerator keyGenerator = null,
|
|
IXAiProjectRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiProjectKeyGenerator.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiProjectKeyGenerator : XGuidKeyGenerator<XAiProject>, IXAiProjectKeyGenerator
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiProjectMongoRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiProjectMongoRepository : XBaseMongoRepository<XAiProject, Guid>, IXAiProjectRepository
|
|
{
|
|
public XAiProjectMongoRepository(
|
|
XDataBaseConfiguration dbConfiguration,
|
|
XDataServiceConfiguration configuration,
|
|
string collectionName = null,
|
|
IXAiProjectKeyGenerator keyGenerator = null,
|
|
IXAiProjectRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
dbConfiguration,
|
|
configuration,
|
|
collectionName,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiProjectRepositoryEvents.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiProjectRepositoryEvents : XBaseRepositoryEvents<XAiProject>, IXAiProjectRepositoryEvents
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiProjectRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xIdentityService.Interfaces;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiProjectRepositoryProvider : XBaseEntityProvider<XAiProject, Guid, XAiProjectEntityHub>, IXAiProjectRepositoryProvider
|
|
{
|
|
public XAiProjectRepositoryProvider(
|
|
IHubContext<XAiProjectEntityHub> hub,
|
|
IXAiProjectRepository repository,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
repository,
|
|
dataConfiguration,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiProjectSeederBase.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public abstract class XAiProjectSeederBase : XBaseDbSeeder<XAiProject, Guid>, IXAiProjectSeeder
|
|
{
|
|
protected XAiProjectSeederBase(
|
|
string entity,
|
|
string database,
|
|
IXAiProjectRepository repository,
|
|
XDataServiceConfiguration dataServiceConfiguration
|
|
) : base(
|
|
entity,
|
|
database,
|
|
repository,
|
|
dataServiceConfiguration
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiConversationGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiConversationGraphQLTypeHelper : XBaseGraphQLTypeHelper<XAiConversation, Guid>, IXAiConversationGraphQLTypeHelper
|
|
{
|
|
public override string GetInQueryCollectionName()
|
|
{
|
|
return XAiModelsConstants.XAiConversationCollectionName;
|
|
}
|
|
|
|
public override string GetInQuerySingleName()
|
|
{
|
|
return XAiModelsConstants.XAiConversationSignleName;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiConversationGraphQuery.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiConversationGraphQuery : XBaseGraphQLQuery<XAiConversation, Guid, XAiConversationGraphType, GuidGraphType>
|
|
{
|
|
public XAiConversationGraphQuery(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiConversationRepository repository,
|
|
IXAiConversationGraphQLTypeHelper helper
|
|
) : base(
|
|
configuration,
|
|
repository,
|
|
helper
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiConversationGraphSchema.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiConversationGraphSchema : Schema
|
|
{
|
|
public XAiConversationGraphSchema(IServiceProvider services) : base(services)
|
|
{
|
|
Query = (XAiConversationGraphQuery)services.GetService(typeof(XAiConversationGraphQuery));
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiConversationGraphType.cs
|
|
|
|
using System;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiConversationGraphType : XBaseGraphObjectType<XAiConversation, Guid>
|
|
{
|
|
public XAiConversationGraphType() : base()
|
|
{
|
|
Field(x => x.Title);
|
|
Field(x => x.OwnerId);
|
|
Field(x => x.CreatedOn);
|
|
Field(x => x.UpdatedAt);
|
|
Field(x => x.ProjectId);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiMessageGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiMessageGraphQLTypeHelper : XBaseGraphQLTypeHelper<XAiMessage, Guid>, IXAiMessageGraphQLTypeHelper
|
|
{
|
|
public override string GetInQueryCollectionName()
|
|
{
|
|
return XAiModelsConstants.XAiMessageCollectionName;
|
|
}
|
|
|
|
public override string GetInQuerySingleName()
|
|
{
|
|
return XAiModelsConstants.XAiMessageSingleName;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiMessageGraphQuery.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiMessageGraphQuery : XBaseGraphQLQuery<XAiMessage, Guid, XAiMessageGraphType, GuidGraphType>
|
|
{
|
|
public XAiMessageGraphQuery(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiMessageRepository repository,
|
|
IXAiMessageGraphQLTypeHelper helper
|
|
) : base(
|
|
configuration,
|
|
repository,
|
|
helper
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiMessageGraphSchema.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiMessageGraphSchema : Schema
|
|
{
|
|
public XAiMessageGraphSchema(IServiceProvider services) : base(services)
|
|
{
|
|
Query = (XAiMessageGraphQuery)services.GetService(typeof(XAiMessageGraphQuery));
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiMessageGraphType.cs
|
|
|
|
using System;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiMessageGraphType: XBaseGraphObjectType<XAiMessage, Guid>
|
|
{
|
|
public XAiMessageGraphType() : base()
|
|
{
|
|
Field(x => x.Role);
|
|
Field(x => x.OwnerId);
|
|
Field(x => x.Content);
|
|
Field(x => x.Metadata);
|
|
Field(x => x.CreatedOn);
|
|
Field(x => x.UpdatedAt);
|
|
Field(x => x.ConversationId);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiProjectGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiProjectGraphQLTypeHelper : XBaseGraphQLTypeHelper<XAiProject, Guid>, IXAiProjectGraphQLTypeHelper
|
|
{
|
|
public override string GetInQueryCollectionName()
|
|
{
|
|
return XAiModelsConstants.XAiProjectCollectionName;
|
|
}
|
|
|
|
public override string GetInQuerySingleName()
|
|
{
|
|
return XAiModelsConstants.XAiProjectSingleName;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiProjectGraphQuery.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiProjectGraphQuery : XBaseGraphQLQuery<XAiProject, Guid, XAiProjectGraphType, GuidGraphType>
|
|
{
|
|
public XAiProjectGraphQuery(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiProjectRepository repository,
|
|
IXAiProjectGraphQLTypeHelper helper
|
|
) : base(
|
|
configuration,
|
|
repository,
|
|
helper
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiProjectGraphSchema.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiProjectGraphSchema : Schema
|
|
{
|
|
public XAiProjectGraphSchema(IServiceProvider services) : base(services)
|
|
{
|
|
Query = (XAiProjectGraphQuery)services.GetService(typeof(XAiProjectGraphQuery));
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiProjectGraphType.cs
|
|
|
|
using System;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiProjectGraphType : XBaseGraphObjectType<XAiProject, Guid>
|
|
{
|
|
public XAiProjectGraphType() : base()
|
|
{
|
|
Field(x => x.Title);
|
|
Field(x => x.OwnerId);
|
|
Field(x => x.Prompt);
|
|
Field(x => x.CreatedOn);
|
|
Field(x => x.UpdatedAt);
|
|
Field(x => x.Description);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Hubs\XAiDataProviderHub.cs
|
|
|
|
using System.Threading;
|
|
using xPushService.Base;
|
|
using xAiModels.Constants;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace xAiModels.Providers.Hubs
|
|
{
|
|
public class XAiDataProviderHub : XBaseHub
|
|
{
|
|
public XAiDataProviderHub(
|
|
ILogger<XBaseHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
|
|
//
|
|
#region XAiProject ...
|
|
/// <summary>
|
|
/// Notify a New Item Created ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task ProjectCreated(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.ProjectCreated.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Notify an Item Removed ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task ProjectRemoved(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.ProjectRemoved.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Notify an Item Updated ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task ProjectUpdated(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.ProjectUpdated.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region XAiConversation ...
|
|
/// <summary>
|
|
/// Notify a New Item Created ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task ConversationCreated(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.ConversationCreated.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Notify an Item Removed ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task ConversationRemoved(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.ConversationRemoved.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Notify an Item Updated ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task ConversationUpdated(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.ConversationUpdated.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region XAiMessage ...
|
|
/// <summary>
|
|
/// Notify a New Item Created ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task MessageCreated(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.MessageCreated.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Notify an Item Removed ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task MessageRemoved(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.MessageRemoved.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Notify an Item Updated ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task MessageUpdated(
|
|
XAiProjectDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.MessageUpdated.GetStringValue(),
|
|
item.ToJSON(camelCase: true),
|
|
connectionId,
|
|
cancellationToken
|
|
);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|