12302 lines
392 KiB
Plaintext
12302 lines
392 KiB
Plaintext
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Attributes\XAiMcpToolAttribute.cs
|
|
|
|
using System;
|
|
|
|
namespace xAiModels.Attributes
|
|
{
|
|
/// <summary>
|
|
/// Decorate and Describe Specified MCP Tool to LLM ...
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
|
public class XAiMcpToolAttribute : Attribute
|
|
{
|
|
/// <summary>
|
|
/// Tools Unique Name (Default: Method Name) ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string Name { get; }
|
|
|
|
/// <summary>
|
|
/// Tools Description for LLM ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specify it's Required to Authenticated or not ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public bool RequiresAuthentication { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Authorization and Policiy ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string RequiredPolicy { get; set; } = string.Empty;
|
|
|
|
public XAiMcpToolAttribute(string name = null)
|
|
{
|
|
Name = name;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Attributes\XAiMcpToolParamAttribute.cs
|
|
|
|
using System;
|
|
|
|
namespace xAiModels.Attributes
|
|
{
|
|
/// <summary>
|
|
/// Describe Specific Tools Parameter Metadata ...
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
|
|
public sealed class XAiMcpToolParamAttribute : Attribute
|
|
{
|
|
/// <summary>
|
|
/// Parameter Name in JSON (Default Parameter Name) ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string Name { get; }
|
|
|
|
/// <summary>
|
|
/// Describe Parameter to LLM ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specified this Parameter is Required or not (Default is true) ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public bool Required { get; set; } = true;
|
|
|
|
public XAiMcpToolParamAttribute(string name = null)
|
|
{
|
|
Name = name;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Attributes\XAiMcpToolTypeAttribute.cs
|
|
|
|
using System;
|
|
|
|
namespace xAiModels.Attributes
|
|
{
|
|
/// <summary>
|
|
/// Decorate Tools Classes ...
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
|
public class XAiMcpToolTypeAttribute : Attribute { }
|
|
}
|
|
|
|
### 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>();
|
|
|
|
//
|
|
// XAiVector ...
|
|
CreateMap<XAiVector, XAiVectorDto>()
|
|
.ForMember(x => x.Embedding, opt => opt.Ignore())
|
|
.ForMember(x => x.Metadata, opt => opt.Ignore());
|
|
CreateMap<XAiVectorDto, XAiVector>()
|
|
.ForMember(x => x.Embedding, opt => opt.Ignore())
|
|
.ForMember(x => x.Metadata, opt => opt.Ignore());
|
|
|
|
//
|
|
// XAiProject ...
|
|
CreateMap<XAiProject, XAiProjectDto>();
|
|
|
|
//
|
|
CreateMap<XAiMcpServer, XAiMcpServerDto>();
|
|
CreateMap<XAiMcpServerDto, XAiMcpServer>();
|
|
|
|
//
|
|
// 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\XAiMcpServerEntityConfiguration .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 XAiMcpServerEntityConfiguration : XBaseEntityTypeConfiguration<XAiMcpServer, Guid>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<XAiMcpServer> builder)
|
|
{
|
|
builder.ToTable(XAiModelsConstants.XAiMcpServerTable);
|
|
}
|
|
}
|
|
}
|
|
|
|
### 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\Configurations\Entities\XAiVectorEntityConfiguration.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 XAiVectorEntityConfiguration : XBaseEntityTypeConfiguration<XAiVector, Guid>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<XAiVector> builder)
|
|
{
|
|
//
|
|
builder.ToTable(XAiModelsConstants.XAiVectorTable);
|
|
|
|
//
|
|
builder.Property(x => x.Type).HasMaxLength(100);
|
|
|
|
//
|
|
// Indexes for Prefix Scoped Search and Type Filtering ...
|
|
builder.HasIndex(x => x.Identifier);
|
|
builder.HasIndex(x => x.Type);
|
|
}
|
|
}
|
|
}
|
|
|
|
### 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,
|
|
|
|
//
|
|
// Message ...
|
|
[StringValue("MessageCreated")]
|
|
MessageCreated,
|
|
|
|
[StringValue("MessageUpdated")]
|
|
MessageUpdated,
|
|
|
|
[StringValue("MessageRemoved")]
|
|
MessageRemoved,
|
|
|
|
//
|
|
// MCPServer ...
|
|
[StringValue("McpServerCreated")]
|
|
McpServerCreated,
|
|
|
|
[StringValue("McpServerUpdated")]
|
|
McpServerUpdated,
|
|
|
|
[StringValue("McpServerRemoved")]
|
|
McpServerRemoved,
|
|
|
|
//
|
|
// Conversation ...
|
|
[StringValue("ConversationCreated")]
|
|
ConversationCreated,
|
|
|
|
[StringValue("ConversationUpdated")]
|
|
ConversationUpdated,
|
|
|
|
[StringValue("ConversationRemoved")]
|
|
ConversationRemoved,
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiKnowledgeScope.cs
|
|
|
|
using xExceptions.Attributes;
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
/// <summary>
|
|
/// Knowledge Base Scope (Where Ingested Vectors are Visible) ...
|
|
/// Identifier Layout: "{scopePrefix}/{scopeKey}/{fileName}#{chunkIndex}" (Global has no scopeKey) ...
|
|
/// </summary>
|
|
public enum XAiKnowledgeScope
|
|
{
|
|
/// <summary>
|
|
/// Visible only Inside a Conversation (Key = ConversationId) ...
|
|
/// </summary>
|
|
[StringValue(XAiModelsConstants.XAiKnowledgeConversationPrefix)]
|
|
Conversation = 0,
|
|
|
|
/// <summary>
|
|
/// Visible to all Conversations of a Project (Key = ProjectId) ...
|
|
/// </summary>
|
|
[StringValue(XAiModelsConstants.XAiKnowledgeProjectPrefix)]
|
|
Project = 1,
|
|
|
|
/// <summary>
|
|
/// Visible to Everyone (Write Requires Admin Role) ...
|
|
/// </summary>
|
|
[StringValue(XAiModelsConstants.XAiKnowledgeGlobalPrefix)]
|
|
Global = 2,
|
|
|
|
/// <summary>
|
|
/// Personal Knowledge Base of Owner (Key = UserId) ...
|
|
/// </summary>
|
|
[StringValue(XAiModelsConstants.XAiKnowledgeUserPrefix)]
|
|
User = 3,
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiMcpConstants.cs
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
public struct XAiMcpConstants
|
|
{
|
|
//
|
|
public const string XAiMcpProtocol = "2024-11-05";
|
|
public const string XAiMcpClientName = "XAiMcpClient";
|
|
public const string XAiMcpSessionIdentifier = "Mcp-Session-Id";
|
|
public const string XAiMcpProtocolIdentifier = "MCP-Protocol-Version";
|
|
|
|
//
|
|
public const string TextKey = "text";
|
|
public const string ContentKey = "content";
|
|
public const string ServerInfoNameKey = "name";
|
|
public const string ServerInfoKey = "serverInfo";
|
|
public const string ServerInfoVersionKey = "version";
|
|
public const string ProtocolVersionKey = "protocolVersion";
|
|
|
|
//
|
|
public const string serverInfoNameValue = "xAiApi";
|
|
public const string serverInfoVersionValue = "";
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiMcpMethods.cs
|
|
|
|
using xExceptions.Attributes;
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
public enum XAiMcpMethods
|
|
{
|
|
[StringValue("initialize")]
|
|
Initialize,
|
|
|
|
[StringValue("tools/list")]
|
|
ToolsList,
|
|
|
|
[StringValue("tools/call")]
|
|
ToolsCall,
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiMcpServerUsageScope.cs
|
|
|
|
using xExceptions.Attributes;
|
|
|
|
namespace xAiModels.Constants
|
|
{
|
|
public enum XAiMcpServerUsageScope
|
|
{
|
|
[StringValue(XAiModelsConstants.XAiMcpServerUsageScopeAll)]
|
|
All = 1,
|
|
|
|
[StringValue(XAiModelsConstants.XAiMcpServerUsageScopeOwner)]
|
|
Owner = 2
|
|
}
|
|
}
|
|
|
|
### 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 XAiVectorTable = "AiVectors";
|
|
public const string XAiMessageTable = "AiMessages";
|
|
public const string XAiProjectTable = "AiProjects";
|
|
public const string XAiMcpServerTable = "AiMcpServers";
|
|
public const string XAiConversationTable = "AiConversations";
|
|
|
|
//
|
|
// GraphQL Collection Mappings ...
|
|
public const string XAiMessageSingleName = "aiMessage";
|
|
public const string XAiProjectSingleName = "aiProject";
|
|
public const string XAiMcpServerSingleName = "aiMcpServer";
|
|
public const string XAiConversationSignleName = "aiConversation";
|
|
|
|
public const string XAiMessageCollectionName = "aiMessages";
|
|
public const string XAiProjectCollectionName = "AiProjectsa";
|
|
public const string XAiMcpServerCollectionName = "aiMcpServers";
|
|
public const string XAiConversationCollectionName = "aiConversations";
|
|
|
|
public const string XAiVectorSingleName = "aiVector";
|
|
public const string XAiVectorCollectionName = "aiVectors";
|
|
|
|
//
|
|
// Hubs ...
|
|
public const string XAiMessageDtoHub = "aiMessageDto";
|
|
public const string XAiMessageEntityHub = "aiMessageEntity";
|
|
|
|
public const string XAiProjectDtoHub = "aiProjectDto";
|
|
public const string XAiProjectEntityHub = "aiProjectEntity";
|
|
|
|
public const string XAiMcpServerDtoHub = "aiMcpServerDto";
|
|
public const string XAiMcpServerEntityHub = "aiMcpServerEntity";
|
|
|
|
public const string XAiConversationDtoHub = "aiConversationDto";
|
|
public const string XAiConversationEntityHub = "aiConversationEntity";
|
|
|
|
public const string XAiVectorDtoHub = "aiVectorDto";
|
|
public const string XAiVectorEntityHub = "aiVectorEntity";
|
|
|
|
//
|
|
// 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 GetXAiVectorEFRepositoryDescriptor = "GetXAiVectorEFRepositoryDescriptor";
|
|
public const string GetXAiMessageEFRepositoryDescriptor = "GetXAiMessageEFRepositoryDescriptor";
|
|
public const string GetXAiProjectEFRepositoryDescriptor = "GetXAiProjectEFRepositoryDescriptor";
|
|
public const string GetXAiMcpServerEFRepositoryDescriptor = "GetXAiMcpServerEFRepositoryDescriptor";
|
|
public const string GetXAiConversationEFRepositoryDescriptor = "GetXAiConversationEFRepositoryDescriptor";
|
|
|
|
//
|
|
public const string DefaultXAiProjectTitleResourceID = "XAiPrjT";
|
|
public const string DefaultXAiConversationTitleResourceID = "XAiCnvT";
|
|
public const string DefaultXAiProjectDescriptionResourceID = "XAiPrjD";
|
|
|
|
//
|
|
public const string XOpenAINoKey = "no-key-required";
|
|
|
|
//
|
|
// Knowledge (Persistent RAG) ...
|
|
public const string XAiDefaultKnowledgeType = "XAiKnowledge";
|
|
public const string XAiKnowledgeSeparator = "/";
|
|
public const string XAiKnowledgeOwnerSeparator = "/";
|
|
public const string XAiKnowledgeChunkSeparator = "#";
|
|
public const string XAiKnowledgeUserPrefix = "user";
|
|
public const string XAiKnowledgeGlobalPrefix = "global";
|
|
public const string XAiKnowledgeProjectPrefix = "project";
|
|
public const string XAiKnowledgeConversationPrefix = "conversation";
|
|
|
|
//
|
|
// Error Handler Route (Production) ...
|
|
public const string XAiErrorRoute = "/error";
|
|
|
|
//
|
|
// Knowledge Metadata Keys ...
|
|
public const string XAiKnowledgeMetadataType = "type";
|
|
public const string XAiKnowledgeMetadataScope = "scope";
|
|
public const string XAiKnowledgeMetadataScopeId = "scopeId";
|
|
public const string XAiKnowledgeMetadataOwnerId = "ownerId";
|
|
public const string XAiKnowledgeMetadataIngestedAtUtc = "ingestedAtUtc";
|
|
|
|
//
|
|
// Mcp Server ...
|
|
public const int XAiMcpServerMinTimeoutSeconds = 30;
|
|
public const string XAiMcpServerUsageScopeAll = "All";
|
|
public const string XAiMcpServerUsageScopeOwner = "Owner";
|
|
}
|
|
}
|
|
|
|
### 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();
|
|
|
|
//
|
|
// XAiVector ...
|
|
pushHelper.AddHub<XAiVectorDtoHub>(XAiModelsConstants.XAiVectorDtoHub);
|
|
pushHelper.AddHub<XAiVectorEntityHub>(XAiModelsConstants.XAiVectorEntityHub);
|
|
|
|
//
|
|
// XAiMessage ...
|
|
pushHelper.AddHub<XAiMessageDtoHub>(XAiModelsConstants.XAiMessageDtoHub);
|
|
pushHelper.AddHub<XAiMessageEntityHub>(XAiModelsConstants.XAiMessageEntityHub);
|
|
|
|
//
|
|
// XAiProject ...
|
|
pushHelper.AddHub<XAiProjectDtoHub>(XAiModelsConstants.XAiProjectDtoHub);
|
|
pushHelper.AddHub<XAiProjectEntityHub>(XAiModelsConstants.XAiProjectEntityHub);
|
|
|
|
//
|
|
// XAiMcpServer ...
|
|
pushHelper.AddHub<XAiMcpServerDtoHub>(XAiModelsConstants.XAiMcpServerDtoHub);
|
|
pushHelper.AddHub<XAiMcpServerEntityHub>(XAiModelsConstants.XAiMcpServerEntityHub);
|
|
|
|
//
|
|
// 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
|
|
);
|
|
}
|
|
|
|
//
|
|
// Using XAiMcpServer Repository Descriptor ...
|
|
if (!aiMcpServerDescriptor.IsNull())
|
|
{
|
|
//
|
|
app.UseXRepository(
|
|
descriptor: aiMcpServerDescriptor,
|
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
#region Private ...
|
|
private static XRepositoryDescriptor aiVectorDescriptor = null;
|
|
private static XRepositoryDescriptor aiMessageDescriptor = null;
|
|
private static XRepositoryDescriptor aiProjectDescriptor = null;
|
|
private static XRepositoryDescriptor aiMcpServerDescriptor = 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:
|
|
//
|
|
// XAiVector ...
|
|
aiVectorDescriptor = typeof(XAiModelsHelper)
|
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
|
args: null,
|
|
runtimeType: contextType,
|
|
methodName: XAiModelsConstants.GetXAiVectorEFRepositoryDescriptor
|
|
);
|
|
|
|
//
|
|
// 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
|
|
);
|
|
|
|
//
|
|
// XAiMcpServer ...
|
|
aiMcpServerDescriptor = typeof(XAiModelsHelper)
|
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
|
args: null,
|
|
runtimeType: contextType,
|
|
methodName: XAiModelsConstants.GetXAiMcpServerEFRepositoryDescriptor
|
|
);
|
|
|
|
//
|
|
// XAiConversation ...
|
|
aiConversationDescriptor = typeof(XAiModelsHelper)
|
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
|
args: null,
|
|
runtimeType: contextType,
|
|
methodName: XAiModelsConstants.GetXAiConversationEFRepositoryDescriptor
|
|
);
|
|
break;
|
|
|
|
//
|
|
case XRepositoryType.Mongo:
|
|
//
|
|
// XAiVector ...
|
|
aiVectorDescriptor = XAiModelsHelper.GetXAiVectorMongoRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiMessage ...
|
|
aiMessageDescriptor = XAiModelsHelper.GetXAiMessageMongoRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiProject ...
|
|
aiProjectDescriptor = XAiModelsHelper.GetXAiProjectMongoRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiMcpServer ...
|
|
aiMcpServerDescriptor = XAiModelsHelper.GetXAiMcpServerMongoRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiConversation ...
|
|
aiConversationDescriptor = XAiModelsHelper.GetXAiConversationMongoRepositoryDescriptor();
|
|
break;
|
|
|
|
//
|
|
case XRepositoryType.InMemory:
|
|
//
|
|
// XAiVector ...
|
|
aiVectorDescriptor = XAiModelsHelper.GetXAiVectorInMemoryRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiMessage ...
|
|
aiMessageDescriptor = XAiModelsHelper.GetXAiMessageInMemoryRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiProject ...
|
|
aiProjectDescriptor = XAiModelsHelper.GetXAiProjectInMemoryRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiMcpServer ...
|
|
aiMcpServerDescriptor = XAiModelsHelper.GetXAiMcpServerInMemoryRepositoryDescriptor();
|
|
|
|
//
|
|
// XAiConversation ...
|
|
aiConversationDescriptor = XAiModelsHelper.GetXAiConversationInMemoryRepositoryDescriptor();
|
|
break;
|
|
}
|
|
|
|
//
|
|
#region Register Repository Descriptor ...
|
|
//
|
|
// XAiVector ...
|
|
if (!aiVectorDescriptor.IsNull())
|
|
{
|
|
//
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: aiVectorDescriptor
|
|
);
|
|
}
|
|
|
|
//
|
|
// XAiMessage ...
|
|
if (!aiMessageDescriptor.IsNull())
|
|
{
|
|
//
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: aiMessageDescriptor
|
|
);
|
|
}
|
|
|
|
//
|
|
// XAiProject ...
|
|
if (!aiProjectDescriptor.IsNull())
|
|
{
|
|
//
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: aiProjectDescriptor
|
|
);
|
|
}
|
|
|
|
//
|
|
// XAiMcpServer ...
|
|
if (!aiMcpServerDescriptor.IsNull())
|
|
{
|
|
//
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: aiMcpServerDescriptor
|
|
);
|
|
}
|
|
|
|
//
|
|
// XAiConversation ...
|
|
if (!aiConversationDescriptor.IsNull())
|
|
{
|
|
//
|
|
services.AddXRepository(
|
|
lifeTime: lifeTime,
|
|
descriptor: aiConversationDescriptor
|
|
);
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Register Services ...
|
|
//
|
|
#region AiVector ...
|
|
//
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiVectorServiceProvider), typeof(XAiVectorServiceProvider), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiVectorRepositoryService), typeof(XAiVectorRepositoryService), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiVectorRepositoryProvider), typeof(XAiVectorRepositoryProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
// Enrichers ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiVectorEnricher), typeof(XAiVectorEnricher), lifeTime)
|
|
);
|
|
#endregion
|
|
|
|
//
|
|
#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 AiMcpServer ...
|
|
//
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiMcpServerServiceProvider), typeof(XAiMcpServerServiceProvider), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiMcpServerRepositoryService), typeof(XAiMcpServerRepositoryService), lifeTime)
|
|
);
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiMcpServerRepositoryProvider), typeof(XAiMcpServerRepositoryProvider), lifeTime)
|
|
);
|
|
|
|
//
|
|
// Enrichers ...
|
|
services.Add(
|
|
new ServiceDescriptor(typeof(IXAiMcpServerEnricher), typeof(XAiMcpServerEnricher), 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 ||
|
|
source.FinishReason == ChatFinishReason.ToolCalls);
|
|
|
|
//
|
|
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\XAiModelsExtensions.cs
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using xAiModels.Models;
|
|
using xCommons.Constants;
|
|
using xModels.Extensions;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Constants;
|
|
using xAiModels.Models.Dtos;
|
|
using xExceptions.Constants;
|
|
using Microsoft.Extensions.AI;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
|
|
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.Prompt.IsNullOrEmpty();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
public static bool IsValidForAddOrUpdate(this XAiProjectDto source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.OwnerId.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.ProjectId.IsNull() &&
|
|
!source.ProjectId.IsDefaultGuid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
public static bool IsValidForAddOrUpdate(this XAiConversationDto source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.OwnerId.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 McpServer for Add Or Update ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValidForAddOrUpdate(this XAiMcpServer source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.Name.IsNullOrEmpty() &&
|
|
!source.OwnerId.IsNullOrEmpty() &&
|
|
!source.Endpoint.IsNullOrEmpty();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
public static bool IsValidForAddOrUpdate(this XAiMcpServerDto source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.Name.IsNullOrEmpty() &&
|
|
!source.OwnerId.IsNullOrEmpty() &&
|
|
!source.Endpoint.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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate a Request for Retrieve Response in Controllers ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this XAiResponseRequest source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
!source.Prompt.IsNullOrEmpty();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate a File Extraction Result ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static bool IsValid(this XFileExtractionResult source)
|
|
{
|
|
//
|
|
var result =
|
|
!source.IsNullOrDefault() &&
|
|
(
|
|
source.Images.HasChild() ||
|
|
!source.Text.IsNullOrEmpty() ||
|
|
!source.AudioTranscript.IsNullOrEmpty()
|
|
);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a File Extraction Result to AI Contents ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static IList<AIContent> ToAIContents(this XFileExtractionResult source)
|
|
{
|
|
//
|
|
var result = new List<AIContent>();
|
|
|
|
//
|
|
if (source.IsValid())
|
|
{
|
|
//
|
|
// Main Text ...
|
|
if (!source.Text.IsNullOrEmpty())
|
|
{
|
|
result.Add(new TextContent(source.Text));
|
|
}
|
|
|
|
//
|
|
// Images ...
|
|
if (source.Images.HasChild())
|
|
{
|
|
//
|
|
foreach (var img in source.Images)
|
|
{
|
|
result.Add(new DataContent(img.Bytes, img.MimeType));
|
|
}
|
|
}
|
|
|
|
//
|
|
// Transcripted Audio ...
|
|
if (!source.AudioTranscript.IsNullOrEmpty())
|
|
{
|
|
result.Add(new TextContent($"[Audio Transcript]\n{source.AudioTranscript}"));
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check a Collection Contains Default Project for Specified Owner or not ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="ownerId"></param>
|
|
/// <returns></returns>
|
|
public static bool HasDefaultProject(
|
|
this IEnumerable<XAiProjectDto> source,
|
|
string ownerId
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (!source.HasChild() ||
|
|
ownerId.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var item = source
|
|
.FirstOrDefault(x =>
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToNormalString()) &&
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.DefaultXAiProjectDescriptionResourceID.ToNormalString())
|
|
);
|
|
|
|
//
|
|
var result = !item.IsNullOrDefault();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check a Collection Contains Default Conversation for Specified Project or not ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static bool HasDefaultConversation(
|
|
this IEnumerable<XAiConversationDto> source,
|
|
string ownerId,
|
|
Guid projectId
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (!source.HasChild() ||
|
|
projectId.IsDefaultGuid())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var item = source
|
|
.FirstOrDefault(x =>
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToNormalString()) &&
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(projectId.ToString().ToNormalString()) &&
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.DefaultXAiConversationTitleResourceID)
|
|
);
|
|
|
|
//
|
|
var result = !item.IsNullOrDefault();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve Default Project Id from a Collection ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="ownerId"></param>
|
|
/// <returns></returns>
|
|
public static Guid GetDafaultProject(
|
|
this IEnumerable<XAiProjectDto> source,
|
|
string ownerId
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (!source.HasChild() ||
|
|
ownerId.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var item = source
|
|
.FirstOrDefault(x =>
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToNormalString()) &&
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.XAiProjectTitleIdentifier.ToNormalString())
|
|
);
|
|
if (item.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
return item.Id;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get Default Conversation Id from a Collection Contains ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public static Guid GetDefaultConversation(
|
|
this IEnumerable<XAiConversationDto> source,
|
|
string ownerId,
|
|
Guid projectId
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (!source.HasChild() ||
|
|
ownerId.IsNullOrEmpty() ||
|
|
projectId.IsDefaultGuid())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var item = source
|
|
.FirstOrDefault(x =>
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToNormalString()) &&
|
|
x.Title
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier.ToNormalString())
|
|
);
|
|
if (item.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
var result = item.Id;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a Message Dto to ChatMessage ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="additionalContents"></param>
|
|
/// <returns></returns>
|
|
public static ChatMessage ToChatMessages(
|
|
this XAiMessageDto source,
|
|
IList<AIContent> additionalContents = null
|
|
)
|
|
{
|
|
//
|
|
ChatMessage result = null;
|
|
|
|
//
|
|
if (!source.IsNullOrDefault())
|
|
{
|
|
//
|
|
var contents = new List<AIContent>
|
|
{
|
|
//
|
|
// Add Source Content ...
|
|
new TextContent(source.Content)
|
|
};
|
|
|
|
//
|
|
// Add Additional Content ...
|
|
if (additionalContents.HasChild())
|
|
{
|
|
contents.AddRange(additionalContents);
|
|
}
|
|
|
|
//
|
|
result = new ChatMessage
|
|
{
|
|
Contents = contents,
|
|
AuthorName =
|
|
source.Role == XAiChatRole.User &&
|
|
!source.Owner.IsNullOrDefault()
|
|
? source.Owner.GetFullname()
|
|
: string.Empty,
|
|
Role = source.Role.ToChatRole(),
|
|
MessageId = source.Id.ToString(),
|
|
};
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add Model Provider API Key ...
|
|
/// </summary>
|
|
/// <param name="descriptor"></param>
|
|
/// <param name="request"></param>
|
|
public static void AddModelDescriptorApiKey(
|
|
this XAiModelDescriptor descriptor,
|
|
HttpRequestMessage request
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (!descriptor.IsValid() || request.IsNull())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
var apiKey =
|
|
descriptor.Provider != XAiModelProviderType.OpenAI
|
|
? descriptor.ApiKey
|
|
: descriptor.ApiKey.IsNullOrEmpty()
|
|
? XAiModelsConstants.XOpenAINoKey
|
|
: descriptor.ApiKey;
|
|
request.Headers.TryAddWithoutValidation(
|
|
name: XAuthorization.Header,
|
|
value: $"{XAuthorization.TokenIdentifier} {apiKey}"
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts To AITools ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static IList<AITool> ToAITools(
|
|
this IList<XAiMcpToolDefinition> source
|
|
)
|
|
{
|
|
//
|
|
var result = new List<AITool>();
|
|
|
|
//
|
|
foreach (var tool in source)
|
|
{
|
|
//
|
|
var declaration = AIFunctionFactory.CreateDeclaration(
|
|
name: tool.Name,
|
|
jsonSchema: tool.InputSchema,
|
|
description: tool.Description
|
|
);
|
|
|
|
//
|
|
result.Add(declaration);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Extensions\XEmbeddingExtensions.cs
|
|
|
|
using System;
|
|
using xCommons.Extensions;
|
|
|
|
namespace xAiModels.Extensions
|
|
{
|
|
public static class XEmbeddingExtensions
|
|
{
|
|
/// <summary>
|
|
/// Converts String to Embeddings JSON ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static float[] AsEmbedding(this string source)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (source.IsNullOrEmpty())
|
|
{
|
|
return [];
|
|
}
|
|
|
|
//
|
|
// JSON is expected to be like: [0.12, 0.34, ...] ...
|
|
var result = source.FromJSON<float[]>();
|
|
if (!result.HasChild())
|
|
{
|
|
result = [];
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts ReadOnly Memory to Embedding Representation ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <returns></returns>
|
|
public static string ToEmbedding(this ReadOnlyMemory<float> source)
|
|
{
|
|
//
|
|
var result = string.Empty;
|
|
|
|
//
|
|
if (!source.IsNull() && !source.IsEmpty)
|
|
{
|
|
result = source.ToArray().ToJSON();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Helpers\VectorHelper.cs
|
|
|
|
using System;
|
|
using xCommons.Extensions;
|
|
using System.Numerics.Tensors;
|
|
using xExceptions.Constants;
|
|
|
|
namespace xAiModels.Helpers
|
|
{
|
|
public static class VectorHelper
|
|
{
|
|
/// <summary>
|
|
/// Normalize a Vector ...
|
|
/// </summary>
|
|
/// <param name="vector"></param>
|
|
public static void Normalize(float[] vector)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (vector.IsNull() || !vector.HasChild())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
float sum = 0f;
|
|
foreach (var value in vector)
|
|
{
|
|
sum += value * value;
|
|
}
|
|
|
|
//
|
|
float norm = MathF.Sqrt(sum);
|
|
if (norm <= 1e-9f)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < vector.Length; i++)
|
|
{
|
|
vector[i] /= norm;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Similarity Check ...
|
|
/// </summary>
|
|
/// <param name="a"></param>
|
|
/// <param name="b"></param>
|
|
/// <returns></returns>
|
|
public static float CosineSimilarity(
|
|
float[] a,
|
|
float[] b
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (a.Length != b.Length)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Check Similarity ...
|
|
var result = TensorPrimitives
|
|
.CosineSimilarity(
|
|
a.AsSpan(),
|
|
b.AsSpan()
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Helpers\XAiMcpHeaderBuilder.cs
|
|
|
|
using xCommons.Constants;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Constants;
|
|
using xIdentityModels.Models;
|
|
using xCommons.Configurations;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Constants;
|
|
|
|
namespace xAiModels.Helpers
|
|
{
|
|
/// <summary>
|
|
/// a Helper Class for Prepare Headers of MCP Client ...
|
|
/// </summary>
|
|
public static class XAiMcpHeaderBuilder
|
|
{
|
|
/// <summary>
|
|
/// Build Headers for MCP Client Connection ...
|
|
/// </summary>
|
|
/// <param name="appConfiguration"></param>
|
|
/// <param name="sessionId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="userInfo"></param>
|
|
/// <param name="protocolVersion"></param>
|
|
/// <returns></returns>
|
|
public static Dictionary<string, string> Build(
|
|
XAppConfiguration appConfiguration,
|
|
string sessionId = null,
|
|
string connectionId = null,
|
|
XUserClaimsInfoDto userInfo = null,
|
|
string protocolVersion = XAiMcpConstants.XAiMcpProtocol
|
|
)
|
|
{
|
|
//
|
|
var headers = new Dictionary<string, string>
|
|
{
|
|
//
|
|
["Accept"] = "application/json, text/event-stream",
|
|
["Content-Type"] = "application/json",
|
|
[XAiMcpConstants.XAiMcpProtocolIdentifier] = protocolVersion,
|
|
[XAuthorization.XPoweredBy] = appConfiguration.XPoweredValue ?? "xAiApi"
|
|
};
|
|
|
|
//
|
|
// Adding Authorization Headers ...
|
|
if (!userInfo.IsNullOrDefault() && !userInfo.AccessToken.IsNullOrEmpty())
|
|
{
|
|
//
|
|
headers[XAuthorization.Header] = $"{XAuthorization.TokenIdentifier} {userInfo.AccessToken}";
|
|
headers[XAuthorization.ExpiresAt] = userInfo.ExpiresAt.ToString();
|
|
|
|
//
|
|
if (!userInfo.RefreshToken.IsNullOrEmpty())
|
|
{
|
|
headers[XAuthorization.RefreshToken] = userInfo.RefreshToken;
|
|
}
|
|
}
|
|
|
|
//
|
|
// شناسه اتصال (برای Push Notification ها)
|
|
if (!connectionId.IsNullOrEmpty()) {
|
|
headers[XHeader.ConnectionId.GetStringValue()] = connectionId;
|
|
}
|
|
|
|
//
|
|
// Session Id ...
|
|
if (!sessionId.IsNullOrEmpty()) {
|
|
headers[XAiMcpConstants.XAiMcpSessionIdentifier] = sessionId;
|
|
}
|
|
|
|
//
|
|
return headers;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Helpers\XAiMcpSseReader.cs
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xHttpService.Constants;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace xAiModels.Helpers
|
|
{
|
|
public static class XAiMcpSseReader
|
|
{
|
|
/// <summary>
|
|
/// Read an SSE Event ...
|
|
/// </summary>
|
|
/// <param name="stream"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public static async IAsyncEnumerable<string> ReadAsync(
|
|
Stream stream,
|
|
[EnumeratorCancellation]
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
using var reader = new StreamReader(stream, Encoding.UTF8);
|
|
var dataBuffer = new StringBuilder();
|
|
while (!reader.EndOfStream)
|
|
{
|
|
//
|
|
var line = await reader.ReadLineAsync();
|
|
if (line is null)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
if (cancellationToken.IsCancellationRequested)
|
|
{
|
|
yield break;
|
|
}
|
|
|
|
//
|
|
// Empty Line equals End of an Event ...
|
|
if (line.IsNullOrEmpty())
|
|
{
|
|
//
|
|
if (dataBuffer.Length > 0)
|
|
{
|
|
//
|
|
yield return dataBuffer.ToString();
|
|
dataBuffer.Clear();
|
|
}
|
|
|
|
//
|
|
continue;
|
|
}
|
|
|
|
//
|
|
if (line.StartsWith(XSSEConstants.DataIdentifier, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
//
|
|
var data = line
|
|
.Substring(XSSEConstants.DataIdentifier.Length)
|
|
.TrimStart();
|
|
|
|
//
|
|
if (dataBuffer.Length > 0)
|
|
{
|
|
dataBuffer.Append('\n');
|
|
}
|
|
|
|
//
|
|
dataBuffer.Append(data);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (dataBuffer.Length > 0)
|
|
{
|
|
yield return dataBuffer.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
### 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
|
|
|
|
//
|
|
#region XAiVector ...
|
|
//
|
|
#region EF Repository Descriptor Provider(s) ...
|
|
public static XEFRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorEFRepository<TContext>,
|
|
TContext
|
|
> GetXAiVectorEFRepositoryDescriptor<TContext>()
|
|
where TContext : XDbContext
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorEFRepository<TContext>,
|
|
TContext
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XEFRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorEFRepository<TContext>,
|
|
TContext,
|
|
IXAiVectorSeeder,
|
|
TSeederImplementation
|
|
> GetXAiVectorEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
|
where TContext : XDbContext
|
|
where TSeederImplementation : XBaseDbSeeder<XAiVector, Guid>
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorEFRepository<TContext>,
|
|
TContext,
|
|
IXAiVectorSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Mongo Repository Descriptor Provider(s) ...
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorMongoRepository
|
|
> GetXAiVectorMongoRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorMongoRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorMongoRepository,
|
|
IXAiVectorSeeder,
|
|
TSeederImplementation
|
|
> GetXAiVectorMongoRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiVector, Guid>
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorMongoRepository,
|
|
IXAiVectorSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region InMemory Repository Descriptor Provider(s) ...
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorInMemoryRepository
|
|
> GetXAiVectorInMemoryRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorInMemoryRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorInMemoryRepository,
|
|
IXAiVectorSeeder,
|
|
TSeederImplementation
|
|
> GetXAiVectorInMemoryRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiVector, Guid>
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiVector,
|
|
Guid,
|
|
IXAiVectorKeyGenerator,
|
|
XAiVectorKeyGenerator,
|
|
IXAiVectorRepositoryEvents,
|
|
XAiVectorRepositoryEvents,
|
|
XAiVectorGraphType,
|
|
GuidGraphType,
|
|
XAiVectorGraphQuery,
|
|
IXAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphQLTypeHelper,
|
|
XAiVectorGraphSchema,
|
|
IXAiVectorRepository,
|
|
XAiVectorInMemoryRepository,
|
|
IXAiVectorSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
//
|
|
#region XAiMcpServer ...
|
|
//
|
|
#region EF Repository Descriptor Provider(s) ...
|
|
public static XEFRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerEFRepository<TContext>,
|
|
TContext
|
|
> GetXAiMcpServerEFRepositoryDescriptor<TContext>()
|
|
where TContext : XDbContext
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerEFRepository<TContext>,
|
|
TContext
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XEFRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerEFRepository<TContext>,
|
|
TContext,
|
|
IXAiMcpServerSeeder,
|
|
TSeederImplementation
|
|
> GetXAiMcpServerEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
|
where TContext : XDbContext
|
|
where TSeederImplementation : XBaseDbSeeder<XAiMcpServer, Guid>
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerEFRepository<TContext>,
|
|
TContext,
|
|
IXAiMcpServerSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Mongo Repository Descriptor Provider(s) ...
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerMongoRepository
|
|
> GetXAiMcpServerMongoRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerMongoRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XMongoRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerMongoRepository,
|
|
IXAiMcpServerSeeder,
|
|
TSeederImplementation
|
|
> GetXAiMcpServerMongoRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiMcpServer, Guid>
|
|
{
|
|
//
|
|
var result = new XMongoRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerMongoRepository,
|
|
IXAiMcpServerSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region InMemory Repository Descriptor Provider(s) ...
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerInMemoryRepository
|
|
> GetXAiMcpServerInMemoryRepositoryDescriptor()
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerInMemoryRepository
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XInMemoryRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerInMemoryRepository,
|
|
IXAiMcpServerSeeder,
|
|
TSeederImplementation
|
|
> GetXAiMcpServerInMemoryRepositoryDescriptor<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XAiMcpServer, Guid>
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XAiMcpServer,
|
|
Guid,
|
|
IXAiMcpServerKeyGenerator,
|
|
XAiMcpServerKeyGenerator,
|
|
IXAiMcpServerRepositoryEvents,
|
|
XAiMcpServerRepositoryEvents,
|
|
XAiMcpServerGraphType,
|
|
GuidGraphType,
|
|
XAiMcpServerGraphQuery,
|
|
IXAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphQLTypeHelper,
|
|
XAiMcpServerGraphSchema,
|
|
IXAiMcpServerRepository,
|
|
XAiMcpServerInMemoryRepository,
|
|
IXAiMcpServerSeeder,
|
|
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 xModels.Dtos;
|
|
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 Getters ...
|
|
/// <summary>
|
|
/// Retrieve Specified Project ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiProjectDto> GetProject(
|
|
Guid id,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Retrieve Specified Conversation ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiConversationDto> GetConversation(
|
|
Guid id,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
|
|
//
|
|
#region Loaders ...
|
|
/// <summary>
|
|
/// Load Projects List of Specified Owner ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiProjectDto>> LoadProjects(
|
|
string ownerId,
|
|
string connectionId = null,
|
|
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="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
|
Guid projectId,
|
|
bool fillMessages = false,
|
|
string connectionId = null,
|
|
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 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(
|
|
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<XAiProjectDto> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = 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<XAiConversationDto> sources,
|
|
bool fillMessages = false,
|
|
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<XAiMessageDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
|
|
//
|
|
#region Defaults ...
|
|
/// <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>
|
|
Task<XAiProjectDto> GetDefaultProject(
|
|
string ownerId,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <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>
|
|
Task<XAiConversationDto> GetDefaultConversation(
|
|
string ownerId,
|
|
Guid? projectId,
|
|
string connectionId = null,
|
|
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="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="item"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiConversationDto> CreateConversation(
|
|
string ownerId,
|
|
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
|
|
|
|
//
|
|
#region Query ...
|
|
/// <summary>
|
|
/// Query Projects ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="query"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XQueryResult<XAiProjectDto>> QueryProjects(
|
|
string ownerId,
|
|
XQuery query,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Query Conversations ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="query"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XQueryResult<XAiConversationDto>> QueryConversations(
|
|
string ownerId,
|
|
Guid projectId,
|
|
XQuery query,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Query Messages ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="conversationId"></param>
|
|
/// <param name="query"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XQueryResult<XAiMessageDto>> QueryMessages(
|
|
string ownerId,
|
|
Guid conversationId,
|
|
XQuery query,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
#endregion
|
|
|
|
//
|
|
#region Vectors ...
|
|
/// <summary>
|
|
/// Insert or Update a Single Vector (Matched by Identifier) ...
|
|
/// </summary>
|
|
/// <param name="identifier"></param>
|
|
/// <param name="text"></param>
|
|
/// <param name="embedding"></param>
|
|
/// <param name="metadata"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task UpsertVectorAsync(
|
|
string identifier,
|
|
string text,
|
|
ReadOnlyMemory<float> embedding,
|
|
Dictionary<string, string> metadata = null,
|
|
string type = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Insert or Update a Batch of Vectors (Matched by Identifier) ...
|
|
/// </summary>
|
|
/// <param name="items"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>Count of Stored Vectors</returns>
|
|
Task<int> UpsertVectorsAsync(
|
|
IEnumerable<XAiVectorDto> items,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Search Vectors by Cosine Similarity (Top K) ...
|
|
/// </summary>
|
|
/// <param name="queryEmbedding"></param>
|
|
/// <param name="topK"></param>
|
|
/// <param name="minScore"></param>
|
|
/// <param name="identifierPrefix">Optional: Restrict Search to Vectors whose Identifier Starts with this Prefix</param>
|
|
/// <param name="type">Optional: Restrict Search to Vectors of Specified Type</param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IReadOnlyList<XAiVectorSearchResult>> SearchVectorsAsync(
|
|
ReadOnlyMemory<float> queryEmbedding,
|
|
int topK = 5,
|
|
float minScore = 0f,
|
|
string identifierPrefix = null,
|
|
string type = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Load Vectors whose Identifier Starts with Specified Prefix ...
|
|
/// </summary>
|
|
/// <param name="identifierPrefix"></param>
|
|
/// <param name="includeEmbedding"></param>
|
|
/// <param name="type">Optional: Restrict to Vectors of Specified Type</param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IReadOnlyList<XAiVectorDto>> LoadVectorsAsync(
|
|
string identifierPrefix,
|
|
bool includeEmbedding = false,
|
|
string type = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Remove Vectors whose Identifier Starts with Specified Prefix ...
|
|
/// </summary>
|
|
/// <param name="identifierPrefix"></param>
|
|
/// <param name="type">Optional: Restrict to Vectors of Specified Type</param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>Count of Removed Vectors</returns>
|
|
Task<int> RemoveVectorsAsync(
|
|
string identifierPrefix,
|
|
string type = 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\IXAiMcpServerDtoHub.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiMcpServerDtoHub : IXBaseDtoHub<XAiMcpServer, XAiMcpServerDto, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiMcpServerRepositoryService.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiMcpServerRepositoryService : IXBaseRepositoryService<XAiMcpServer, XAiMcpServerDto, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiMcpServerServiceProvider.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Providers.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiMcpServerServiceProvider : IXBaseDtoProvider<XAiMcpServer, XAiMcpServerDto, Guid, XAiMcpServerDtoHub>
|
|
{ }
|
|
}
|
|
|
|
### 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\Dtos\IXAiVectorDtoHub.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiVectorDtoHub : IXBaseDtoHub<XAiVector, XAiVectorDto, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiVectorRepositoryService.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiVectorRepositoryService : IXBaseRepositoryService<XAiVector, XAiVectorDto, Guid>
|
|
{
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Dtos\IXAiVectorServiceProvider.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Providers.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Dtos
|
|
{
|
|
public interface IXAiVectorServiceProvider : IXBaseDtoProvider<XAiVector, XAiVectorDto, Guid, XAiVectorDtoHub>
|
|
{ }
|
|
}
|
|
|
|
### 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\IXAiMcpServerEnricher.cs
|
|
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Interfaces.Enrichers
|
|
{
|
|
public interface IXAiMcpServerEnricher
|
|
{
|
|
Task<XAiMcpServerDto> Enrich(
|
|
XAiMcpServer source,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
Task<XAiMcpServerDto> Enrich(
|
|
XAiMcpServerDto source,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
|
IEnumerable<XAiMcpServer> sources,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
|
IEnumerable<XAiMcpServerDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
}
|
|
}
|
|
|
|
### 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\Enrichers\IXAiVectorEnricher.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 IXAiVectorEnricher
|
|
{
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiVectorDto> Enrich(
|
|
XAiVector source,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiVectorDto> Enrich(
|
|
XAiVectorDto source,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
|
IEnumerable<XAiVector> sources,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
|
IEnumerable<XAiVectorDto> sources,
|
|
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\IXAiMcpServerEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMcpServerEntityHub : IXBaseEntityHub<XAiMcpServer, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMcpServerGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XAiMcpServer, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerKeyGenerator.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMcpServerKeyGenerator : IXKeyGenerator<XAiMcpServer, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMcpServerRepository : IXBaseRepository<XAiMcpServer, Guid> { }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerRepositoryEvents.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMcpServerRepositoryEvents : IXBaseRepositoryEvents<XAiMcpServer>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Providers.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMcpServerRepositoryProvider : IXBaseEntityProvider<XAiMcpServer, Guid, XAiMcpServerEntityHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerSeeder.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiMcpServerSeeder : IXBaseDbSeeder<XAiMcpServer, Guid>
|
|
{ }
|
|
}
|
|
|
|
### 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\Interfaces\Entities\IXAiVectorEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiVectorEntityHub : IXBaseEntityHub<XAiVector, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiVectorGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XAiVector, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorKeyGenerator.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiVectorKeyGenerator : IXKeyGenerator<XAiVector, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiVectorRepository : IXBaseRepository<XAiVector, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorRepositoryEvents.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiVectorRepositoryEvents : IXBaseRepositoryEvents<XAiVector>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorRepositoryProvider.cs
|
|
|
|
using System;
|
|
using xPushService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Providers.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiVectorRepositoryProvider : IXBaseEntityProvider<XAiVector, Guid, XAiVectorEntityHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorSeeder.cs
|
|
|
|
using System;
|
|
using xDataService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Interfaces.Entities
|
|
{
|
|
public interface IXAiVectorSeeder : IXBaseDbSeeder<XAiVector, Guid>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiMcpJsonRpcError.cs
|
|
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
public class XAiMcpJsonRpcError
|
|
{
|
|
[JsonPropertyName("code")]
|
|
public int Code { get; set; }
|
|
|
|
[JsonPropertyName("message")]
|
|
public string Message { get; set; }
|
|
|
|
[JsonPropertyName("data")]
|
|
public JsonElement? Data { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiMcpJsonRpcRequest.cs
|
|
|
|
using System;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
public class XAiMcpJsonRpcRequest
|
|
{
|
|
[JsonPropertyName("jsonrpc")]
|
|
public string JsonRpc { get; set; } = "2.0";
|
|
|
|
[JsonPropertyName("id")]
|
|
public string Id { get; set; } = Guid.NewGuid().ToString("N");
|
|
|
|
[JsonPropertyName("method")]
|
|
public string Method { get; set; }
|
|
|
|
[JsonPropertyName("params")]
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public object Params { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiMcpJsonRpcResponse.cs
|
|
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
public class XAiMcpJsonRpcResponse
|
|
{
|
|
[JsonPropertyName("jsonrpc")]
|
|
public string JsonRpc { get; set; }
|
|
|
|
[JsonPropertyName("id")]
|
|
public string Id { get; set; }
|
|
|
|
[JsonPropertyName("result")]
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public JsonElement? Result { get; set; }
|
|
|
|
[JsonPropertyName("error")]
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public XAiMcpJsonRpcError Error { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public bool IsSuccess => Error is null;
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiMcpToolDefinition.cs
|
|
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
public class XAiMcpToolDefinition
|
|
{
|
|
[JsonPropertyName("name")]
|
|
public string Name { get; set; }
|
|
|
|
[JsonPropertyName("description")]
|
|
public string Description { get; set; }
|
|
|
|
[JsonPropertyName("inputSchema")]
|
|
public JsonElement InputSchema { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiMcpToolDescriptor.cs
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
public class XAiMcpToolDescriptor
|
|
{
|
|
public string Name { get; set; }
|
|
public string Description { get; set; }
|
|
public JObject InputSchema { get; set; }
|
|
public string RequiredPolicy { get; set; }
|
|
public bool RequiresAuthentication { get; set; } = false;
|
|
public Func<JObject, CancellationToken, Task<string>> Execute { get; set; }
|
|
}
|
|
}
|
|
|
|
### 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\XAiResonseMessage.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using xAiModels.Constants;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
public class XAiResonseMessage : XBaseDto
|
|
{
|
|
public long Sequence { get; set; }
|
|
public Guid RespondTo { get; set; }
|
|
public string OwnerId { get; set; }
|
|
public string Content { get; set; }
|
|
public XAiChatRole Role { get; set; }
|
|
public DateTime RespondedOn { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiResponseRequest.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
/// <summary>
|
|
/// /Request for a Response in Controllers ...
|
|
/// </summary>
|
|
public class XAiResponseRequest
|
|
{
|
|
/// <summary>
|
|
/// Prompt Text ...
|
|
/// </summary>
|
|
public string Prompt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Knowledge Type ...
|
|
/// </summary>
|
|
public string Type { get; set; } = XAiModelsConstants.XAiDefaultKnowledgeType;
|
|
|
|
/// <summary>
|
|
/// Provided TopK in Vector Searchs ...
|
|
/// </summary>
|
|
public int? TopK { get; set; }
|
|
|
|
/// <summary>
|
|
/// Min Score for Vector Searchs ...
|
|
/// </summary>
|
|
public float? MinScore { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specified Project Id ...
|
|
/// </summary>
|
|
public Guid? ProjectId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specified Conversation Id ...
|
|
/// </summary>
|
|
public Guid? ConversationId { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XFileExtractionResult.cs
|
|
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Models
|
|
{
|
|
/// <summary>
|
|
/// Holds File Extraction Result ...
|
|
/// </summary>
|
|
public class XFileExtractionResult
|
|
{
|
|
/// <summary>
|
|
/// Extracted String Content ...
|
|
/// </summary>
|
|
public string Text { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Extracted Images for Vision Model ...
|
|
/// </summary>
|
|
public IList<XExtractedImage> Images { get; set; } = [];
|
|
|
|
/// <summary>
|
|
/// Extracted Content from Audio File ...
|
|
/// </summary>
|
|
public string AudioTranscript { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Main File Name ...
|
|
/// </summary>
|
|
public string FileName { get; set; }
|
|
|
|
/// <summary>
|
|
/// Main File MIME Type ...
|
|
/// </summary>
|
|
public string MimeType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specified Fallback done using Images or not ...
|
|
/// </summary>
|
|
public bool UsedImageFallback { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Error Message ...
|
|
/// </summary>
|
|
public string ErrorMessage { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Extracted Image ...
|
|
/// </summary>
|
|
public class XExtractedImage
|
|
{
|
|
/// <summary>
|
|
/// Content as Byte ...
|
|
/// </summary>
|
|
public byte[] Bytes { get; set; }
|
|
|
|
/// <summary>
|
|
/// MIME Type of Image ...
|
|
/// </summary>
|
|
public string MimeType { get; set; } = "image/png";
|
|
|
|
/// <summary>
|
|
/// for PDF Files ...
|
|
/// </summary>
|
|
public int? PageNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// Describe Image ...
|
|
/// </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\XAiMcpServerDto.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using xModels.Dtos;
|
|
using xAiModels.Constants;
|
|
|
|
namespace xAiModels.Models.Dtos
|
|
{
|
|
public class XAiMcpServerDto : XBaseGuidIDEntityDto
|
|
{
|
|
/// <summary>
|
|
/// Owner ...
|
|
/// </summary>
|
|
public string OwnerId { get; set; }
|
|
public virtual XPersonDto Owner { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specified Which Scope can Use MCP Server ...
|
|
/// </summary>
|
|
public XAiMcpServerUsageScope Scope { get; set; } = XAiMcpServerUsageScope.Owner;
|
|
|
|
/// <summary>
|
|
/// MCP Server Name ...
|
|
/// </summary>
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// Description ...
|
|
/// </summary>
|
|
public string Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// Enabled or Disabled ...
|
|
/// </summary>
|
|
public bool Enabled { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Environment Variables as JSON Object ...
|
|
/// </summary>
|
|
public string EnvironmentVariables { get; set; }
|
|
|
|
/// <summary>
|
|
/// Endpoint to Connect ...
|
|
/// </summary>
|
|
public string Endpoint { get; set; }
|
|
|
|
/// <summary>
|
|
/// Headers List as Json Object ...
|
|
/// </summary>
|
|
public string Headers { get; set; }
|
|
|
|
/// <summary>
|
|
/// Timout Secconds ...
|
|
/// </summary>
|
|
public int TimeoutSeconds { get; set; } = 30;
|
|
|
|
public DateTime CreatedOn { get; set; }
|
|
public DateTime UpdatedAt { 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\Dtos\XAiVectorDto.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Models.Dtos
|
|
{
|
|
/// <summary>
|
|
/// Vector DTO for AI Vector data ...
|
|
/// </summary>
|
|
public class XAiVectorDto : XBaseGuidIDEntityDto
|
|
{
|
|
/// <summary>
|
|
/// Text content of the vector ...
|
|
/// </summary>
|
|
public string Text { get; set; }
|
|
|
|
/// <summary>
|
|
/// Doc and Chunk Identifier ...
|
|
/// </summary>
|
|
public string Identifier { get; set; }
|
|
|
|
/// <summary>
|
|
/// Knowledge Base Type / Domain (Optional Filter on Search) ...
|
|
/// </summary>
|
|
public string Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// Embedding vector representation ...
|
|
/// </summary>
|
|
public virtual ReadOnlyMemory<float> Embedding { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Metadata associated with the vector ...
|
|
/// </summary>
|
|
public virtual Dictionary<string, string> Metadata { get; set; } = null;
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\Dtos\XAiVectorSearchResult.cs
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiModels.Models.Dtos
|
|
{
|
|
public class XAiVectorSearchResult
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string Text { get; set; }
|
|
public float Score { get; set; }
|
|
public string Type { get; set; }
|
|
public string Identifier { get; set; }
|
|
public Dictionary<string, string> Metadata { get; set; } = null;
|
|
}
|
|
}
|
|
|
|
### 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\XAiMcpServer.cs
|
|
|
|
using System;
|
|
using xModels.Base;
|
|
using xAiModels.Constants;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace xAiModels.Models.Entities
|
|
{
|
|
/// <summary>
|
|
/// An MCP Server Descriptor for Adding Tools to XAI ...
|
|
/// </summary>
|
|
public class XAiMcpServer : XBaseGuidIDEntity
|
|
{
|
|
/// <summary>
|
|
/// Owner ...
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string OwnerId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specified Which Scope can Use MCP Server ...
|
|
/// </summary>
|
|
public XAiMcpServerUsageScope Scope { get; set; } = XAiMcpServerUsageScope.Owner;
|
|
|
|
/// <summary>
|
|
/// MCP Server Name ...
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(255)]
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// Description ...
|
|
/// </summary>
|
|
[StringLength(1000)]
|
|
public string Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// Enabled or Disabled ...
|
|
/// </summary>
|
|
public bool Enabled { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Environment Variables as JSON Object ...
|
|
/// </summary>
|
|
public string EnvironmentVariables { get; set; }
|
|
|
|
/// <summary>
|
|
/// Endpoint to Connect ...
|
|
/// </summary>
|
|
[StringLength(1000)]
|
|
public string Endpoint { get; set; }
|
|
|
|
/// <summary>
|
|
/// Headers List as Json Object ...
|
|
/// </summary>
|
|
public string Headers { get; set; }
|
|
|
|
/// <summary>
|
|
/// Timout Secconds ...
|
|
/// </summary>
|
|
public int TimeoutSeconds { get; set; } = 30;
|
|
|
|
public DateTime CreatedOn { get; set; }
|
|
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\Models\Entities\XAiVector.cs
|
|
|
|
using xModels.Base;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace xAiModels.Models.Entities
|
|
{
|
|
public class XAiVector : XBaseGuidIDEntity
|
|
{
|
|
/// <summary>
|
|
/// Thge Content Which Embedded ...
|
|
/// </summary>
|
|
public string Text { get; set; }
|
|
|
|
/// <summary>
|
|
/// Doc and Chunk Identifier ...
|
|
/// </summary>
|
|
public string Identifier { get; set; }
|
|
|
|
/// <summary>
|
|
/// Knowledge Base Type / Domain (e.g. "Legal", "Medical") ...
|
|
/// Used for Filtering on Search and Retrieve ...
|
|
/// </summary>
|
|
[StringLength(100)]
|
|
public string Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// a Json String which Represents IReadOnlyList of float ...
|
|
/// </summary>
|
|
public string Embedding { get; set; }
|
|
|
|
/// <summary>
|
|
/// a Json String Which Represents MetaData ...
|
|
/// </summary>
|
|
public string Metadata { get; set; } = string.Empty;
|
|
}
|
|
}
|
|
|
|
### 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.Helpers;
|
|
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 System.Linq.Expressions;
|
|
using xDataService.Extensions;
|
|
using xAiModels.Providers.Hubs;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xStringService.Interfaces;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using xAiModels.Interfaces.Entities;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
|
|
namespace xAiModels.Providers
|
|
{
|
|
/// <summary>
|
|
/// All Data Manipulation Requirements ...
|
|
/// </summary>
|
|
public class XAiDataProvider : IXAiDataProvider
|
|
{
|
|
//
|
|
#region Properties ...
|
|
private readonly IXStringProvider stringProvider;
|
|
private readonly IXAiVectorEnricher vectorEnricher;
|
|
private readonly XAppConfiguration appConfiguration;
|
|
private readonly IHubContext<XAiDataProviderHub> hub;
|
|
private readonly IXAiMessageEnricher messageEnricher;
|
|
private readonly IXAiProjectEnricher projectEnricher;
|
|
private readonly IXAiVectorRepository vectorRepository;
|
|
private readonly IXAiMcpServerEnricher mcpServerEnricher;
|
|
private readonly IXAiMcpServerRepository mcpServerRepository;
|
|
private readonly IXAiConversationEnricher conversationEnricher;
|
|
private readonly IXAiVectorRepositoryService vectorRepositoryService;
|
|
private readonly IXAiMessageRepositoryService messageRepositoryService;
|
|
private readonly IXAiProjectRepositoryService projectRepositoryService;
|
|
private readonly IXAiMcpServerRepositoryService mcpServerRepositoryService;
|
|
private readonly IXAiProjectTitleResourceProvider projectTitleResourceProvider;
|
|
private readonly IXAiConversationRepositoryService conversationRepositoryService;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
|
#endregion
|
|
|
|
public XAiDataProvider(
|
|
IXStringProvider stringProvider,
|
|
IXAiVectorEnricher vectorEnricher,
|
|
XAppConfiguration appConfiguration,
|
|
IHubContext<XAiDataProviderHub> hub,
|
|
IXAiProjectEnricher projectEnricher,
|
|
IXAiMessageEnricher messageEnricher,
|
|
IXAiVectorRepository vectorRepository,
|
|
IXAiMcpServerEnricher mcpServerEnricher,
|
|
IXAiMcpServerRepository mcpServerRepository,
|
|
IXAiConversationEnricher conversationEnricher,
|
|
IXAiVectorRepositoryService vectorRepositoryService,
|
|
IXAiMessageRepositoryService messageRepositoryService,
|
|
IXAiProjectRepositoryService projectRepositoryService,
|
|
IXAiMcpServerRepositoryService mcpServerRepositoryService,
|
|
IXAiProjectTitleResourceProvider projectTitleResourceProvider,
|
|
IXAiConversationRepositoryService conversationRepositoryService,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider,
|
|
IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider
|
|
)
|
|
{
|
|
this.hub = hub;
|
|
this.stringProvider = stringProvider;
|
|
this.vectorEnricher = vectorEnricher;
|
|
this.projectEnricher = projectEnricher;
|
|
this.messageEnricher = messageEnricher;
|
|
this.appConfiguration = appConfiguration;
|
|
this.vectorRepository = vectorRepository;
|
|
this.mcpServerEnricher = mcpServerEnricher;
|
|
this.mcpServerRepository = mcpServerRepository;
|
|
this.conversationEnricher = conversationEnricher;
|
|
this.vectorRepositoryService = vectorRepositoryService;
|
|
this.messageRepositoryService = messageRepositoryService;
|
|
this.projectRepositoryService = projectRepositoryService;
|
|
this.mcpServerRepositoryService = mcpServerRepositoryService;
|
|
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="connectionId"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiProjectDto>> LoadProjects(
|
|
string ownerId,
|
|
string connectionId = null,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (ownerId.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Handle Default Project and Conversation ...
|
|
|
|
//
|
|
// Default Project ...
|
|
bool hasDefault = await HasDefaultProject(
|
|
ownerId: ownerId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!hasDefault)
|
|
{
|
|
//
|
|
await CreateDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
var defaultProject = await GetDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Default Project's Default Conversation ...
|
|
hasDefault = await HasDefaultConversation(
|
|
ownerId: ownerId,
|
|
projectId: defaultProject.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!hasDefault)
|
|
{
|
|
//
|
|
await CreateDefaultConversation(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
projectId: defaultProject.Id,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Retrieve Project List ...
|
|
var result = await projectRepositoryService.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
predicate: x => x.OwnerId == ownerId,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
|
|
//
|
|
if (result.HasChild())
|
|
{
|
|
//
|
|
result = await projectEnricher.EnrichRange(
|
|
sources: result,
|
|
cancellationToken: cancellationToken,
|
|
fillConversations: fillConversations,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load List of Conversations for Specified Project ...
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
|
Guid projectId,
|
|
bool fillMessages = false,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (projectId.IsNull() ||
|
|
projectId.IsDefaultGuid()
|
|
)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Retrieve Project ...
|
|
var project = await projectRepositoryService.GetAsync(
|
|
id: projectId,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (project.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
// Default Conversation ...
|
|
var hasDefault = await HasDefaultConversation(
|
|
projectId: projectId,
|
|
ownerId: project.OwnerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!hasDefault)
|
|
{
|
|
//
|
|
await CreateDefaultConversation(
|
|
projectId: projectId,
|
|
ownerId: project.OwnerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
// Retrieve Conversation's List ...
|
|
var result = await conversationRepositoryService.FindManyAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
predicate: x => x.ProjectId == projectId,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
|
|
//
|
|
if (result.HasChild())
|
|
{
|
|
//
|
|
result = await conversationEnricher.EnrichRange(
|
|
sources: result,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
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();
|
|
}
|
|
|
|
//
|
|
var conversation = await conversationRepositoryService.GetAsync(
|
|
id: conversationId,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (conversation.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.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
|
|
);
|
|
|
|
//
|
|
if (result.HasChild())
|
|
{
|
|
//
|
|
result = await messageEnricher.EnrichRange(
|
|
sources: result,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Getters ...
|
|
/// <summary>
|
|
/// Retrieve Specified Project ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="fillConversations"></param>
|
|
/// <param name="fillConversationMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XAiProjectDto> GetProject(
|
|
Guid id,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (id.IsDefaultGuid())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var result = await projectRepositoryService.GetAsync(
|
|
id: id,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (result.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
// Handle Enrichment ...
|
|
result = await projectEnricher.Enrich(
|
|
source: result,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve Specified Conversation ...
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XAiConversationDto> GetConversation(
|
|
Guid id,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
if (id.IsDefaultGuid())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var result = await conversationRepositoryService.GetAsync(
|
|
id: id,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (result.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
// Handle Enrichment ...
|
|
result = await conversationEnricher.Enrich(
|
|
source: result,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#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>
|
|
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.OwnerId = ownerId;
|
|
item.CreatedOn = DateTime.UtcNow;
|
|
|
|
//
|
|
// Validate Item ...
|
|
if (!item.IsValidForAddOrUpdate())
|
|
{
|
|
XException.InvalidData.Throw();
|
|
}
|
|
}
|
|
|
|
//
|
|
XAiProjectDto result = null;
|
|
var defaultLanguage = appConfiguration.DefaultLanguage;
|
|
|
|
//
|
|
// Create Provided Project ...
|
|
if (hasProject)
|
|
{
|
|
//
|
|
// Add Item for ID Gneneration ...
|
|
result = await projectRepositoryService.AddAsync(
|
|
item: item,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Checking Resources ...
|
|
|
|
//
|
|
// Titles ...
|
|
var titleResource = string.Empty;
|
|
if (!item.TitleResource.IsNullOrDefault() &&
|
|
item.TitleResource.Locales.HasChild())
|
|
{
|
|
//
|
|
// Adding Title Resource Locales ...
|
|
var isDefaultLanguageHandled = false;
|
|
foreach (var trl in item.TitleResource.Locales)
|
|
{
|
|
//
|
|
// Attaching Default Language ...
|
|
if (!isDefaultLanguageHandled &&
|
|
trl.Language.IsNullOrEmpty())
|
|
{
|
|
//
|
|
trl.Language = defaultLanguage;
|
|
isDefaultLanguageHandled = true;
|
|
}
|
|
|
|
//
|
|
// Check Value Exists ...
|
|
if (trl.Value.IsNullOrEmpty())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
var resource = await projectTitleResourceProvider.AddOrUpdateLocale(
|
|
locale: trl,
|
|
owner: ownerId,
|
|
identifier: result.Id,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!resource.IsNullOrDefault() &&
|
|
titleResource.IsNullOrEmpty())
|
|
{
|
|
titleResource = resource.Resource;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Descriptions ...
|
|
var descriptionResource = string.Empty;
|
|
if (!item.DescriptionResource.IsNullOrDefault() &&
|
|
item.DescriptionResource.Locales.HasChild())
|
|
{
|
|
//
|
|
// Adding Description Resource Locales ....
|
|
var isDefaultLanguageHandled = false;
|
|
foreach (var trl in item.DescriptionResource.Locales)
|
|
{
|
|
//
|
|
// Attaching Default Language ...
|
|
if (!isDefaultLanguageHandled &&
|
|
trl.Language.IsNullOrEmpty())
|
|
{
|
|
//
|
|
trl.Language = defaultLanguage;
|
|
isDefaultLanguageHandled = true;
|
|
}
|
|
|
|
//
|
|
// Check Value Exists ...
|
|
if (trl.Value.IsNullOrEmpty())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
var resource = await projectDescriptionResourceProvider.AddOrUpdateLocale(
|
|
locale: trl,
|
|
owner: ownerId,
|
|
identifier: result.Id,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!resource.IsNullOrDefault() &&
|
|
descriptionResource.IsNullOrEmpty())
|
|
{
|
|
descriptionResource = resource.Resource;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Update Data ...
|
|
result.Title = titleResource;
|
|
result.Description = descriptionResource;
|
|
result = await projectRepositoryService.UpdateAsync(
|
|
item: result,
|
|
id: result.Id,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
result = await projectEnricher.Enrich(
|
|
source: result,
|
|
fillConversations: false,
|
|
fillConversationMessages: 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.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();
|
|
}
|
|
|
|
//
|
|
// Handle Enrichment ...
|
|
result = await Enrich(
|
|
source: result,
|
|
fillConversations: false,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create an AI Conversation ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="item"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XAiConversationDto> CreateConversation(
|
|
string ownerId,
|
|
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.OwnerId = ownerId;
|
|
item.ProjectId = project.Id;
|
|
item.CreatedOn = DateTime.UtcNow;
|
|
|
|
//
|
|
// Validate Item ...
|
|
if (!item.IsValidForAddOrUpdate())
|
|
{
|
|
XException.InvalidData.Throw();
|
|
}
|
|
}
|
|
|
|
//
|
|
XAiConversationDto result = null;
|
|
var defaultLanguage = appConfiguration.DefaultLanguage;
|
|
|
|
//
|
|
// Create Provided Conversation ...
|
|
if (hasConversation)
|
|
{
|
|
//
|
|
// Add Item for ID Gneneration ...
|
|
result = await conversationRepositoryService.AddAsync(
|
|
item: item,
|
|
saveChanges: true,
|
|
// fillMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
// Checking Resources ...
|
|
|
|
//
|
|
// Titles ...
|
|
var titleResource = string.Empty;
|
|
if (!item.TitleResource.IsNullOrDefault() &&
|
|
item.TitleResource.Locales.HasChild())
|
|
{
|
|
//
|
|
// Adding Title Resource Locales ...
|
|
var isDefaultLanguageHandled = false;
|
|
foreach (var trl in item.TitleResource.Locales)
|
|
{
|
|
//
|
|
// Attaching Default Language ...
|
|
if (!isDefaultLanguageHandled &&
|
|
trl.Language.IsNullOrEmpty())
|
|
{
|
|
//
|
|
trl.Language = defaultLanguage;
|
|
isDefaultLanguageHandled = true;
|
|
}
|
|
|
|
//
|
|
// Check Value Exists ...
|
|
if (trl.Value.IsNullOrEmpty())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
var resource = await conversationTitleResourceProvider.AddOrUpdateLocale(
|
|
locale: trl,
|
|
owner: ownerId,
|
|
identifier: result.Id,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!resource.IsNullOrDefault() &&
|
|
titleResource.IsNullOrEmpty())
|
|
{
|
|
titleResource = resource.Resource;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Update Data ...
|
|
result.Title = titleResource;
|
|
result = await conversationRepositoryService.UpdateAsync(
|
|
item: result,
|
|
id: result.Id,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
result = await conversationEnricher.Enrich(
|
|
source: result,
|
|
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();
|
|
}
|
|
|
|
//
|
|
// Handle Enrichment ...
|
|
result = await Enrich(
|
|
source: result,
|
|
fillMessages: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add Message ...
|
|
/// </summary>
|
|
/// <param name="conversationId"></param>
|
|
/// <param name="item"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
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
|
|
);
|
|
|
|
//
|
|
// Handle Enrichment ...
|
|
if (!result.IsNullOrDefault())
|
|
{
|
|
//
|
|
result = await Enrich(
|
|
source: result,
|
|
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 Defaults ...
|
|
/// <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>
|
|
public async Task<XAiProjectDto> GetDefaultProject(
|
|
string ownerId,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Check Default Project Exists or noit ...
|
|
var isExists = await HasDefaultProject(
|
|
ownerId: ownerId,
|
|
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.ToNormalString())
|
|
);
|
|
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>
|
|
/// 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>
|
|
public 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.HasValue ||
|
|
projectId.Value.IsDefaultGuid()
|
|
)
|
|
{
|
|
//
|
|
project = await GetDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
project = await projectRepositoryService.GetAsync(
|
|
id: projectId.Value,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
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
|
|
);
|
|
}
|
|
|
|
//
|
|
// Check Default Owner Exists or not ...
|
|
var resource = await stringProvider.FindOne(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x =>
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(ownerId.ToString().ToNormalString()) &&
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier.ToNormalString()) &&
|
|
x.TranslatedValue
|
|
.ToNormalString()
|
|
.Contains(XAiDataProviderConstants.XDefaultAiConversationSuffix.ToNormalString())
|
|
);
|
|
if (resource.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
var result = await conversationRepositoryService.FindOneAsync(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x =>
|
|
x.ProjectId == project.Id &&
|
|
x.Title == resource.ResourceTitle
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Query ...
|
|
/// <summary>
|
|
/// Query Projects ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="query"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XQueryResult<XAiProjectDto>> QueryProjects(
|
|
string ownerId,
|
|
XQuery query,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
Expression<Func<XAiProject, bool>> predicate = null;
|
|
if (!ownerId.IsNullOrEmpty())
|
|
{
|
|
predicate = x => x.OwnerId == ownerId;
|
|
}
|
|
|
|
//
|
|
var result = await projectRepositoryService.QueryAsync(
|
|
query: query,
|
|
predicate: predicate,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
if (!result.IsNullOrDefault() &&
|
|
result.Items.HasChild())
|
|
{
|
|
//
|
|
result.Items = [..await EnrichRange(
|
|
sources: result.Items,
|
|
fillConversations: false,
|
|
fillConversationMessages: false,
|
|
cancellationToken: cancellationToken
|
|
)];
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Query Messages ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="conversationId"></param>
|
|
/// <param name="query"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XQueryResult<XAiMessageDto>> QueryMessages(
|
|
string ownerId,
|
|
Guid conversationId,
|
|
XQuery query,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (conversationId.IsDefaultGuid())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Retrieve Conversation ...
|
|
var conversation = await conversationRepositoryService.GetAsync(
|
|
id: conversationId,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (conversation.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
Expression<Func<XAiMessage, bool>> predicate = x =>
|
|
x.ConversationId == conversationId;
|
|
if (!ownerId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
predicate = x =>
|
|
x.OwnerId == ownerId &&
|
|
x.ConversationId == conversationId;
|
|
}
|
|
|
|
//
|
|
var result = await messageRepositoryService.QueryAsync(
|
|
query: query,
|
|
predicate: predicate,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
if (!result.IsNullOrDefault() &&
|
|
result.Items.HasChild())
|
|
{
|
|
//
|
|
result.Items = [..await EnrichRange(
|
|
sources: result.Items,
|
|
cancellationToken: cancellationToken
|
|
)];
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Query McpServers ...
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <param name="predicate"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XQueryResult<XAiMcpServerDto>> QueryMcpServers(
|
|
XQuery query,
|
|
Expression<Func<XAiMcpServer, bool>> predicate = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await mcpServerRepositoryService.QueryAsync(
|
|
query: query,
|
|
predicate: predicate,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
if (!result.IsNullOrDefault() &&
|
|
result.Items.HasChild())
|
|
{
|
|
//
|
|
result.Items = [..await EnrichRange(
|
|
sources: result.Items,
|
|
cancellationToken: cancellationToken
|
|
)];
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Query Conversations ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="query"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XQueryResult<XAiConversationDto>> QueryConversations(
|
|
string ownerId,
|
|
Guid projectId,
|
|
XQuery query,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (projectId.IsDefaultGuid())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Retrieve Project ...
|
|
var project = await projectRepositoryService.GetAsync(
|
|
id: projectId,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
if (project.IsNullOrDefault())
|
|
{
|
|
XException.NotFound.Throw();
|
|
}
|
|
|
|
//
|
|
Expression<Func<XAiConversation, bool>> predicate = x =>
|
|
x.ProjectId == projectId;
|
|
if (!ownerId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
predicate = x =>
|
|
x.OwnerId == ownerId &&
|
|
x.ProjectId == projectId;
|
|
}
|
|
|
|
//
|
|
var result = await conversationRepositoryService.QueryAsync(
|
|
query: query,
|
|
predicate: predicate,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
|
);
|
|
if (!result.IsNullOrDefault() &&
|
|
result.Items.HasChild())
|
|
{
|
|
//
|
|
result.Items = [..await EnrichRange(
|
|
fillMessages: false,
|
|
sources: result.Items,
|
|
cancellationToken: cancellationToken
|
|
)];
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Vectors ...
|
|
/// <summary>
|
|
/// Insert or Update a Single Vector (Matched by Identifier) ...
|
|
/// </summary>
|
|
/// <param name="identifier"></param>
|
|
/// <param name="text"></param>
|
|
/// <param name="embedding"></param>
|
|
/// <param name="metadata"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task UpsertVectorAsync(
|
|
string identifier,
|
|
string text,
|
|
ReadOnlyMemory<float> embedding,
|
|
Dictionary<string, string> metadata = null,
|
|
string type = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (
|
|
embedding.IsEmpty ||
|
|
text.IsNullOrEmpty() ||
|
|
identifier.IsNullOrEmpty()
|
|
)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var exists = await vectorRepository.FindOneAsync(
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
predicate: x => x.Identifier == identifier
|
|
);
|
|
var isExists = !exists.IsNullOrDefault();
|
|
if (isExists)
|
|
{
|
|
//
|
|
exists.Text = text;
|
|
exists.Embedding = embedding.ToJSON();
|
|
exists.Type = type.IsNullOrEmpty() ? exists.Type : type;
|
|
exists.Metadata = metadata.IsNullOrDefault() ? exists.Metadata : metadata.ToJSON();
|
|
}
|
|
else
|
|
{
|
|
//
|
|
exists = new XAiVector
|
|
{
|
|
Text = text,
|
|
Type = type,
|
|
Identifier = identifier,
|
|
Metadata = metadata.ToJSON(),
|
|
Embedding = embedding.ToJSON(),
|
|
};
|
|
}
|
|
|
|
//
|
|
await vectorRepository.AddOrUpdateAsync(
|
|
item: exists,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Search Vectors by Cosine Similarity (Top K) ...
|
|
/// </summary>
|
|
/// <param name="queryEmbedding"></param>
|
|
/// <param name="topK"></param>
|
|
/// <param name="minScore"></param>
|
|
/// <param name="identifierPrefix"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IReadOnlyList<XAiVectorSearchResult>> SearchVectorsAsync(
|
|
ReadOnlyMemory<float> queryEmbedding,
|
|
int topK = 5,
|
|
float minScore = 0f,
|
|
string identifierPrefix = null,
|
|
string type = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (
|
|
topK <= 0 ||
|
|
queryEmbedding.IsEmpty
|
|
)
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
// Normalize ...
|
|
if (type.IsNullOrEmpty())
|
|
{
|
|
type = XAiModelsConstants.XAiDefaultKnowledgeType;
|
|
}
|
|
|
|
//
|
|
// Converts Question Vector to Vector Array ...
|
|
var queryVector = queryEmbedding.ToArray();
|
|
var scoredResult = new List<(XAiVectorSearchResult Result, float Score)>();
|
|
|
|
//
|
|
// Load Candidates (Restricted by Prefix / Type when Provided) ...
|
|
var predicateExp = BuildVectorPredicateExpression(identifierPrefix, type);
|
|
IAsyncEnumerable<XAiVector> candidates;
|
|
if (predicateExp.IsNull())
|
|
{
|
|
//
|
|
candidates = vectorRepository
|
|
.GetAllAsAsyncEnumerable(
|
|
ignoreSoftDeleteds: true,
|
|
orderBuilder: null,
|
|
includeBuilder: null
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
candidates = (await vectorRepository
|
|
.FindManyAsync(
|
|
predicate: predicateExp,
|
|
ignoreSoftDeleteds: true,
|
|
orderBuilder: null,
|
|
includeBuilder: null,
|
|
cancellationToken: cancellationToken
|
|
))
|
|
.ToAsyncEnumerable();
|
|
}
|
|
|
|
//
|
|
await foreach (var vector in candidates.WithCancellation(cancellationToken))
|
|
{
|
|
//
|
|
// Validate Vector ...
|
|
if (vector.Embedding.IsNullOrEmpty())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Ignore Unsame Vectors ...
|
|
var embd = vector.Embedding.AsEmbedding();
|
|
if (
|
|
embd.IsNull() ||
|
|
embd.Length != queryEmbedding.Length
|
|
)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Calculate Cosine Similarity Score ...
|
|
var score = VectorHelper.CosineSimilarity(queryVector, embd);
|
|
if (score < minScore)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
scoredResult.Add((new XAiVectorSearchResult
|
|
{
|
|
//
|
|
Score = score,
|
|
Id = vector.Id,
|
|
Text = vector.Text,
|
|
Type = vector.Type,
|
|
Identifier = vector.Identifier,
|
|
Metadata = vector.Metadata.AsMetadat(),
|
|
}, score));
|
|
}
|
|
|
|
//
|
|
var result = scoredResult
|
|
.OrderByDescending(x => x.Score)
|
|
.Take(topK)
|
|
.Select(x => x.Result)
|
|
.ToList();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Insert or Update a Batch of Vectors (Matched by Identifier) ...
|
|
/// </summary>
|
|
/// <param name="items"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>Count of Stored Vectors</returns>
|
|
public async Task<int> UpsertVectorsAsync(
|
|
IEnumerable<XAiVectorDto> items,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate & Normalize (Last One Wins on Duplicate Identifiers) ...
|
|
var validItems = (items ?? [])
|
|
.Where(x =>
|
|
!x.IsNullOrDefault() &&
|
|
!x.Embedding.IsEmpty &&
|
|
!x.Text.IsNullOrEmpty() &&
|
|
!x.Identifier.IsNullOrEmpty()
|
|
)
|
|
.GroupBy(x => x.Identifier)
|
|
.Select(g => g.Last())
|
|
.ToList();
|
|
if (!validItems.HasChild())
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
//
|
|
// Load Existing Vectors with Same Identifiers ...
|
|
var identifiers = validItems
|
|
.Select(x => x.Identifier)
|
|
.ToList();
|
|
var existings = await vectorRepository.FindManyAsync(
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
predicate: x => identifiers.Contains(x.Identifier)
|
|
);
|
|
var existingMap = (existings ?? [])
|
|
.GroupBy(x => x.Identifier)
|
|
.ToDictionary(g => g.Key, g => g.First());
|
|
|
|
//
|
|
// Split to Insert / Update ...
|
|
var toAdd = new List<XAiVector>();
|
|
var toUpdate = new List<XAiVector>();
|
|
foreach (var item in validItems)
|
|
{
|
|
//
|
|
if (existingMap.TryGetValue(item.Identifier, out var exists))
|
|
{
|
|
//
|
|
exists.Text = item.Text;
|
|
exists.Embedding = item.Embedding.ToEmbedding();
|
|
exists.Type = item.Type.IsNullOrEmpty() ? exists.Type : item.Type;
|
|
exists.Metadata = item.Metadata.IsNullOrDefault() ? exists.Metadata : item.Metadata.ToJSON();
|
|
toUpdate.Add(exists);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
toAdd.Add(new XAiVector
|
|
{
|
|
Text = item.Text,
|
|
Type = item.Type,
|
|
Identifier = item.Identifier,
|
|
Metadata = item.Metadata.ToJSON(),
|
|
Embedding = item.Embedding.ToEmbedding(),
|
|
Id = item.Id.IsDefaultGuid() ? Guid.NewGuid() : item.Id,
|
|
});
|
|
}
|
|
}
|
|
|
|
//
|
|
if (toUpdate.HasChild())
|
|
{
|
|
await vectorRepository.UpdateRangeAsync(
|
|
items: toUpdate,
|
|
saveChanges: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
if (toAdd.HasChild())
|
|
{
|
|
await vectorRepository.AddRangeAsync(
|
|
items: toAdd,
|
|
saveChanges: false,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
|
|
//
|
|
await vectorRepository.SaveChangesAsync(cancellationToken);
|
|
|
|
//
|
|
var result = toAdd.Count + toUpdate.Count;
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load Vectors whose Identifier Starts with Specified Prefix ...
|
|
/// </summary>
|
|
/// <param name="identifierPrefix"></param>
|
|
/// <param name="includeEmbedding"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IReadOnlyList<XAiVectorDto>> LoadVectorsAsync(
|
|
string identifierPrefix,
|
|
bool includeEmbedding = false,
|
|
string type = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (identifierPrefix.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var vectors = await vectorRepository.FindManyAsync(
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
predicate: BuildVectorPredicateExpression(identifierPrefix, type)
|
|
);
|
|
|
|
//
|
|
var result = (vectors ?? [])
|
|
.Select(v => new XAiVectorDto
|
|
{
|
|
Id = v.Id,
|
|
Text = v.Text,
|
|
Type = v.Type,
|
|
Identifier = v.Identifier,
|
|
Metadata = v.Metadata.AsMetadat(),
|
|
Embedding = includeEmbedding ? v.Embedding.AsEmbedding() : null,
|
|
})
|
|
.ToList();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove Vectors whose Identifier Starts with Specified Prefix ...
|
|
/// </summary>
|
|
/// <param name="identifierPrefix"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>Count of Removed Vectors</returns>
|
|
public async Task<int> RemoveVectorsAsync(
|
|
string identifierPrefix,
|
|
string type = null,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (identifierPrefix.IsNullOrEmpty())
|
|
{
|
|
XException.InvalidArgs.Throw();
|
|
}
|
|
|
|
//
|
|
var vectors = await vectorRepository.FindManyAsync(
|
|
ignoreSoftDeleteds: true,
|
|
cancellationToken: cancellationToken,
|
|
predicate: BuildVectorPredicateExpression(identifierPrefix, type)
|
|
);
|
|
var toRemove = (vectors ?? []).ToList();
|
|
if (!toRemove.HasChild())
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
//
|
|
// Hard Delete (Vectors are Disposable Data) ...
|
|
await vectorRepository.RemoveRangeAsync(
|
|
items: toRemove,
|
|
softDelete: false,
|
|
saveChanges: true,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
var result = toRemove.Count;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XAiVectorDto> Enrich(
|
|
XAiVectorDto source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await vectorEnricher.Enrich(
|
|
source: source,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XAiVectorDto> Enrich(
|
|
XAiVector source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await vectorEnricher.Enrich(
|
|
source: source,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XAiMessageDto> Enrich(
|
|
XAiMessageDto source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await messageEnricher.Enrich(
|
|
source: source,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
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 async Task<XAiProjectDto> Enrich(
|
|
XAiProjectDto source,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await projectEnricher.Enrich(
|
|
source: source,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XAiMcpServerDto> Enrich(
|
|
XAiMcpServerDto source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await mcpServerEnricher.Enrich(
|
|
source: source,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<XAiConversationDto> Enrich(
|
|
XAiConversationDto source,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await conversationEnricher.Enrich(
|
|
source: source,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
|
IEnumerable<XAiVector> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await vectorEnricher.EnrichRange(
|
|
sources: sources,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
|
IEnumerable<XAiVectorDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await vectorEnricher.EnrichRange(
|
|
sources: sources,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
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 async Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
|
IEnumerable<XAiProjectDto> sources,
|
|
bool fillConversations = false,
|
|
bool fillConversationMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await projectEnricher.EnrichRange(
|
|
sources: sources,
|
|
fillConversations: fillConversations,
|
|
cancellationToken: cancellationToken,
|
|
fillConversationMessages: fillConversationMessages
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiMessageDto>> EnrichRange(
|
|
IEnumerable<XAiMessageDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await messageEnricher.EnrichRange(
|
|
sources: sources,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
|
IEnumerable<XAiMcpServerDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await mcpServerEnricher.EnrichRange(
|
|
sources: sources,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="fillMessages"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
|
IEnumerable<XAiConversationDto> sources,
|
|
bool fillMessages = false,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = await conversationEnricher.EnrichRange(
|
|
sources: sources,
|
|
fillMessages: fillMessages,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
#region Private ...
|
|
/// <summary>
|
|
/// Check Default Project Exists or not ...
|
|
/// </summary>
|
|
/// <param name="ownerId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
private async Task<bool> HasDefaultProject(
|
|
string ownerId,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Validate Args ...
|
|
var result = !ownerId.IsNullOrEmpty();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Default Owner Exists or not ...
|
|
var defaultProjectResource = 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.ToNormalString())
|
|
);
|
|
result = !defaultProjectResource.IsNullOrDefault();
|
|
|
|
//
|
|
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.HasValue ||
|
|
projectId.Value.IsDefaultGuid()
|
|
)
|
|
{
|
|
//
|
|
project = await GetDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
project = await projectRepositoryService.GetAsync(
|
|
id: projectId.Value,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
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.ToString().ToNormalString()) &&
|
|
x.ResourceTitle
|
|
.ToNormalString()
|
|
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier.ToNormalString()) &&
|
|
x.TranslatedValue
|
|
.ToNormalString()
|
|
.Contains(XAiDataProviderConstants.XDefaultAiConversationSuffix.ToNormalString())
|
|
);
|
|
result = !resource.IsNullOrDefault();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
var defaultConversation = await conversationRepositoryService.FindOneAsync(
|
|
cancellationToken: cancellationToken,
|
|
predicate: x =>
|
|
x.ProjectId == project.Id &&
|
|
x.Title == resource.ResourceTitle
|
|
);
|
|
result = !defaultConversation.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.HasValue ||
|
|
projectId.Value.IsDefaultGuid()
|
|
)
|
|
{
|
|
//
|
|
project = await GetDefaultProject(
|
|
ownerId: ownerId,
|
|
connectionId: connectionId,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
project = await projectRepositoryService.GetAsync(
|
|
id: projectId.Value,
|
|
includeBuilder: null,
|
|
ignoreSoftDeleteds: true,
|
|
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>
|
|
/// 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 { }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Build Database Predicate Expression for Vectors by Optional Identifier Prefix and Type ...
|
|
/// Returns null when no Filter Provided ...
|
|
/// </summary>
|
|
/// <param name="identifierPrefix"></param>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
private Expression<Func<XAiVector, bool>> BuildVectorPredicateExpression(
|
|
string identifierPrefix,
|
|
string type
|
|
)
|
|
{
|
|
//
|
|
Expression<Func<XAiVector, bool>> result = null;
|
|
|
|
//
|
|
var hasType = !type.IsNullOrEmpty();
|
|
var hasPrefix = !identifierPrefix.IsNullOrEmpty();
|
|
|
|
//
|
|
if (hasPrefix && hasType)
|
|
{
|
|
//
|
|
result = x => x.Identifier
|
|
.StartsWith(identifierPrefix) && x.Type == type;
|
|
}
|
|
else if (hasPrefix)
|
|
{
|
|
//
|
|
result = x => x.Identifier
|
|
.StartsWith(identifierPrefix);
|
|
}
|
|
else if (hasType)
|
|
{
|
|
result = x => x.Type == type;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\XAiMcpServerEntityRegisterar .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 XAiMcpServerEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
|
|
{
|
|
public XAiMcpServerEntityRegisterar()
|
|
: base(nameof(XAiMcpServerEntityRegisterar))
|
|
{
|
|
//
|
|
// Add Entity ...
|
|
AddEntity<XAiMcpServer, Guid>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure Entities ...
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
|
{
|
|
//
|
|
// Configure Entity Using Provided ...
|
|
modelBuilder
|
|
.ApplyConfigurationsFromAssembly(typeof(XAiMcpServerEntityConfiguration).Assembly);
|
|
|
|
//
|
|
base.ConfigureEntities(modelBuilder);
|
|
}
|
|
}
|
|
}
|
|
|
|
### 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\XAiVectorEntityRegisterar.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 XAiVectorEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
|
|
{
|
|
public XAiVectorEntityRegisterar()
|
|
: base(nameof(XAiVectorEntityRegisterar))
|
|
{
|
|
//
|
|
// Add Entity ...
|
|
AddEntity<XAiVector, Guid>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure Entities ...
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
|
{
|
|
//
|
|
// Configure Entity Using Provided ...
|
|
modelBuilder
|
|
.ApplyConfigurationsFromAssembly(typeof(XAiVectorEntityConfiguration).Assembly);
|
|
|
|
//
|
|
base.ConfigureEntities(modelBuilder);
|
|
}
|
|
}
|
|
}
|
|
|
|
### 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\XAiMcpServerDtoHub.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 XAiMcpServerDtoHub : XBaseDtoHub<XAiMcpServer, XAiMcpServerDto, Guid>, IXAiMcpServerDtoHub
|
|
{
|
|
public XAiMcpServerDtoHub(
|
|
ILogger<XAiMcpServerDtoHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiMcpServerRepositoryService.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xDataService.Providers;
|
|
using xAiModels.Configurations;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiMcpServerRepositoryService : XBaseRepositoryService<XAiMcpServer, XAiMcpServerDto, Guid>, IXAiMcpServerRepositoryService
|
|
{
|
|
private readonly IXAiMcpServerEnricher enricher;
|
|
private readonly IXAiMcpServerRepository repository;
|
|
|
|
public XAiMcpServerRepositoryService(
|
|
IXAiMcpServerRepository repository,
|
|
IXAiMcpServerEnricher enricher
|
|
) : base(repository, mapperProfiles: [new XAiModelMappersProfile()])
|
|
{
|
|
this.enricher = enricher;
|
|
this.repository = repository;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiMcpServerServiceProvider.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 XAiMcpServerServiceProvider : XBaseDtoProvider<XAiMcpServer, XAiMcpServerDto, Guid, XAiMcpServerDtoHub>, IXAiMcpServerServiceProvider
|
|
{
|
|
public XAiMcpServerServiceProvider(
|
|
IHubContext<XAiMcpServerDtoHub> hub,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXAiMcpServerRepositoryService 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\Dtos\XAiVectorDtoHub.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 XAiVectorDtoHub : XBaseDtoHub<XAiVector, XAiVectorDto, Guid>, IXAiVectorDtoHub
|
|
{
|
|
public XAiVectorDtoHub(
|
|
ILogger<XAiVectorDtoHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiVectorRepositoryService.cs
|
|
|
|
using System;
|
|
using xAiModels.Models.Dtos;
|
|
using xDataService.Providers;
|
|
using xAiModels.Configurations;
|
|
using xAiModels.Interfaces.Dtos;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Dtos
|
|
{
|
|
public class XAiVectorRepositoryService : XBaseRepositoryService<XAiVector, XAiVectorDto, Guid>, IXAiVectorRepositoryService
|
|
{
|
|
public XAiVectorRepositoryService(
|
|
IXAiVectorRepository repository
|
|
) : base(
|
|
repository,
|
|
mapperProfiles:
|
|
[
|
|
new XAiModelMappersProfile()
|
|
]
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Dtos\XAiVectorServiceProvider.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 XAiVectorServiceProvider : XBaseDtoProvider<XAiVector, XAiVectorDto, Guid, XAiVectorDtoHub>, IXAiVectorServiceProvider
|
|
{
|
|
public XAiVectorServiceProvider(
|
|
IHubContext<XAiVectorDtoHub> hub,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXAiVectorRepositoryService 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.ProjectTitle = projectTitleResource.Resource;
|
|
result.ProjectDescriptionResource = projectDescriptionResource;
|
|
result.ProjectDescription = projectDescriptionResource.Resource;
|
|
|
|
//
|
|
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\XAiMcpServerEnricher.cs
|
|
|
|
using System.Linq;
|
|
using xModels.Dtos;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xIdentityService.Interfaces;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
|
|
namespace xAiModels.Providers.Enrichers
|
|
{
|
|
public class XAiMcpServerEnricher : IXAiMcpServerEnricher
|
|
{
|
|
private readonly IXPersonService personService;
|
|
|
|
public XAiMcpServerEnricher(
|
|
IXPersonService personService
|
|
)
|
|
{
|
|
this.personService = personService;
|
|
}
|
|
|
|
public virtual async Task<XAiMcpServerDto> Enrich(
|
|
XAiMcpServer source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var result = source.MapConvert<XAiMcpServerDto, XAiMcpServer>();
|
|
result = await Enrich(
|
|
source: result,
|
|
cancellationToken: cancellationToken
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public virtual async Task<XAiMcpServerDto> Enrich(
|
|
XAiMcpServerDto source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
XPersonDto owner = null;
|
|
if (!source.OwnerId.IsNullOrEmpty())
|
|
{
|
|
owner = await personService.GetPerson(source.OwnerId);
|
|
}
|
|
|
|
//
|
|
var result = source.MapConvert<XAiMcpServerDto, XAiMcpServerDto>();
|
|
result.Owner = owner;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public virtual async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
|
IEnumerable<XAiMcpServer> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
var tasks = sources.Select(x => Enrich(x, cancellationToken));
|
|
return await Task.WhenAll(tasks);
|
|
}
|
|
|
|
public virtual async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
|
IEnumerable<XAiMcpServerDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
var tasks = sources.Select(x => Enrich(x, cancellationToken));
|
|
return await Task.WhenAll(tasks);
|
|
}
|
|
}
|
|
}
|
|
|
|
### 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 IXPersonService personService;
|
|
private readonly IXIdentityProvider identityProvider;
|
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
|
|
|
public XAiMessageEnricher(
|
|
IXPersonService personService,
|
|
IXIdentityProvider identityProvider,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider
|
|
)
|
|
{
|
|
this.personService = personService;
|
|
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())
|
|
{
|
|
owner = await personService.GetPerson(source.OwnerId);
|
|
}
|
|
|
|
//
|
|
// 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 xAiModels.Interfaces.Entities;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
|
|
namespace xAiModels.Providers.Enrichers
|
|
{
|
|
public class XAiProjectEnricher : IXAiProjectEnricher
|
|
{
|
|
private readonly IXPersonService personService;
|
|
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(
|
|
IXPersonService personService,
|
|
IXIdentityProvider identityProvider,
|
|
IXAiMessageRepository messageRepository,
|
|
IXAiConversationRepository conversationRepository,
|
|
IXAiProjectTitleResourceProvider projectTitleResourceProvider,
|
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider,
|
|
IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider
|
|
)
|
|
{
|
|
//
|
|
this.personService = personService;
|
|
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())
|
|
{
|
|
owner = await personService.GetPerson(source.OwnerId);
|
|
}
|
|
|
|
//
|
|
// 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\Enrichers\XAiVectorEnricher.cs
|
|
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using xCommons.Extensions;
|
|
using xAiModels.Extensions;
|
|
using xAiModels.Models.Dtos;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xAiModels.Interfaces.Enrichers;
|
|
|
|
namespace xAiModels.Providers.Enrichers
|
|
{
|
|
public class XAiVectorEnricher : IXAiVectorEnricher
|
|
{
|
|
public XAiVectorEnricher()
|
|
{ }
|
|
|
|
//
|
|
#region Enrichers ...
|
|
/// <summary>
|
|
/// Enrich Specified Item ...
|
|
/// </summary>
|
|
/// <param name="source"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<XAiVectorDto> Enrich(
|
|
XAiVector source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Mapping Default ...
|
|
var result = source.MapConvert<XAiVectorDto, XAiVector>();
|
|
|
|
//
|
|
// Here we Converts Embeddings ...
|
|
result.Metadata = source.Metadata.AsMetadat();
|
|
result.Embedding = source.Embedding.AsEmbedding();
|
|
|
|
//
|
|
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<XAiVectorDto> Enrich(
|
|
XAiVectorDto source,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
// Currently no additional enrichment needed for XAiVector
|
|
// This can be extended in the future if needed
|
|
return await Task.FromResult(source);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enrich Specified Items ...
|
|
/// </summary>
|
|
/// <param name="sources"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public virtual async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
|
IEnumerable<XAiVector> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
cancellationToken: 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<XAiVectorDto>> EnrichRange(
|
|
IEnumerable<XAiVectorDto> sources,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var tasks = sources
|
|
.Select(x => Enrich(
|
|
source: x,
|
|
cancellationToken: cancellationToken
|
|
));
|
|
|
|
//
|
|
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\XAiMcpServerEFRepository.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 XAiMcpServerEFRepository<TContext> : XBaseEFRepository<XAiMcpServer, Guid, TContext>, IXAiMcpServerRepository
|
|
where TContext : XDbContext
|
|
{
|
|
public XAiMcpServerEFRepository(
|
|
IXUnitOfWorks<TContext> unitOfWorks,
|
|
XDataServiceConfiguration configuration,
|
|
IXAiMcpServerKeyGenerator keyGenerator = null,
|
|
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
|
|
) : base(unitOfWorks, configuration, keyGenerator, baseRepositoryEvents)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMcpServerEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMcpServerEntityHub : XBaseEntityHub<XAiMcpServer, Guid>, IXAiMcpServerEntityHub
|
|
{
|
|
public XAiMcpServerEntityHub(
|
|
ILogger<XAiMcpServerEntityHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMcpServerInMemoryRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMcpServerInMemoryRepository : XBaseInMemoryRepository<XAiMcpServer, Guid>, IXAiMcpServerRepository
|
|
{
|
|
public XAiMcpServerInMemoryRepository(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiMcpServerKeyGenerator keyGenerator = null,
|
|
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
|
|
) : base(configuration, keyGenerator, baseRepositoryEvents)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMcpServerKeyGenerator.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMcpServerKeyGenerator : XGuidKeyGenerator<XAiMcpServer>, IXAiMcpServerKeyGenerator
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMcpServerMongoRepository.cs
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using xAiModels.Interfaces.Entities;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xDataService.Providers;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMcpServerMongoRepository : XBaseMongoRepository<XAiMcpServer, Guid>, IXAiMcpServerRepository
|
|
{
|
|
public XAiMcpServerMongoRepository(
|
|
XDataBaseConfiguration dbConfiguration,
|
|
XDataServiceConfiguration configuration,
|
|
string collectionName = null,
|
|
IXAiMcpServerKeyGenerator keyGenerator = null,
|
|
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
|
|
) : base(dbConfiguration, configuration, collectionName, keyGenerator, baseRepositoryEvents)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMcpServerRepositoryEvents.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiMcpServerRepositoryEvents : XBaseRepositoryEvents<XAiMcpServer>, IXAiMcpServerRepositoryEvents
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMcpServerRepositoryProvider.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 XAiMcpServerRepositoryProvider : XBaseEntityProvider<XAiMcpServer, Guid, XAiMcpServerEntityHub>, IXAiMcpServerRepositoryProvider
|
|
{
|
|
public XAiMcpServerRepositoryProvider(
|
|
IHubContext<XAiMcpServerEntityHub> hub,
|
|
IXAiMcpServerRepository repository,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(hub, repository, dataConfiguration, identityProvider)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiMcpServerSeederBase.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public abstract class XAiMcpServerSeederBase : XBaseDbSeeder<XAiMcpServer, Guid>, IXAiMcpServerSeeder
|
|
{
|
|
protected XAiMcpServerSeederBase(
|
|
string entity,
|
|
string database,
|
|
IXAiMcpServerRepository 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\Entities\XAiVectorEFRepository.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 XAiVectorEFRepository<TContext> : XBaseEFRepository<XAiVector, Guid, TContext>, IXAiVectorRepository
|
|
where TContext : XDbContext
|
|
{
|
|
public XAiVectorEFRepository(
|
|
IXUnitOfWorks<TContext> unitOfWorks,
|
|
XDataServiceConfiguration configuration,
|
|
IXAiVectorKeyGenerator keyGenerator = null,
|
|
IXAiVectorRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
unitOfWorks,
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiVectorEntityHub.cs
|
|
|
|
using System;
|
|
using xPushService.Base;
|
|
using xAiModels.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiVectorEntityHub : XBaseEntityHub<XAiVector, Guid>, IXAiVectorEntityHub
|
|
{
|
|
public XAiVectorEntityHub(
|
|
ILogger<XAiVectorEntityHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiVectorInMemoryRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiVectorInMemoryRepository : XBaseInMemoryRepository<XAiVector, Guid>, IXAiVectorRepository
|
|
{
|
|
public XAiVectorInMemoryRepository(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiVectorKeyGenerator keyGenerator = null,
|
|
IXAiVectorRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiVectorKeyGenerator.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiVectorKeyGenerator : XGuidKeyGenerator<XAiVector>, IXAiVectorKeyGenerator
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiVectorMongoRepository.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiVectorMongoRepository : XBaseMongoRepository<XAiVector, Guid>, IXAiVectorRepository
|
|
{
|
|
public XAiVectorMongoRepository(
|
|
XDataBaseConfiguration dbConfiguration,
|
|
XDataServiceConfiguration configuration,
|
|
string collectionName = null,
|
|
IXAiVectorKeyGenerator keyGenerator = null,
|
|
IXAiVectorRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
dbConfiguration,
|
|
configuration,
|
|
collectionName,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiVectorRepositoryEvents.cs
|
|
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public class XAiVectorRepositoryEvents : XBaseRepositoryEvents<XAiVector>, IXAiVectorRepositoryEvents
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiVectorRepositoryProvider.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 XAiVectorRepositoryProvider : XBaseEntityProvider<XAiVector, Guid, XAiVectorEntityHub>, IXAiVectorRepositoryProvider
|
|
{
|
|
public XAiVectorRepositoryProvider(
|
|
IHubContext<XAiVectorEntityHub> hub,
|
|
IXAiVectorRepository repository,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
repository,
|
|
dataConfiguration,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\Entities\XAiVectorSeederBase.cs
|
|
|
|
using System;
|
|
using xDataService.Providers;
|
|
using xAiModels.Models.Entities;
|
|
using xDataService.Configuration;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.Entities
|
|
{
|
|
public abstract class XAiVectorSeederBase : XBaseDbSeeder<XAiVector, Guid>, IXAiVectorSeeder
|
|
{
|
|
protected XAiVectorSeederBase(
|
|
string entity,
|
|
string database,
|
|
IXAiVectorRepository 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\XAiMcpServerGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiMcpServerGraphQLTypeHelper : XBaseGraphQLTypeHelper<XAiMcpServer, Guid>, IXAiMcpServerGraphQLTypeHelper
|
|
{
|
|
public override string GetInQueryCollectionName()
|
|
{
|
|
return XAiModelsConstants.XAiMcpServerCollectionName;
|
|
}
|
|
|
|
public override string GetInQuerySingleName()
|
|
{
|
|
return XAiModelsConstants.XAiMcpServerSingleName;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiMcpServerGraphQuery.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 XAiMcpServerGraphQuery : XBaseGraphQLQuery<XAiMcpServer, Guid, XAiMcpServerGraphType, GuidGraphType>
|
|
{
|
|
public XAiMcpServerGraphQuery(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiMcpServerRepository repository,
|
|
IXAiMcpServerGraphQLTypeHelper helper
|
|
) : base(
|
|
configuration,
|
|
repository,
|
|
helper
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiMcpServerGraphSchema.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiMcpServerGraphSchema : Schema
|
|
{
|
|
public XAiMcpServerGraphSchema(IServiceProvider services) : base(services)
|
|
{
|
|
Query = (XAiMcpServerGraphQuery)services.GetService(typeof(XAiMcpServerGraphQuery));
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiMcpServerGraphType.cs
|
|
|
|
using System;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiMcpServerGraphType: XBaseGraphObjectType<XAiMcpServer, Guid>
|
|
{
|
|
public XAiMcpServerGraphType() : base()
|
|
{
|
|
Field(x => x.Name);
|
|
Field(x => x.Enabled);
|
|
Field(x => x.OwnerId);
|
|
Field(x => x.Headers);
|
|
Field(x => x.Endpoint);
|
|
Field(x => x.CreatedOn);
|
|
Field(x => x.UpdatedAt);
|
|
Field(x => x.Description);
|
|
Field(x => x.TimeoutSeconds);
|
|
Field(x => x.EnvironmentVariables);
|
|
}
|
|
}
|
|
}
|
|
|
|
### 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\GraphQL\XAiVectorGraphQLTypeHelper.cs
|
|
|
|
using System;
|
|
using xAiModels.Constants;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
using xAiModels.Interfaces.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiVectorGraphQLTypeHelper : XBaseGraphQLTypeHelper<XAiVector, Guid>, IXAiVectorGraphQLTypeHelper
|
|
{
|
|
public override string GetInQueryCollectionName()
|
|
{
|
|
return XAiModelsConstants.XAiVectorCollectionName;
|
|
}
|
|
|
|
public override string GetInQuerySingleName()
|
|
{
|
|
return XAiModelsConstants.XAiVectorSingleName;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiVectorGraphQuery.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 XAiVectorGraphQuery : XBaseGraphQLQuery<XAiVector, Guid, XAiVectorGraphType, GuidGraphType>
|
|
{
|
|
public XAiVectorGraphQuery(
|
|
XDataServiceConfiguration configuration,
|
|
IXAiVectorRepository repository,
|
|
IXAiVectorGraphQLTypeHelper helper
|
|
) : base(
|
|
configuration,
|
|
repository,
|
|
helper
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiVectorGraphSchema.cs
|
|
|
|
using System;
|
|
using GraphQL.Types;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiVectorGraphSchema : Schema
|
|
{
|
|
public XAiVectorGraphSchema(IServiceProvider services) : base(services)
|
|
{
|
|
Query = (XAiVectorGraphQuery)services.GetService(typeof(XAiVectorGraphQuery));
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Providers\GraphQL\XAiVectorGraphType.cs
|
|
|
|
using System;
|
|
using xDataService.GraphQL;
|
|
using xAiModels.Models.Entities;
|
|
|
|
namespace xAiModels.Providers.GraphQL
|
|
{
|
|
public class XAiVectorGraphType : XBaseGraphObjectType<XAiVector, Guid>
|
|
{
|
|
public XAiVectorGraphType() : base()
|
|
{
|
|
Field(x => x.Text);
|
|
Field(x => x.Metadata);
|
|
Field(x => x.Embedding);
|
|
}
|
|
}
|
|
}
|
|
|
|
### 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 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
|
|
|
|
//
|
|
#region XAiMcpServer ...
|
|
/// <summary>
|
|
/// Notify a New Item Created ...
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
public async Task McpServerCreated(
|
|
XAiMcpServerDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.McpServerCreated.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 McpServerRemoved(
|
|
XAiMcpServerDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.McpServerRemoved.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 McpServerUpdated(
|
|
XAiMcpServerDto item,
|
|
CancellationToken cancellationToken = default
|
|
)
|
|
{
|
|
//
|
|
var connectionId = Context.ConnectionId;
|
|
if (!connectionId.IsNullOrEmpty())
|
|
{
|
|
//
|
|
await Clients
|
|
.AllExcept(connectionId)
|
|
.SendAsync(
|
|
XAiDataProviderHubActions.McpServerUpdated.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
|
|
}
|
|
}
|