### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Attributes\XAiMcpToolAttribute.cs
using System;
namespace xAiModels.Attributes
{
///
/// Decorate and Describe Specified MCP Tool to LLM ...
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class XAiMcpToolAttribute : Attribute
{
///
/// Tools Unique Name (Default: Method Name) ...
///
///
public string Name { get; }
///
/// Tools Description for LLM ...
///
///
public string Description { get; set; }
///
/// Specify it's Required to Authenticated or not ...
///
///
public bool RequiresAuthentication { get; set; } = false;
///
/// Authorization and Policiy ...
///
///
public string RequiredPolicy { get; set; } = string.Empty;
public XAiMcpToolAttribute(string name = null)
{
Name = name;
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Attributes\XAiMcpToolParamAttribute.cs
using System;
namespace xAiModels.Attributes
{
///
/// Describe Specific Tools Parameter Metadata ...
///
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public sealed class XAiMcpToolParamAttribute : Attribute
{
///
/// Parameter Name in JSON (Default Parameter Name) ...
///
///
public string Name { get; }
///
/// Describe Parameter to LLM ...
///
///
public string Description { get; set; }
///
/// Specified this Parameter is Required or not (Default is true) ...
///
///
public bool Required { get; set; } = true;
public XAiMcpToolParamAttribute(string name = null)
{
Name = name;
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Attributes\XAiMcpToolTypeAttribute.cs
using System;
namespace xAiModels.Attributes
{
///
/// Decorate Tools Classes ...
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class XAiMcpToolTypeAttribute : Attribute { }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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();
//
// XAiVector ...
CreateMap()
.ForMember(x => x.Embedding, opt => opt.Ignore())
.ForMember(x => x.Metadata, opt => opt.Ignore());
CreateMap()
.ForMember(x => x.Embedding, opt => opt.Ignore())
.ForMember(x => x.Metadata, opt => opt.Ignore());
//
// XAiProject ...
CreateMap();
//
CreateMap();
CreateMap();
//
// XAiConversation ...
CreateMap();
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
public override void Configure(EntityTypeBuilder builder)
{
builder.ToTable(XAiModelsConstants.XAiConversationTable);
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
public override void Configure(EntityTypeBuilder builder)
{
builder.ToTable(XAiModelsConstants.XAiMcpServerTable);
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
public override void Configure(EntityTypeBuilder builder)
{
builder.ToTable(XAiModelsConstants.XAiMessageTable);
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
public override void Configure(EntityTypeBuilder builder)
{
builder.ToTable(XAiModelsConstants.XAiProjectTable);
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
public override void Configure(EntityTypeBuilder 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\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Constants\ConfigurationNodeNames.cs
namespace xAiModels.Constants
{
public partial struct ConfigurationNodeNames
{
public const string AI_API_NODE = "AiApiConfiguration";
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiKnowledgeScope.cs
using xExceptions.Attributes;
namespace xAiModels.Constants
{
///
/// Knowledge Base Scope (Where Ingested Vectors are Visible) ...
/// Identifier Layout: "{scopePrefix}/{scopeKey}/{fileName}#{chunkIndex}" (Global has no scopeKey) ...
///
public enum XAiKnowledgeScope
{
///
/// Visible only Inside a Conversation (Key = ConversationId) ...
///
[StringValue(XAiModelsConstants.XAiKnowledgeConversationPrefix)]
Conversation = 0,
///
/// Visible to all Conversations of a Project (Key = ProjectId) ...
///
[StringValue(XAiModelsConstants.XAiKnowledgeProjectPrefix)]
Project = 1,
///
/// Visible to Everyone (Write Requires Admin Role) ...
///
[StringValue(XAiModelsConstants.XAiKnowledgeGlobalPrefix)]
Global = 2,
///
/// Personal Knowledge Base of Owner (Key = UserId) ...
///
[StringValue(XAiModelsConstants.XAiKnowledgeUserPrefix)]
User = 3,
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Constants\XAiModelProviderType.cs
namespace xAiModels.Constants
{
///
/// Specifiy Provider Type ...
///
public enum XAiModelProviderType
{
None,
OpenAI,
Ollama,
DeepSeek,
HuggingFace
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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
{
///
/// Service Registration Extensions Classes ...
///
public static class XDIHelperExtension
{
///
/// Register Service ...
///
///
///
///
public static void AddXAiDataService(
this IServiceCollection services,
XRepositoryType repositoryType,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
)
{
AddAiDataService(
contextType: null,
services: services,
lifeTime: lifeTime,
repositoryType: repositoryType
);
}
///
/// Register Service ...
///
///
///
///
///
public static void AddXAiDataService(
this IServiceCollection services,
XRepositoryType repositoryType,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
)
where TContext : XDbContext
{
AddAiDataService(
services: services,
lifeTime: lifeTime,
contextType: typeof(TContext),
repositoryType: repositoryType
);
}
///
/// Use XSubCategoryService Middleware ...
///
///
///
public static void UseXAiDataService(
this IApplicationBuilder app,
bool isDevelopmentEnvironment = false
)
{
//
#region Using Hubs ...
//
var pushHelper = new XPushServiceHelper();
//
// XAiVector ...
pushHelper.AddHub(XAiModelsConstants.XAiVectorDtoHub);
pushHelper.AddHub(XAiModelsConstants.XAiVectorEntityHub);
//
// XAiMessage ...
pushHelper.AddHub(XAiModelsConstants.XAiMessageDtoHub);
pushHelper.AddHub(XAiModelsConstants.XAiMessageEntityHub);
//
// XAiProject ...
pushHelper.AddHub(XAiModelsConstants.XAiProjectDtoHub);
pushHelper.AddHub(XAiModelsConstants.XAiProjectEntityHub);
//
// XAiMcpServer ...
pushHelper.AddHub(XAiModelsConstants.XAiMcpServerDtoHub);
pushHelper.AddHub(XAiModelsConstants.XAiMcpServerEntityHub);
//
// XAiConversation ...
pushHelper.AddHub(XAiModelsConstants.XAiConversationDtoHub);
pushHelper.AddHub(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;
///
/// a LogTag for Service ...
///
private static string XLogTag = XAiModelsConstants.XAiModelsDILogTag;
///
/// print a log in Console ...
///
///
private static void Log(string message)
{
Console.WriteLine($"{XLogTag} => {message}");
}
///
/// Register Service ...
///
///
///
///
///
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(
args: null,
runtimeType: contextType,
methodName: XAiModelsConstants.GetXAiVectorEFRepositoryDescriptor
);
//
// XAiMessage ...
aiMessageDescriptor = typeof(XAiModelsHelper)
.InvokeGenericMethod(
args: null,
runtimeType: contextType,
methodName: XAiModelsConstants.GetXAiMessageEFRepositoryDescriptor
);
//
// XAiProject ...
aiProjectDescriptor = typeof(XAiModelsHelper)
.InvokeGenericMethod(
args: null,
runtimeType: contextType,
methodName: XAiModelsConstants.GetXAiProjectEFRepositoryDescriptor
);
//
// XAiMcpServer ...
aiMcpServerDescriptor = typeof(XAiModelsHelper)
.InvokeGenericMethod(
args: null,
runtimeType: contextType,
methodName: XAiModelsConstants.GetXAiMcpServerEFRepositoryDescriptor
);
//
// XAiConversation ...
aiConversationDescriptor = typeof(XAiModelsHelper)
.InvokeGenericMethod(
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\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Extensions\ChatResponseExtensions.cs
using xCommons.Extensions;
using Microsoft.Extensions.AI;
namespace xAiModels.Extensions
{
public static class ChatResponseExtensions
{
///
/// Validate a Chat Response ...
///
///
///
public static bool IsValid(this ChatResponse source)
{
//
var result =
source is not null &&
!source.IsNullOrDefault() &&
!string.IsNullOrWhiteSpace(source.Text) &&
source.FinishReason == ChatFinishReason.Stop;
//
return result;
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Extensions\ChatRoleExtensions.cs
using xAiModels.Constants;
using xCommons.Extensions;
using Microsoft.Extensions.AI;
namespace xAiModels.Extensions
{
///
/// Extensions for ChatRole ...
///
public static class ChatRoleExtensions
{
///
/// Normalize an String to Propper Chat Role Value ...
/// >
///
///
///
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;
}
///
/// Get Chat Role Title from Chat Role Class ...
///
///
///
///
public static string GetRole(this ChatRole source)
{
//
var result = source.Value
.GetChatRoleTitle();
//
return result;
}
///
/// Generate Chat Role Class Based on role Title ...
///
///
///
public static ChatRole ToChatRole(this string source)
{
//
var role = source.GetChatRoleTitle();
ChatRole result = new ChatRole(role);
//
return result;
}
///
/// Generate Chat Role Class Based on role Title ...
///
///
///
public static ChatRole ToChatRole(this XAiChatRole source)
{
//
var role = source.GetStringValue();
ChatRole result = new ChatRole(role);
//
return result;
}
///
/// Extract Chat Role Enum from Chat Role ...
///
///
///
///
///
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;
}
///
/// Validate an String as Chat Role ...
///
///
///
public static bool IsValid(this string source)
{
//
var result =
source != XAiChatRoles.None &&
source.ToNormalString() != XAiChatRoles.None.ToNormalString();
//
return result;
}
///
/// Validate Role ...
/// >
///
///
///
public static bool IsValid(this XAiChatRole source)
{
//
var result = source != XAiChatRole.None;
return result;
}
///
/// Validate Role ...
/// >
///
///
///
public static bool IsValid(this ChatRole source)
{
//
var role = source.ToChatRole();
var result = role.IsValid();
return result;
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
///
/// Extensions Methods for XAiModels ...
///
public static class XAiModelsExtensions
{
///
/// Validate a Project for Add Or Update ...
///
///
///
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;
}
///
/// Validate a Conversation for Add Or Update ...
///
///
///
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;
}
///
/// Validate a Message for Add Or Update ...
///
///
///
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;
}
///
/// Validate a McpServer for Add Or Update ...
///
///
///
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;
}
///
/// Validate a Model Descriptor ...
///
///
///
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;
}
///
/// Validate Specified Param ...
///
///
///
public static bool IsValid(this XAiPromptParam source)
{
//
var result =
!source.IsNullOrDefault() &&
!source.Name.IsNullOrEmpty() &&
!source.Param.IsNullOrEmpty();
//
return result;
}
///
/// Validate Specified Prompt ...
///
///
///
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;
}
///
/// Validate a Request for Retrieve Response in Controllers ...
///
///
///
public static bool IsValid(this XAiResponseRequest source)
{
//
var result =
!source.IsNullOrDefault() &&
!source.Prompt.IsNullOrEmpty();
//
return result;
}
///
/// Validate a File Extraction Result ...
///
///
///
public static bool IsValid(this XFileExtractionResult source)
{
//
var result =
!source.IsNullOrDefault() &&
(
source.Images.HasChild() ||
!source.Text.IsNullOrEmpty() ||
!source.AudioTranscript.IsNullOrEmpty()
);
return result;
}
///
/// Converts a File Extraction Result to AI Contents ...
///
///
///
public static IList ToAIContents(this XFileExtractionResult source)
{
//
var result = new List();
//
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;
}
///
/// Check a Collection Contains Default Project for Specified Owner or not ...
///
///
///
///
public static bool HasDefaultProject(
this IEnumerable 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;
}
///
/// Check a Collection Contains Default Conversation for Specified Project or not ...
///
///
///
///
///
public static bool HasDefaultConversation(
this IEnumerable 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;
}
///
/// Retrieve Default Project Id from a Collection ...
///
///
///
///
public static Guid GetDafaultProject(
this IEnumerable 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;
}
///
/// Get Default Conversation Id from a Collection Contains ...
///
///
///
///
///
public static Guid GetDefaultConversation(
this IEnumerable 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;
}
///
/// Converts a Message Dto to ChatMessage ...
///
///
///
///
public static ChatMessage ToChatMessages(
this XAiMessageDto source,
IList additionalContents = null
)
{
//
ChatMessage result = null;
//
if (!source.IsNullOrDefault())
{
//
var contents = new List
{
//
// 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;
}
///
/// Add Model Provider API Key ...
///
///
///
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}"
);
}
///
/// Converts To AITools ...
///
///
///
public static IList ToAITools(
this IList source
)
{
//
var result = new List();
//
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\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Extensions\XEmbeddingExtensions.cs
using System;
using xCommons.Extensions;
namespace xAiModels.Extensions
{
public static class XEmbeddingExtensions
{
///
/// Converts String to Embeddings JSON ...
///
///
///
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();
if (!result.HasChild())
{
result = [];
}
//
return result;
}
///
/// Converts ReadOnly Memory to Embedding Representation ...
///
///
///
public static string ToEmbedding(this ReadOnlyMemory source)
{
//
var result = string.Empty;
//
if (!source.IsNull() && !source.IsEmpty)
{
result = source.ToArray().ToJSON();
}
//
return result;
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
///
/// Normalize a Vector ...
///
///
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;
}
}
///
/// Similarity Check ...
///
///
///
///
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\SaherElm\Documents\Projects\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
{
///
/// a Helper Class for Prepare Headers of MCP Client ...
///
public static class XAiMcpHeaderBuilder
{
///
/// Build Headers for MCP Client Connection ...
///
///
///
///
///
///
///
public static Dictionary Build(
XAppConfiguration appConfiguration,
string sessionId = null,
string connectionId = null,
XUserClaimsInfoDto userInfo = null,
string protocolVersion = XAiMcpConstants.XAiMcpProtocol
)
{
//
var headers = new Dictionary
{
//
["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\SaherElm\Documents\Projects\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
{
///
/// Read an SSE Event ...
///
///
///
///
public static async IAsyncEnumerable 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\SaherElm\Documents\Projects\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
> GetXAiConversationEFRepositoryDescriptor()
where TContext : XDbContext
{
//
var result = new XEFRepositoryDescriptor<
XAiConversation,
Guid,
IXAiConversationKeyGenerator,
XAiConversationKeyGenerator,
IXAiConversationRepositoryEvents,
XAiConversationRepositoryEvents,
XAiConversationGraphType,
GuidGraphType,
XAiConversationGraphQuery,
IXAiConversationGraphQLTypeHelper,
XAiConversationGraphQLTypeHelper,
XAiConversationGraphSchema,
IXAiConversationRepository,
XAiConversationEFRepository,
TContext
>();
//
return result;
}
public static XEFRepositoryDescriptor<
XAiConversation,
Guid,
IXAiConversationKeyGenerator,
XAiConversationKeyGenerator,
IXAiConversationRepositoryEvents,
XAiConversationRepositoryEvents,
XAiConversationGraphType,
GuidGraphType,
XAiConversationGraphQuery,
IXAiConversationGraphQLTypeHelper,
XAiConversationGraphQLTypeHelper,
XAiConversationGraphSchema,
IXAiConversationRepository,
XAiConversationEFRepository,
TContext,
IXAiConversationSeeder,
TSeederImplementation
> GetXAiConversationEFRepositoryDescriptor()
where TContext : XDbContext
where TSeederImplementation : XBaseDbSeeder
{
//
var result = new XEFRepositoryDescriptor<
XAiConversation,
Guid,
IXAiConversationKeyGenerator,
XAiConversationKeyGenerator,
IXAiConversationRepositoryEvents,
XAiConversationRepositoryEvents,
XAiConversationGraphType,
GuidGraphType,
XAiConversationGraphQuery,
IXAiConversationGraphQLTypeHelper,
XAiConversationGraphQLTypeHelper,
XAiConversationGraphSchema,
IXAiConversationRepository,
XAiConversationEFRepository,
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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
> GetXAiMessageEFRepositoryDescriptor()
where TContext : XDbContext
{
//
var result = new XEFRepositoryDescriptor<
XAiMessage,
Guid,
IXAiMessageKeyGenerator,
XAiMessageKeyGenerator,
IXAiMessageRepositoryEvents,
XAiMessageRepositoryEvents,
XAiMessageGraphType,
GuidGraphType,
XAiMessageGraphQuery,
IXAiMessageGraphQLTypeHelper,
XAiMessageGraphQLTypeHelper,
XAiMessageGraphSchema,
IXAiMessageRepository,
XAiMessageEFRepository,
TContext
>();
//
return result;
}
public static XEFRepositoryDescriptor<
XAiMessage,
Guid,
IXAiMessageKeyGenerator,
XAiMessageKeyGenerator,
IXAiMessageRepositoryEvents,
XAiMessageRepositoryEvents,
XAiMessageGraphType,
GuidGraphType,
XAiMessageGraphQuery,
IXAiMessageGraphQLTypeHelper,
XAiMessageGraphQLTypeHelper,
XAiMessageGraphSchema,
IXAiMessageRepository,
XAiMessageEFRepository,
TContext,
IXAiMessageSeeder,
TSeederImplementation
> GetXAiMessageEFRepositoryDescriptor()
where TContext : XDbContext
where TSeederImplementation : XBaseDbSeeder
{
//
var result = new XEFRepositoryDescriptor<
XAiMessage,
Guid,
IXAiMessageKeyGenerator,
XAiMessageKeyGenerator,
IXAiMessageRepositoryEvents,
XAiMessageRepositoryEvents,
XAiMessageGraphType,
GuidGraphType,
XAiMessageGraphQuery,
IXAiMessageGraphQLTypeHelper,
XAiMessageGraphQLTypeHelper,
XAiMessageGraphSchema,
IXAiMessageRepository,
XAiMessageEFRepository,
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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
> GetXAiProjectEFRepositoryDescriptor()
where TContext : XDbContext
{
//
var result = new XEFRepositoryDescriptor<
XAiProject,
Guid,
IXAiProjectKeyGenerator,
XAiProjectKeyGenerator,
IXAiProjectRepositoryEvents,
XAiProjectRepositoryEvents,
XAiProjectGraphType,
GuidGraphType,
XAiProjectGraphQuery,
IXAiProjectGraphQLTypeHelper,
XAiProjectGraphQLTypeHelper,
XAiProjectGraphSchema,
IXAiProjectRepository,
XAiProjectEFRepository,
TContext
>();
//
return result;
}
public static XEFRepositoryDescriptor<
XAiProject,
Guid,
IXAiProjectKeyGenerator,
XAiProjectKeyGenerator,
IXAiProjectRepositoryEvents,
XAiProjectRepositoryEvents,
XAiProjectGraphType,
GuidGraphType,
XAiProjectGraphQuery,
IXAiProjectGraphQLTypeHelper,
XAiProjectGraphQLTypeHelper,
XAiProjectGraphSchema,
IXAiProjectRepository,
XAiProjectEFRepository,
TContext,
IXAiProjectSeeder,
TSeederImplementation
> GetXAiProjectEFRepositoryDescriptor()
where TContext : XDbContext
where TSeederImplementation : XBaseDbSeeder
{
//
var result = new XEFRepositoryDescriptor<
XAiProject,
Guid,
IXAiProjectKeyGenerator,
XAiProjectKeyGenerator,
IXAiProjectRepositoryEvents,
XAiProjectRepositoryEvents,
XAiProjectGraphType,
GuidGraphType,
XAiProjectGraphQuery,
IXAiProjectGraphQLTypeHelper,
XAiProjectGraphQLTypeHelper,
XAiProjectGraphSchema,
IXAiProjectRepository,
XAiProjectEFRepository,
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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
> GetXAiVectorEFRepositoryDescriptor()
where TContext : XDbContext
{
//
var result = new XEFRepositoryDescriptor<
XAiVector,
Guid,
IXAiVectorKeyGenerator,
XAiVectorKeyGenerator,
IXAiVectorRepositoryEvents,
XAiVectorRepositoryEvents,
XAiVectorGraphType,
GuidGraphType,
XAiVectorGraphQuery,
IXAiVectorGraphQLTypeHelper,
XAiVectorGraphQLTypeHelper,
XAiVectorGraphSchema,
IXAiVectorRepository,
XAiVectorEFRepository,
TContext
>();
//
return result;
}
public static XEFRepositoryDescriptor<
XAiVector,
Guid,
IXAiVectorKeyGenerator,
XAiVectorKeyGenerator,
IXAiVectorRepositoryEvents,
XAiVectorRepositoryEvents,
XAiVectorGraphType,
GuidGraphType,
XAiVectorGraphQuery,
IXAiVectorGraphQLTypeHelper,
XAiVectorGraphQLTypeHelper,
XAiVectorGraphSchema,
IXAiVectorRepository,
XAiVectorEFRepository,
TContext,
IXAiVectorSeeder,
TSeederImplementation
> GetXAiVectorEFRepositoryDescriptor()
where TContext : XDbContext
where TSeederImplementation : XBaseDbSeeder
{
//
var result = new XEFRepositoryDescriptor<
XAiVector,
Guid,
IXAiVectorKeyGenerator,
XAiVectorKeyGenerator,
IXAiVectorRepositoryEvents,
XAiVectorRepositoryEvents,
XAiVectorGraphType,
GuidGraphType,
XAiVectorGraphQuery,
IXAiVectorGraphQLTypeHelper,
XAiVectorGraphQLTypeHelper,
XAiVectorGraphSchema,
IXAiVectorRepository,
XAiVectorEFRepository,
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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
> GetXAiMcpServerEFRepositoryDescriptor()
where TContext : XDbContext
{
//
var result = new XEFRepositoryDescriptor<
XAiMcpServer,
Guid,
IXAiMcpServerKeyGenerator,
XAiMcpServerKeyGenerator,
IXAiMcpServerRepositoryEvents,
XAiMcpServerRepositoryEvents,
XAiMcpServerGraphType,
GuidGraphType,
XAiMcpServerGraphQuery,
IXAiMcpServerGraphQLTypeHelper,
XAiMcpServerGraphQLTypeHelper,
XAiMcpServerGraphSchema,
IXAiMcpServerRepository,
XAiMcpServerEFRepository,
TContext
>();
//
return result;
}
public static XEFRepositoryDescriptor<
XAiMcpServer,
Guid,
IXAiMcpServerKeyGenerator,
XAiMcpServerKeyGenerator,
IXAiMcpServerRepositoryEvents,
XAiMcpServerRepositoryEvents,
XAiMcpServerGraphType,
GuidGraphType,
XAiMcpServerGraphQuery,
IXAiMcpServerGraphQLTypeHelper,
XAiMcpServerGraphQLTypeHelper,
XAiMcpServerGraphSchema,
IXAiMcpServerRepository,
XAiMcpServerEFRepository,
TContext,
IXAiMcpServerSeeder,
TSeederImplementation
> GetXAiMcpServerEFRepositoryDescriptor()
where TContext : XDbContext
where TSeederImplementation : XBaseDbSeeder
{
//
var result = new XEFRepositoryDescriptor<
XAiMcpServer,
Guid,
IXAiMcpServerKeyGenerator,
XAiMcpServerKeyGenerator,
IXAiMcpServerRepositoryEvents,
XAiMcpServerRepositoryEvents,
XAiMcpServerGraphType,
GuidGraphType,
XAiMcpServerGraphQuery,
IXAiMcpServerGraphQLTypeHelper,
XAiMcpServerGraphQLTypeHelper,
XAiMcpServerGraphSchema,
IXAiMcpServerRepository,
XAiMcpServerEFRepository,
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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()
where TSeederImplementation : XBaseDbSeeder
{
//
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\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\IXAiConversationTitleResourceProvider.cs
using xStringService.Interfaces;
namespace xAiModels.Interfaces
{
public interface IXAiConversationTitleResourceProvider : IXOwnedItemResourceProvider
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
///
/// All Data Manipulation Requirements ...
///
public interface IXAiDataProvider
{
//
#region Getters ...
///
/// Retrieve Specified Project ...
///
///
///
///
///
///
Task GetProject(
Guid id,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Retrieve Specified Conversation ...
///
///
///
///
///
Task GetConversation(
Guid id,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
#endregion
//
#region Loaders ...
///
/// Load Projects List of Specified Owner ...
///
///
///
///
///
///
///
Task> LoadProjects(
string ownerId,
string connectionId = null,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Load List of Conversations for Specified Project ...
///
///
///
///
///
///
Task> LoadConversations(
Guid projectId,
bool fillMessages = false,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Load Messages of Specified Conversation ...
///
///
///
///
Task> LoadMessages(
Guid conversationId,
CancellationToken cancellationToken = default
);
#endregion
//
#region Enrichers ...
///
/// Enrich Specified Item ...
///
///
///
///
///
///
Task Enrich(
XAiProjectDto source,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
///
Task Enrich(
XAiConversationDto source,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
Task Enrich(
XAiMessageDto source,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
#endregion
//
#region Defaults ...
///
/// Retrieve Default Project of Specified Owner ...
/// Create it if not Handled ...
///
///
///
///
///
Task GetDefaultProject(
string ownerId,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Retrieve Default Conversation of Specified Owner ...
/// Create it if not Handled ...
///
///
///
///
///
///
Task GetDefaultConversation(
string ownerId,
Guid? projectId,
string connectionId = null,
CancellationToken cancellationToken = default
);
#endregion
//
#region Creator/Adders ...
///
/// Create Project ...
///
///
///
///
///
///
Task CreateProject(
string ownerId,
XAiProjectDto item = null,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Create Conversation ...
///
///
///
///
///
///
///
Task CreateConversation(
string ownerId,
Guid projectId,
XAiConversationDto item = null,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Add Message ...
///
///
///
///
///
///
Task AddMessage(
Guid conversationId,
XAiMessageDto item,
string connectionId = null,
CancellationToken cancellationToken = default
);
#endregion
//
#region Query ...
///
/// Query Projects ...
///
///
///
///
///
Task> QueryProjects(
string ownerId,
XQuery query,
CancellationToken cancellationToken = default
);
///
/// Query Conversations ...
///
///
///
///
///
///
Task> QueryConversations(
string ownerId,
Guid projectId,
XQuery query,
CancellationToken cancellationToken = default
);
///
/// Query Messages ...
///
///
///
///
///
///
Task> QueryMessages(
string ownerId,
Guid conversationId,
XQuery query,
CancellationToken cancellationToken = default
);
#endregion
//
#region Vectors ...
///
/// Insert or Update a Single Vector (Matched by Identifier) ...
///
///
///
///
///
///
///
///
Task UpsertVectorAsync(
string identifier,
string text,
ReadOnlyMemory embedding,
Dictionary metadata = null,
string type = null,
CancellationToken cancellationToken = default
);
///
/// Insert or Update a Batch of Vectors (Matched by Identifier) ...
///
///
///
/// Count of Stored Vectors
Task UpsertVectorsAsync(
IEnumerable items,
CancellationToken cancellationToken = default
);
///
/// Search Vectors by Cosine Similarity (Top K) ...
///
///
///
///
/// Optional: Restrict Search to Vectors whose Identifier Starts with this Prefix
/// Optional: Restrict Search to Vectors of Specified Type
///
///
Task> SearchVectorsAsync(
ReadOnlyMemory queryEmbedding,
int topK = 5,
float minScore = 0f,
string identifierPrefix = null,
string type = null,
CancellationToken cancellationToken = default
);
///
/// Load Vectors whose Identifier Starts with Specified Prefix ...
///
///
///
/// Optional: Restrict to Vectors of Specified Type
///
///
Task> LoadVectorsAsync(
string identifierPrefix,
bool includeEmbedding = false,
string type = null,
CancellationToken cancellationToken = default
);
///
/// Remove Vectors whose Identifier Starts with Specified Prefix ...
///
///
/// Optional: Restrict to Vectors of Specified Type
///
/// Count of Removed Vectors
Task RemoveVectorsAsync(
string identifierPrefix,
string type = null,
CancellationToken cancellationToken = default
);
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\IXAiProjectDescriptionResourceProvider.cs
using xStringService.Interfaces;
namespace xAiModels.Interfaces
{
public interface IXAiProjectDescriptionResourceProvider : IXOwnedItemResourceProvider
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\IXAiProjectTitleResourceProvider.cs
using xStringService.Interfaces;
namespace xAiModels.Interfaces
{
public interface IXAiProjectTitleResourceProvider : IXOwnedItemResourceProvider
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
//
#region Enrichers ...
///
/// Enrich Specified Item ...
///
///
///
///
///
Task Enrich(
XAiConversation source,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
///
Task Enrich(
XAiConversationDto source,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
//
#region Enrichers ...
///
/// Enrich Specified Item ...
///
///
///
///
Task Enrich(
XAiMessage source,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
Task Enrich(
XAiMessageDto source,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
//
#region Enrichers ...
///
/// Enrich Specified Item ...
///
///
///
///
///
///
Task Enrich(
XAiProject source,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
///
///
Task Enrich(
XAiProjectDto source,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
///
/// Ai Conversation Enricher ...
///
public interface IXAiConversationEnricher
{
//
#region Enrichers ...
///
/// Enrich Specified Item ...
///
///
///
///
///
Task Enrich(
XAiConversation source,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
///
Task Enrich(
XAiConversationDto source,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillMessages = false,
CancellationToken cancellationToken = default
);
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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 Enrich(
XAiMcpServer source,
CancellationToken cancellationToken = default
);
Task Enrich(
XAiMcpServerDto source,
CancellationToken cancellationToken = default
);
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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 ...
///
/// Enrich Specified Item ...
///
///
///
///
Task Enrich(
XAiMessage source,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
Task Enrich(
XAiMessageDto source,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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 ...
///
/// Enrich Specified Item ...
///
///
///
///
///
///
Task Enrich(
XAiProject source,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
///
///
Task Enrich(
XAiProjectDto source,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
bool fillConversations = false,
bool fillConversationMessages = false,
CancellationToken cancellationToken = default
);
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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 ...
///
/// Enrich Specified Item ...
///
///
///
///
Task Enrich(
XAiVector source,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Item ...
///
///
///
///
Task Enrich(
XAiVectorDto source,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
///
/// Enrich Specified Items ...
///
///
///
///
Task> EnrichRange(
IEnumerable sources,
CancellationToken cancellationToken = default
);
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationEntityHub.cs
using System;
using xPushService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiConversationEntityHub : IXBaseEntityHub
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationGraphQLTypeHelper.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiConversationGraphQLTypeHelper : IXBaseGraphQLTypeHelper
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationKeyGenerator.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiConversationKeyGenerator : IXKeyGenerator
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationRepository.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiConversationRepository : IXBaseRepository
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationRepositoryEvents.cs
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiConversationRepositoryEvents : IXBaseRepositoryEvents
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiConversationSeeder.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiConversationSeeder : IXBaseDbSeeder
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerEntityHub.cs
using System;
using xPushService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMcpServerEntityHub : IXBaseEntityHub
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerGraphQLTypeHelper.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMcpServerGraphQLTypeHelper : IXBaseGraphQLTypeHelper
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerKeyGenerator.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMcpServerKeyGenerator : IXKeyGenerator
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerRepository.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMcpServerRepository : IXBaseRepository { }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerRepositoryEvents.cs
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMcpServerRepositoryEvents : IXBaseRepositoryEvents
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMcpServerSeeder.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMcpServerSeeder : IXBaseDbSeeder
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageEntityHub.cs
using System;
using xPushService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMessageEntityHub : IXBaseEntityHub
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageGraphQLTypeHelper.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMessageGraphQLTypeHelper : IXBaseGraphQLTypeHelper
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageKeyGenerator.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMessageKeyGenerator : IXKeyGenerator
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageRepository.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMessageRepository : IXBaseRepository
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageRepositoryEvents.cs
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMessageRepositoryEvents : IXBaseRepositoryEvents
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiMessageSeeder.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiMessageSeeder : IXBaseDbSeeder
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectEntityHub.cs
using System;
using xPushService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiProjectEntityHub : IXBaseEntityHub
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectGraphQLTypeHelper.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiProjectGraphQLTypeHelper : IXBaseGraphQLTypeHelper
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectKeyGenerator.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiProjectKeyGenerator : IXKeyGenerator
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectRepository.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiProjectRepository : IXBaseRepository
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectRepositoryEvents.cs
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiProjectRepositoryEvents : IXBaseRepositoryEvents
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiProjectSeeder.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiProjectSeeder : IXBaseDbSeeder
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorEntityHub.cs
using System;
using xPushService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiVectorEntityHub : IXBaseEntityHub
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorGraphQLTypeHelper.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiVectorGraphQLTypeHelper : IXBaseGraphQLTypeHelper
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorKeyGenerator.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiVectorKeyGenerator : IXKeyGenerator
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorRepository.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiVectorRepository : IXBaseRepository
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorRepositoryEvents.cs
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiVectorRepositoryEvents : IXBaseRepositoryEvents
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Interfaces\Entities\IXAiVectorSeeder.cs
using System;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
namespace xAiModels.Interfaces.Entities
{
public interface IXAiVectorSeeder : IXBaseDbSeeder
{ }
}
### FILE: C:\Users\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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> Execute { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiModelDescriptor.cs
using xAiModels.Constants;
namespace xAiModels.Models
{
///
/// Describe a Provided Model ...
///
public class XAiModelDescriptor
{
///
/// Provider Name ...
///
public string Name { get; set; }
///
/// LLM Provider Url ...
///
public string Url { get; set; }
///
/// Model Name ...
///
public string LLM { get; set; }
///
/// Api Key for Connection ...
///
public string ApiKey { get; set; }
///
/// Specified Model Provider Type ...
///
public XAiModelProviderType Provider { get; set; } = XAiModelProviderType.Ollama;
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiPromptDescriptor.cs
namespace xAiModels.Models
{
///
/// Describe Specified Prompt ...
///
public class XAiPromptDescriptor
{
///
/// Prompt Name ...
///
public string Name { get; set; }
///
/// Prompt Template ...
///
public string Template { get; set; }
///
/// Prompt Description ...
///
public string Description { get; set; }
///
/// Prompt Template Params ...
///
public XAiPromptParam[] Params { get; set; } = [];
}
///
/// Specified a Prompt Param ...
///
public class XAiPromptParam
{
///
/// Param Name ...
///
public string Name { get; set; }
///
/// Param Identifier ...
///
public string Param { get; set; }
///
/// Parma Description ...
///
public string Description { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiResponseRequest.cs
using System;
using xAiModels.Constants;
namespace xAiModels.Models
{
///
/// /Request for a Response in Controllers ...
///
public class XAiResponseRequest
{
///
/// Prompt Text ...
///
public string Prompt { get; set; }
///
/// Knowledge Type ...
///
public string Type { get; set; } = XAiModelsConstants.XAiDefaultKnowledgeType;
///
/// Provided TopK in Vector Searchs ...
///
public int? TopK { get; set; }
///
/// Min Score for Vector Searchs ...
///
public float? MinScore { get; set; }
///
/// Specified Project Id ...
///
public Guid? ProjectId { get; set; }
///
/// Specified Conversation Id ...
///
public Guid? ConversationId { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\XFileExtractionResult.cs
using System.Collections.Generic;
namespace xAiModels.Models
{
///
/// Holds File Extraction Result ...
///
public class XFileExtractionResult
{
///
/// Extracted String Content ...
///
public string Text { get; set; } = string.Empty;
///
/// Extracted Images for Vision Model ...
///
public IList Images { get; set; } = [];
///
/// Extracted Content from Audio File ...
///
public string AudioTranscript { get; set; } = string.Empty;
///
/// Main File Name ...
///
public string FileName { get; set; }
///
/// Main File MIME Type ...
///
public string MimeType { get; set; }
///
/// Specified Fallback done using Images or not ...
///
public bool UsedImageFallback { get; set; } = false;
///
/// Error Message ...
///
public string ErrorMessage { get; set; }
}
///
/// Extracted Image ...
///
public class XExtractedImage
{
///
/// Content as Byte ...
///
public byte[] Bytes { get; set; }
///
/// MIME Type of Image ...
///
public string MimeType { get; set; } = "image/png";
///
/// for PDF Files ...
///
public int? PageNumber { get; set; }
///
/// Describe Image ...
///
public string Description { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\Dtos\XAiConversationDto.cs
using System;
using xModels.Base;
using xModels.Dtos;
using System.Collections.Generic;
namespace xAiModels.Models.Dtos
{
///
/// Conversation Describe ...
///
public class XAiConversationDto : XBaseGuidIDEntityDto
{
///
/// User Identifier ...
///
///
public string OwnerId { get; set; }
///
/// Owner Info ...
///
public virtual XPersonDto Owner { get; set; } = null;
///
/// Conversation Title Resource ID ...
///
public string Title { get; set; }
///
/// All Exists Title Locale Resources ...
///
public virtual XResourceDto TitleResource { get; set; }
///
/// Created Time ...
///
public DateTime CreatedOn { get; set; }
///
/// Updated Time ...
///
public DateTime UpdatedAt { get; set; }
///
/// Conversation Messages ...
///
public virtual IEnumerable Messages { get; set; } = [];
///
/// Project ID ...
///
public Guid ProjectId { get; set; }
///
/// Project Title Resource ID ...
///
public virtual string ProjectTitle { get; set; } = null;
///
/// Project Description Resource ID ...
///
public virtual string ProjectDescription { get; set; } = null;
///
/// Project Title Locale Resources ...
///
public virtual XResourceDto ProjectTitleResource { get; set; }
///
/// Project Description Locale Resources ...
///
public virtual XResourceDto ProjectDescriptionResource { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
///
/// Owner ...
///
public string OwnerId { get; set; }
public virtual XPersonDto Owner { get; set; }
///
/// Specified Which Scope can Use MCP Server ...
///
public XAiMcpServerUsageScope Scope { get; set; } = XAiMcpServerUsageScope.Owner;
///
/// MCP Server Name ...
///
public string Name { get; set; }
///
/// Description ...
///
public string Description { get; set; }
///
/// Enabled or Disabled ...
///
public bool Enabled { get; set; } = true;
///
/// Environment Variables as JSON Object ...
///
public string EnvironmentVariables { get; set; }
///
/// Endpoint to Connect ...
///
public string Endpoint { get; set; }
///
/// Headers List as Json Object ...
///
public string Headers { get; set; }
///
/// Timout Secconds ...
///
public int TimeoutSeconds { get; set; } = 30;
public DateTime CreatedOn { get; set; }
public DateTime UpdatedAt { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
///
/// User Identifier ...
///
///
public string OwnerId { get; set; }
///
/// Owner Info ...
///
public virtual XPersonDto Owner { get; set; } = null;
///
/// Message of Chat ...
///
public string Content { get; set; }
///
/// Role of Message ...
///
public XAiChatRole Role { get; set; }
///
/// Created Time ...
///
public DateTime CreatedOn { get; set; }
///
/// Updated Time ...
///
public DateTime UpdatedAt { get; set; }
///
/// Conversation Id ...
///
public Guid ConversationId { get; set; }
///
/// Conversation Info ...
///
public virtual string ConversationTitle { get; set; } = null;
public virtual XResourceDto ConversationTitleResouce { get; set; } = null;
//
#region Meta Data Property ...
private string _metadata;
///
/// Meta Data of Message ...
///
[NotMapped]
public IDictionary Metadata { get; private set; } = null;
///
/// Meta Data of MEssage in Json ...
///
public string MetaDatas
{
//
get => _metadata;
//
set
{
//
// Converts Json String to Dictionary ...
if (!value.IsNullOrEmpty())
{
Metadata = value.FromJSON>();
}
//
_metadata = value;
}
}
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\Dtos\XAiProjectDto.cs
using System;
using xModels.Base;
using xModels.Dtos;
using System.Collections.Generic;
namespace xAiModels.Models.Dtos
{
///
/// Describe a Project ...
///
public class XAiProjectDto : XBaseGuidIDEntityDto
{
///
/// User Identifier ...
///
///
public string OwnerId { get; set; }
///
/// Owner Info ...
///
public virtual XPersonDto Owner { get; set; } = null;
///
/// Title of Project ...
///
public string Title { get; set; }
///
/// All Exists Title Locale Resources ...
///
public virtual XResourceDto TitleResource { get; set; }
///
/// Description of Project ...
///
public string Description { get; set; }
///
/// All Exists Description Locale Resources ...
///
public virtual XResourceDto DescriptionResource { get; set; }
///
/// a Prompt for Project Start ...
///
public string Prompt { get; set; }
///
/// Created Time ...
///
public DateTime CreatedOn { get; set; }
///
/// Updated Time ...
///
public DateTime UpdatedAt { get; set; }
///
/// Conversations ...
///
public virtual IList Conversations { get; set; } = [];
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\Dtos\XAiVectorDto.cs
using System;
using xModels.Base;
using System.Collections.Generic;
namespace xAiModels.Models.Dtos
{
///
/// Vector DTO for AI Vector data ...
///
public class XAiVectorDto : XBaseGuidIDEntityDto
{
///
/// Text content of the vector ...
///
public string Text { get; set; }
///
/// Doc and Chunk Identifier ...
///
public string Identifier { get; set; }
///
/// Knowledge Base Type / Domain (Optional Filter on Search) ...
///
public string Type { get; set; }
///
/// Embedding vector representation ...
///
public virtual ReadOnlyMemory Embedding { get; set; } = null;
///
/// Metadata associated with the vector ...
///
public virtual Dictionary Metadata { get; set; } = null;
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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 Metadata { get; set; } = null;
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\Entities\XAiConversation.cs
using System;
using xModels.Base;
using System.ComponentModel.DataAnnotations;
namespace xAiModels.Models.Entities
{
///
/// Conversation Describe ...
///
public class XAiConversation : XBaseGuidIDEntity
{
///
/// User Identifier ...
///
///
[Required]
[StringLength(255)]
public string OwnerId { get; set; }
///
/// Title of Conversation ...
///
[Required]
[StringLength(255)]
public string Title { get; set; }
///
/// Created Time ...
///
public DateTime CreatedOn { get; set; }
///
/// Updated Time ...
///
public DateTime UpdatedAt { get; set; }
///
/// Project ID ...
///
[Required]
public Guid ProjectId { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\Entities\XAiMcpServer.cs
using System;
using xModels.Base;
using xAiModels.Constants;
using System.ComponentModel.DataAnnotations;
namespace xAiModels.Models.Entities
{
///
/// An MCP Server Descriptor for Adding Tools to XAI ...
///
public class XAiMcpServer : XBaseGuidIDEntity
{
///
/// Owner ...
///
[Required]
[StringLength(255)]
public string OwnerId { get; set; }
///
/// Specified Which Scope can Use MCP Server ...
///
public XAiMcpServerUsageScope Scope { get; set; } = XAiMcpServerUsageScope.Owner;
///
/// MCP Server Name ...
///
[Required]
[StringLength(255)]
public string Name { get; set; }
///
/// Description ...
///
[StringLength(1000)]
public string Description { get; set; }
///
/// Enabled or Disabled ...
///
public bool Enabled { get; set; } = true;
///
/// Environment Variables as JSON Object ...
///
public string EnvironmentVariables { get; set; }
///
/// Endpoint to Connect ...
///
[StringLength(1000)]
public string Endpoint { get; set; }
///
/// Headers List as Json Object ...
///
public string Headers { get; set; }
///
/// Timout Secconds ...
///
public int TimeoutSeconds { get; set; } = 30;
public DateTime CreatedOn { get; set; }
public DateTime UpdatedAt { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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
{
///
/// Message Model of Ai ...
///
public class XAiMessage : XBaseGuidIDEntity
{
///
/// User Identifier ...
///
///
[Required]
[StringLength(255)]
public string OwnerId { get; set; }
///
/// Message of Chat ...
///
[Required]
public string Content { get; set; }
///
/// Role of Message ...
///
public XAiChatRole Role { get; set; }
///
/// Created Time ...
///
public DateTime CreatedOn { get; set; }
///
/// Updated Time ...
///
public DateTime UpdatedAt { get; set; }
///
/// Conversation Id ...
///
[StringLength(255)]
public Guid ConversationId { get; set; }
//
#region Meta Data Property ...
private string _metadata;
///
/// Meta Data of Message ...
///
[NotMapped]
public IDictionary Metadata { get; private set; } = null;
///
/// Meta Data of MEssage in Json ...
///
public string MetaDatas
{
//
get => _metadata;
//
set
{
//
// Converts Json String to Dictionary ...
if (!value.IsNullOrEmpty())
{
Metadata = value.FromJSON>();
}
//
_metadata = value;
}
}
#endregion
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\Entities\XAiProject.cs
using System;
using xModels.Base;
using System.ComponentModel.DataAnnotations;
namespace xAiModels.Models.Entities
{
///
/// Describe a Project ...
///
public class XAiProject : XBaseGuidIDEntity
{
///
/// User Identifier ...
///
///
[Required]
[StringLength(255)]
public string OwnerId { get; set; }
///
/// Title of Project ...
///
[Required]
[StringLength(255)]
public string Title { get; set; }
///
/// Description of Project ...
///
[StringLength(1000)]
public string Description { get; set; }
///
/// a Prompt for Project Start ...
///
public string Prompt { get; set; }
///
/// Created Time ...
///
public DateTime CreatedOn { get; set; }
///
/// Updated Time ...
///
public DateTime UpdatedAt { get; set; }
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\xSaherelmWorkspace\Modules\xAiModels\Models\Entities\XAiVector.cs
using xModels.Base;
using System.ComponentModel.DataAnnotations;
namespace xAiModels.Models.Entities
{
public class XAiVector : XBaseGuidIDEntity
{
///
/// Thge Content Which Embedded ...
///
public string Text { get; set; }
///
/// Doc and Chunk Identifier ...
///
public string Identifier { get; set; }
///
/// Knowledge Base Type / Domain (e.g. "Legal", "Medical") ...
/// Used for Filtering on Search and Retrieve ...
///
[StringLength(100)]
public string Type { get; set; }
///
/// a Json String which Represents IReadOnlyList of float ...
///
public string Embedding { get; set; }
///
/// a Json String Which Represents MetaData ...
///
public string Metadata { get; set; } = string.Empty;
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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();
}
///
/// Configure Entities ...
///
///
public override void ConfigureEntities(ModelBuilder modelBuilder)
{
//
// Configure Entity Using Provided ...
modelBuilder
.ApplyConfigurationsFromAssembly(typeof(XAiConversationEntityConfiguration).Assembly);
//
base.ConfigureEntities(modelBuilder);
}
}
}
### FILE: C:\Users\SaherElm\Documents\Projects\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\SaherElm\Documents\Projects\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
{
///
/// All Data Manipulation Requirements ...
///
public class XAiDataProvider : IXAiDataProvider
{
//
#region Properties ...
private readonly IXStringProvider stringProvider;
private readonly IXAiVectorEnricher vectorEnricher;
private readonly XAppConfiguration appConfiguration;
private readonly IHubContext 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 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 ...
///
/// Load Projects List of Specified Owner ...
///
///
///
///
///
///
///
public async Task> 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;
}
///
/// Load List of Conversations for Specified Project ...
///
///
///
///
///
///
public async Task> 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;
}
///
/// Load Messages of Specified Conversation ...
///
///
///
///
public async Task> 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 ...
///
/// Retrieve Specified Project ...
///
///
///
///
///
///
public async Task 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;
}
///
/// Retrieve Specified Conversation ...
///
///
///
///
///
public async Task 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 ...
///
/// Create Project ...
///
///
///
///
///
///
public async Task 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;
}
///
/// Create an AI Conversation ...
///
///
///
///
///
///
///
public async Task 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;
}
///
/// Add Message ...
///
///
///
///
///
///
public async Task 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 ...
///