From 5efd41754ab30bb4fd76729d059add0e8fc61a18 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 24 Apr 2026 00:33:50 +0330 Subject: [PATCH] last ... --- .../Entities/XAiConversationConfiguration.cs | 21 +++ .../Entities/XAiMessageConfiguration.cs | 13 ++ .../Entities/XAiProjectConfiguration.cs | 21 +++ AI/DI/AIExtensions.cs | 1 + AI/DataHelper/Events/XAiConversationEvents.cs | 9 + AI/DataHelper/Events/XAiMessageEvents.cs | 9 + AI/DataHelper/Events/XAiProjectEvents.cs | 9 + .../XAiConversationGraphQLTypeHelper.cs | 27 +++ .../GraphQL/XAiConversationGraphQuery.cs | 23 +++ .../GraphQL/XAiConversationGraphSchema.cs | 13 ++ .../GraphQL/XAiConversationGraphType.cs | 17 ++ .../GraphQL/XAiMessageGraphQLTypeHelper.cs | 26 +++ AI/DataHelper/GraphQL/XAiMessageGraphQuery.cs | 23 +++ .../GraphQL/XAiMessageGraphSchema.cs | 13 ++ AI/DataHelper/GraphQL/XAiMessageGraphType.cs | 19 ++ .../GraphQL/XAiProjectGraphQLTypeHelper.cs | 27 +++ AI/DataHelper/GraphQL/XAiProjectGraphQuery.cs | 23 +++ .../GraphQL/XAiProjectGraphSchema.cs | 13 ++ AI/DataHelper/GraphQL/XAiProjectGraphType.cs | 19 ++ AI/Extensions/ChatRoleExtensions.cs | 162 ++++++++++++++++++ AI/Hubs/XAiConversationEntityHub.cs | 13 ++ AI/Hubs/XAiMessageEntityHub.cs | 13 ++ AI/Hubs/XAiProjectEntityHub.cs | 13 ++ .../Entities/IXAiConversationEvents.cs | 8 + .../IXAiConversationGraphQLTypeHelper.cs | 9 + .../Entities/IXAiConversationRepository.cs | 9 + AI/Interfaces/Entities/IXAiMessageEvents.cs | 8 + .../Entities/IXAiMessageGraphQLTypeHelper.cs | 9 + .../Entities/IXAiMessageRepository.cs | 9 + AI/Interfaces/Entities/IXAiProjectEvents.cs | 8 + .../Entities/IXAiProjectGraphQLTypeHelper.cs | 9 + .../Entities/IXAiProjectRepository.cs | 9 + AI/Interfaces/IXAiProvider.cs | 10 ++ AI/Models/Entities/XAiConversation.cs | 42 +++++ AI/Models/Entities/XAiMessage.cs | 75 +++++++- AI/Models/Entities/XAiProject.cs | 39 +++++ Data/Helpers/XAiApiDataHelperGraphQLHelper.cs | 55 ++++++ Data/Helpers/XAiApiDataProviderHelper.cs | 42 +++++ .../Ef/XAiConversationEfRepository.cs | 38 ++++ .../Repositories/Ef/XAiMessageEfRepository.cs | 38 ++++ .../Repositories/Ef/XAiProjectEfRepository.cs | 38 ++++ .../Mongo/XAiConversationMongoRepository.cs | 39 +++++ .../Mongo/XAiMessageMongoRepository.cs | 39 +++++ .../Mongo/XAiProjectMongoRepository.cs | 39 +++++ Data/XAiApiDbContext.cs | 8 + xAiApi.csproj | 1 + 46 files changed, 1104 insertions(+), 4 deletions(-) create mode 100644 AI/Configuration/Entities/XAiConversationConfiguration.cs create mode 100644 AI/Configuration/Entities/XAiMessageConfiguration.cs create mode 100644 AI/Configuration/Entities/XAiProjectConfiguration.cs create mode 100644 AI/DataHelper/Events/XAiConversationEvents.cs create mode 100644 AI/DataHelper/Events/XAiMessageEvents.cs create mode 100644 AI/DataHelper/Events/XAiProjectEvents.cs create mode 100644 AI/DataHelper/GraphQL/XAiConversationGraphQLTypeHelper.cs create mode 100644 AI/DataHelper/GraphQL/XAiConversationGraphQuery.cs create mode 100644 AI/DataHelper/GraphQL/XAiConversationGraphSchema.cs create mode 100644 AI/DataHelper/GraphQL/XAiConversationGraphType.cs create mode 100644 AI/DataHelper/GraphQL/XAiMessageGraphQLTypeHelper.cs create mode 100644 AI/DataHelper/GraphQL/XAiMessageGraphQuery.cs create mode 100644 AI/DataHelper/GraphQL/XAiMessageGraphSchema.cs create mode 100644 AI/DataHelper/GraphQL/XAiMessageGraphType.cs create mode 100644 AI/DataHelper/GraphQL/XAiProjectGraphQLTypeHelper.cs create mode 100644 AI/DataHelper/GraphQL/XAiProjectGraphQuery.cs create mode 100644 AI/DataHelper/GraphQL/XAiProjectGraphSchema.cs create mode 100644 AI/DataHelper/GraphQL/XAiProjectGraphType.cs create mode 100644 AI/Extensions/ChatRoleExtensions.cs create mode 100644 AI/Hubs/XAiConversationEntityHub.cs create mode 100644 AI/Hubs/XAiMessageEntityHub.cs create mode 100644 AI/Hubs/XAiProjectEntityHub.cs create mode 100644 AI/Interfaces/Entities/IXAiConversationEvents.cs create mode 100644 AI/Interfaces/Entities/IXAiConversationGraphQLTypeHelper.cs create mode 100644 AI/Interfaces/Entities/IXAiConversationRepository.cs create mode 100644 AI/Interfaces/Entities/IXAiMessageEvents.cs create mode 100644 AI/Interfaces/Entities/IXAiMessageGraphQLTypeHelper.cs create mode 100644 AI/Interfaces/Entities/IXAiMessageRepository.cs create mode 100644 AI/Interfaces/Entities/IXAiProjectEvents.cs create mode 100644 AI/Interfaces/Entities/IXAiProjectGraphQLTypeHelper.cs create mode 100644 AI/Interfaces/Entities/IXAiProjectRepository.cs create mode 100644 AI/Interfaces/IXAiProvider.cs create mode 100644 AI/Models/Entities/XAiConversation.cs create mode 100644 AI/Models/Entities/XAiProject.cs create mode 100644 Data/Repositories/Ef/XAiConversationEfRepository.cs create mode 100644 Data/Repositories/Ef/XAiMessageEfRepository.cs create mode 100644 Data/Repositories/Ef/XAiProjectEfRepository.cs create mode 100644 Data/Repositories/Mongo/XAiConversationMongoRepository.cs create mode 100644 Data/Repositories/Mongo/XAiMessageMongoRepository.cs create mode 100644 Data/Repositories/Mongo/XAiProjectMongoRepository.cs diff --git a/AI/Configuration/Entities/XAiConversationConfiguration.cs b/AI/Configuration/Entities/XAiConversationConfiguration.cs new file mode 100644 index 0000000..d7516e2 --- /dev/null +++ b/AI/Configuration/Entities/XAiConversationConfiguration.cs @@ -0,0 +1,21 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using xAiApi.AI.Models.Entities; + +namespace xAiApi.AI.Configuration.Entities +{ + public class XAiConversationConfiguration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + // + // Configure Navigations ... + builder + .HasMany(x => x.Messages) + .WithOne(x => x.Conversation) + .HasForeignKey(x => x.ConversationId) + .OnDelete(DeleteBehavior.NoAction); + } + } +} \ No newline at end of file diff --git a/AI/Configuration/Entities/XAiMessageConfiguration.cs b/AI/Configuration/Entities/XAiMessageConfiguration.cs new file mode 100644 index 0000000..7a36f7b --- /dev/null +++ b/AI/Configuration/Entities/XAiMessageConfiguration.cs @@ -0,0 +1,13 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using xAiApi.AI.Models.Entities; + +namespace xAiApi.AI.Configuration.Entities +{ + public class XAiMessageConfiguration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { } + } +} \ No newline at end of file diff --git a/AI/Configuration/Entities/XAiProjectConfiguration.cs b/AI/Configuration/Entities/XAiProjectConfiguration.cs new file mode 100644 index 0000000..3eda950 --- /dev/null +++ b/AI/Configuration/Entities/XAiProjectConfiguration.cs @@ -0,0 +1,21 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using xAiApi.AI.Models.Entities; + +namespace xAiApi.AI.Configuration.Entities +{ + public class XAiProjectConfiguration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + // + // Configure Navigations ... + builder + .HasMany(x => x.Conversations) + .WithOne(x => x.Project) + .HasForeignKey(x => x.ProjectId) + .OnDelete(DeleteBehavior.NoAction); + } + } +} \ No newline at end of file diff --git a/AI/DI/AIExtensions.cs b/AI/DI/AIExtensions.cs index 95b3e62..3b830d8 100644 --- a/AI/DI/AIExtensions.cs +++ b/AI/DI/AIExtensions.cs @@ -15,6 +15,7 @@ namespace xAiApi.AI.DI this IServiceCollection services ) { + // services.AddSingleton(); } diff --git a/AI/DataHelper/Events/XAiConversationEvents.cs b/AI/DataHelper/Events/XAiConversationEvents.cs new file mode 100644 index 0000000..670b8ef --- /dev/null +++ b/AI/DataHelper/Events/XAiConversationEvents.cs @@ -0,0 +1,9 @@ +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Events; + +namespace xAiApi.AI.DataHelper.Events +{ + public class XAiConversationEvents : XBaseRepositoryEvents, IXAiConversationEvents + { } +} \ No newline at end of file diff --git a/AI/DataHelper/Events/XAiMessageEvents.cs b/AI/DataHelper/Events/XAiMessageEvents.cs new file mode 100644 index 0000000..d3d71b2 --- /dev/null +++ b/AI/DataHelper/Events/XAiMessageEvents.cs @@ -0,0 +1,9 @@ +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Events; + +namespace xAiApi.AI.DataHelper.Events +{ + public class XAiMessageEvents : XBaseRepositoryEvents, IXAiMessageEvents + { } +} \ No newline at end of file diff --git a/AI/DataHelper/Events/XAiProjectEvents.cs b/AI/DataHelper/Events/XAiProjectEvents.cs new file mode 100644 index 0000000..043acd9 --- /dev/null +++ b/AI/DataHelper/Events/XAiProjectEvents.cs @@ -0,0 +1,9 @@ +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Events; + +namespace xAiApi.AI.DataHelper.Events +{ + public class XAiProjectEvents : XBaseRepositoryEvents, IXAiProjectEvents + { } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiConversationGraphQLTypeHelper.cs b/AI/DataHelper/GraphQL/XAiConversationGraphQLTypeHelper.cs new file mode 100644 index 0000000..a707faa --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiConversationGraphQLTypeHelper.cs @@ -0,0 +1,27 @@ +using System; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiConversationGraphQLTypeHelper : XBaseGraphQLTypeHelper, IXAiConversationGraphQLTypeHelper + { + public XAiConversationGraphQLTypeHelper( + XDataServiceConfiguration configuration + ) : base(configuration) + { } + + public override string GetInQueryCollectionName() + { + return "aiConversations"; + } + + public override string GetInQuerySingleName() + { + return "aiConversation"; + } + + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiConversationGraphQuery.cs b/AI/DataHelper/GraphQL/XAiConversationGraphQuery.cs new file mode 100644 index 0000000..504500f --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiConversationGraphQuery.cs @@ -0,0 +1,23 @@ +using System; +using GraphQL.Types; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiConversationGraphQuery : XBaseGraphQLQuery + { + public XAiConversationGraphQuery( + XDataServiceConfiguration configuration, + IXAiConversationRepository repository, + IXAiConversationGraphQLTypeHelper helper + ) : base( + configuration, + repository, + helper + ) + { } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiConversationGraphSchema.cs b/AI/DataHelper/GraphQL/XAiConversationGraphSchema.cs new file mode 100644 index 0000000..ef06070 --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiConversationGraphSchema.cs @@ -0,0 +1,13 @@ +using System; +using GraphQL.Types; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiConversationGraphSchema : Schema + { + public XAiConversationGraphSchema(IServiceProvider services) : base(services) + { + Query = (XAiConversationGraphQuery)services.GetService(typeof(XAiConversationGraphQuery)); + } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiConversationGraphType.cs b/AI/DataHelper/GraphQL/XAiConversationGraphType.cs new file mode 100644 index 0000000..61a2393 --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiConversationGraphType.cs @@ -0,0 +1,17 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiConversationGraphType : XBaseGraphObjectType + { + public XAiConversationGraphType() : base() + { + Field(x => x.Title); + Field(x => x.Messages); + Field(x => x.CreatedOn); + Field(x => x.UpdatedAt); + } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiMessageGraphQLTypeHelper.cs b/AI/DataHelper/GraphQL/XAiMessageGraphQLTypeHelper.cs new file mode 100644 index 0000000..01be00f --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiMessageGraphQLTypeHelper.cs @@ -0,0 +1,26 @@ +using System; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiMessageGraphQLTypeHelper : XBaseGraphQLTypeHelper, IXAiMessageGraphQLTypeHelper + { + public XAiMessageGraphQLTypeHelper( + XDataServiceConfiguration configuration + ) : base(configuration) + { } + + public override string GetInQueryCollectionName() + { + return "aiMessages"; + } + + public override string GetInQuerySingleName() + { + return "aiMessage"; + } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiMessageGraphQuery.cs b/AI/DataHelper/GraphQL/XAiMessageGraphQuery.cs new file mode 100644 index 0000000..60f8c0a --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiMessageGraphQuery.cs @@ -0,0 +1,23 @@ +using System; +using GraphQL.Types; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiMessageGraphQuery : XBaseGraphQLQuery + { + public XAiMessageGraphQuery( + XDataServiceConfiguration configuration, + IXAiMessageRepository repository, + IXAiMessageGraphQLTypeHelper helper + ) : base( + configuration, + repository, + helper + ) + { } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiMessageGraphSchema.cs b/AI/DataHelper/GraphQL/XAiMessageGraphSchema.cs new file mode 100644 index 0000000..d807751 --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiMessageGraphSchema.cs @@ -0,0 +1,13 @@ +using System; +using GraphQL.Types; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiMessageGraphSchema : Schema + { + public XAiMessageGraphSchema(IServiceProvider services) : base(services) + { + Query = (XAiMessageGraphQuery)services.GetService(typeof(XAiMessageGraphQuery)); + } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiMessageGraphType.cs b/AI/DataHelper/GraphQL/XAiMessageGraphType.cs new file mode 100644 index 0000000..95a8eb8 --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiMessageGraphType.cs @@ -0,0 +1,19 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiMessageGraphType : XBaseGraphObjectType + { + public XAiMessageGraphType() : base() + { + Field(x => x.Role); + Field(x => x.Content); + Field(x => x.Metadata); + Field(x => x.CreatedOn); + Field(x => x.UpdatedAt); + Field(x => x.ConversationId); + } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiProjectGraphQLTypeHelper.cs b/AI/DataHelper/GraphQL/XAiProjectGraphQLTypeHelper.cs new file mode 100644 index 0000000..a8671ff --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiProjectGraphQLTypeHelper.cs @@ -0,0 +1,27 @@ +using System; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiProjectGraphQLTypeHelper : XBaseGraphQLTypeHelper, IXAiProjectGraphQLTypeHelper + { + public XAiProjectGraphQLTypeHelper( + XDataServiceConfiguration configuration + ) : base(configuration) + { } + + public override string GetInQueryCollectionName() + { + return "aiProjects"; + } + + public override string GetInQuerySingleName() + { + return "aiProjects"; + } + + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiProjectGraphQuery.cs b/AI/DataHelper/GraphQL/XAiProjectGraphQuery.cs new file mode 100644 index 0000000..308ce0d --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiProjectGraphQuery.cs @@ -0,0 +1,23 @@ +using System; +using GraphQL.Types; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiProjectGraphQuery : XBaseGraphQLQuery + { + public XAiProjectGraphQuery( + XDataServiceConfiguration configuration, + IXAiProjectRepository repository, + IXAiProjectGraphQLTypeHelper helper + ) : base( + configuration, + repository, + helper + ) + { } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiProjectGraphSchema.cs b/AI/DataHelper/GraphQL/XAiProjectGraphSchema.cs new file mode 100644 index 0000000..d438bdf --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiProjectGraphSchema.cs @@ -0,0 +1,13 @@ +using System; +using GraphQL.Types; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiProjectGraphSchema : Schema + { + public XAiProjectGraphSchema(IServiceProvider services) : base(services) + { + Query = (XAiProjectGraphQuery)services.GetService(typeof(XAiProjectGraphQuery)); + } + } +} \ No newline at end of file diff --git a/AI/DataHelper/GraphQL/XAiProjectGraphType.cs b/AI/DataHelper/GraphQL/XAiProjectGraphType.cs new file mode 100644 index 0000000..01bdba0 --- /dev/null +++ b/AI/DataHelper/GraphQL/XAiProjectGraphType.cs @@ -0,0 +1,19 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.GraphQL; + +namespace xAiApi.AI.DataHelper.GraphQL +{ + public class XAiProjectGraphType : XBaseGraphObjectType + { + public XAiProjectGraphType() : base() + { + Field(x => x.Title); + Field(x => x.Prompt); + Field(x => x.CreatedOn); + Field(x => x.UpdatedAt); + Field(x => x.Description); + Field(x => x.Conversations); + } + } +} \ No newline at end of file diff --git a/AI/Extensions/ChatRoleExtensions.cs b/AI/Extensions/ChatRoleExtensions.cs new file mode 100644 index 0000000..bfd3b54 --- /dev/null +++ b/AI/Extensions/ChatRoleExtensions.cs @@ -0,0 +1,162 @@ +using Microsoft.Extensions.AI; +using xAiApi.AI.Constants; +using xCommons.Extensions; + +namespace xAiApi.AI.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; + } + + /// + /// 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; + } + } +} \ No newline at end of file diff --git a/AI/Hubs/XAiConversationEntityHub.cs b/AI/Hubs/XAiConversationEntityHub.cs new file mode 100644 index 0000000..1be3d2d --- /dev/null +++ b/AI/Hubs/XAiConversationEntityHub.cs @@ -0,0 +1,13 @@ +using System; +using Microsoft.Extensions.Logging; +using xAiApi.AI.Models.Entities; +using xPushService.Base; + +namespace xAiApi.AI.Hubs +{ + public class XAiConversationEntityHub : XBaseEntityHub + { + public XAiConversationEntityHub(ILogger logger) : base(logger) + { } + } +} \ No newline at end of file diff --git a/AI/Hubs/XAiMessageEntityHub.cs b/AI/Hubs/XAiMessageEntityHub.cs new file mode 100644 index 0000000..f6c5179 --- /dev/null +++ b/AI/Hubs/XAiMessageEntityHub.cs @@ -0,0 +1,13 @@ +using System; +using Microsoft.Extensions.Logging; +using xAiApi.AI.Models.Entities; +using xPushService.Base; + +namespace xAiApi.AI.Hubs +{ + public class XAiMessageEntityHub : XBaseEntityHub + { + public XAiMessageEntityHub(ILogger logger) : base(logger) + { } + } +} \ No newline at end of file diff --git a/AI/Hubs/XAiProjectEntityHub.cs b/AI/Hubs/XAiProjectEntityHub.cs new file mode 100644 index 0000000..28da8f7 --- /dev/null +++ b/AI/Hubs/XAiProjectEntityHub.cs @@ -0,0 +1,13 @@ +using System; +using Microsoft.Extensions.Logging; +using xAiApi.AI.Models.Entities; +using xPushService.Base; + +namespace xAiApi.AI.Hubs +{ + public class XAiProjectEntityHub : XBaseEntityHub + { + public XAiProjectEntityHub(ILogger logger) : base(logger) + { } + } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiConversationEvents.cs b/AI/Interfaces/Entities/IXAiConversationEvents.cs new file mode 100644 index 0000000..0d28819 --- /dev/null +++ b/AI/Interfaces/Entities/IXAiConversationEvents.cs @@ -0,0 +1,8 @@ +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiConversationEvents : IXBaseRepositoryEvents + { } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiConversationGraphQLTypeHelper.cs b/AI/Interfaces/Entities/IXAiConversationGraphQLTypeHelper.cs new file mode 100644 index 0000000..a001c59 --- /dev/null +++ b/AI/Interfaces/Entities/IXAiConversationGraphQLTypeHelper.cs @@ -0,0 +1,9 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiConversationGraphQLTypeHelper : IXBaseGraphQLTypeHelper + { } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiConversationRepository.cs b/AI/Interfaces/Entities/IXAiConversationRepository.cs new file mode 100644 index 0000000..14edf22 --- /dev/null +++ b/AI/Interfaces/Entities/IXAiConversationRepository.cs @@ -0,0 +1,9 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiConversationRepository : IXBaseRepository + { } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiMessageEvents.cs b/AI/Interfaces/Entities/IXAiMessageEvents.cs new file mode 100644 index 0000000..4911d4b --- /dev/null +++ b/AI/Interfaces/Entities/IXAiMessageEvents.cs @@ -0,0 +1,8 @@ +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiMessageEvents : IXBaseRepositoryEvents + { } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiMessageGraphQLTypeHelper.cs b/AI/Interfaces/Entities/IXAiMessageGraphQLTypeHelper.cs new file mode 100644 index 0000000..632a385 --- /dev/null +++ b/AI/Interfaces/Entities/IXAiMessageGraphQLTypeHelper.cs @@ -0,0 +1,9 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiMessageGraphQLTypeHelper : IXBaseGraphQLTypeHelper + { } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiMessageRepository.cs b/AI/Interfaces/Entities/IXAiMessageRepository.cs new file mode 100644 index 0000000..eb1a731 --- /dev/null +++ b/AI/Interfaces/Entities/IXAiMessageRepository.cs @@ -0,0 +1,9 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiMessageRepository : IXBaseRepository + { } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiProjectEvents.cs b/AI/Interfaces/Entities/IXAiProjectEvents.cs new file mode 100644 index 0000000..39a61f4 --- /dev/null +++ b/AI/Interfaces/Entities/IXAiProjectEvents.cs @@ -0,0 +1,8 @@ +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiProjectEvents : IXBaseRepositoryEvents + { } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiProjectGraphQLTypeHelper.cs b/AI/Interfaces/Entities/IXAiProjectGraphQLTypeHelper.cs new file mode 100644 index 0000000..800666e --- /dev/null +++ b/AI/Interfaces/Entities/IXAiProjectGraphQLTypeHelper.cs @@ -0,0 +1,9 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiProjectGraphQLTypeHelper : IXBaseGraphQLTypeHelper + { } +} \ No newline at end of file diff --git a/AI/Interfaces/Entities/IXAiProjectRepository.cs b/AI/Interfaces/Entities/IXAiProjectRepository.cs new file mode 100644 index 0000000..d3b540c --- /dev/null +++ b/AI/Interfaces/Entities/IXAiProjectRepository.cs @@ -0,0 +1,9 @@ +using System; +using xAiApi.AI.Models.Entities; +using xDataService.Interfaces; + +namespace xAiApi.AI.Interfaces.Entities +{ + public interface IXAiProjectRepository : IXBaseRepository + { } +} \ No newline at end of file diff --git a/AI/Interfaces/IXAiProvider.cs b/AI/Interfaces/IXAiProvider.cs new file mode 100644 index 0000000..d54e0b6 --- /dev/null +++ b/AI/Interfaces/IXAiProvider.cs @@ -0,0 +1,10 @@ +namespace xAiApi.AI.Interfaces +{ + /// + /// Provide Ai Capabilities Using AI Service ... + /// + public interface IXAiProvider + { + + } +} \ No newline at end of file diff --git a/AI/Models/Entities/XAiConversation.cs b/AI/Models/Entities/XAiConversation.cs new file mode 100644 index 0000000..7490041 --- /dev/null +++ b/AI/Models/Entities/XAiConversation.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using xModels.Base; + +namespace xAiApi.AI.Models.Entities +{ + /// + /// Conversation Describe ... + /// + public class XAiConversation : XBaseGuidIDEntity + { + /// + /// Title of Conversation ... + /// + public string Title { get; set; } + + /// + /// Created Time ... + /// + public DateTime CreatedOn { get; set; } + + /// + /// Updated Time ... + /// + public DateTime UpdatedAt { get; set; } + + /// + /// Messages of Conversation ... + /// + public IEnumerable Messages { get; set; } + + /// + /// Project ID ... + /// + public Guid ProjectId { get; set; } + + /// + /// Project ... + /// + public XAiProject Project { get; set; } + } +} \ No newline at end of file diff --git a/AI/Models/Entities/XAiMessage.cs b/AI/Models/Entities/XAiMessage.cs index 50ed820..581189c 100644 --- a/AI/Models/Entities/XAiMessage.cs +++ b/AI/Models/Entities/XAiMessage.cs @@ -1,12 +1,79 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations.Schema; +using xModels.Base; +using xCommons.Extensions; +using xAiModels.Constants; namespace xAiApi.AI.Models.Entities { - public class XAiMessage + /// + /// Message Model of Ai ... + /// + public class XAiMessage : XBaseGuidIDEntity { - + /// + /// 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 ... + /// + public XAiConversation Conversation { 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 MeatDatas + { + // + get => _metadata; + + // + set + { + // + // Converts Json String to Dictionary ... + if (!value.IsNullOrEmpty()) + { + Metadata = value.FromJSON>(); + } + + // + _metadata = value; + } + } + #endregion } } \ No newline at end of file diff --git a/AI/Models/Entities/XAiProject.cs b/AI/Models/Entities/XAiProject.cs new file mode 100644 index 0000000..23b5208 --- /dev/null +++ b/AI/Models/Entities/XAiProject.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using xModels.Base; + +namespace xAiApi.AI.Models.Entities +{ + public class XAiProject : XBaseGuidIDEntity + { + /// + /// Title of Project ... + /// + public string Title { get; set; } + + /// + /// Description of Project ... + /// + 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; } + + /// + /// Conversations ... + /// + public IEnumerable Conversations { get; set; } + } +} \ No newline at end of file diff --git a/Data/Helpers/XAiApiDataHelperGraphQLHelper.cs b/Data/Helpers/XAiApiDataHelperGraphQLHelper.cs index dfbd292..8d79ddc 100644 --- a/Data/Helpers/XAiApiDataHelperGraphQLHelper.cs +++ b/Data/Helpers/XAiApiDataHelperGraphQLHelper.cs @@ -1,6 +1,10 @@ +using System; using GraphQL.Server; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; +using xAiApi.AI.DataHelper.GraphQL; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; using xAiApi.Data.GraphQL; using xAiApi.Data.Interfaces; using xAiApi.Data.Models.Entities; @@ -24,6 +28,21 @@ namespace xAiApi.Data.Helpers // XTest ... services.AddSingleton(); services.AddSingleton>(); + + // + // XAiMessage ... + services.AddSingleton(); + services.AddSingleton>(); + + // + // XAiProject ... + services.AddSingleton(); + services.AddSingleton>(); + + // + // XAiConversation ... + services.AddSingleton(); + services.AddSingleton>(); } public void AddXGraphQueries(IServiceCollection services) @@ -32,12 +51,30 @@ namespace xAiApi.Data.Helpers // XTest ... services.AddSingleton(); services.AddScoped(); + + // + // XAiMessage ... + services.AddSingleton(); + services.AddScoped(); + + // + // XAiProject ... + services.AddSingleton(); + services.AddScoped(); + + // + // XAiConversation ... + services.AddSingleton(); + services.AddScoped(); } public void AddXGraphSchemas(IServiceCollection services) { // services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); } public void AddXGraphSubscriptions(IServiceCollection services) { } @@ -65,6 +102,24 @@ namespace xAiApi.Data.Helpers var testHelper = scope.ServiceProvider.GetService(); app.UseGraphQL(testHelper.GetGraphQLPath()); app.UseGraphQLWebSockets(); + + // + // XAiMessage ... + var aiMessageHelper = scope.ServiceProvider.GetService(); + app.UseGraphQL(aiMessageHelper.GetGraphQLPath()); + app.UseGraphQLWebSockets(); + + // + // XAiProject ... + var aiProjectHelper = scope.ServiceProvider.GetService(); + app.UseGraphQL(aiProjectHelper.GetGraphQLPath()); + app.UseGraphQLWebSockets(); + + // + // XAiConversation ... + var aiConversationHelper = scope.ServiceProvider.GetService(); + app.UseGraphQL(aiConversationHelper.GetGraphQLPath()); + app.UseGraphQLWebSockets(); } } } diff --git a/Data/Helpers/XAiApiDataProviderHelper.cs b/Data/Helpers/XAiApiDataProviderHelper.cs index 178ccbf..a4bc8ea 100644 --- a/Data/Helpers/XAiApiDataProviderHelper.cs +++ b/Data/Helpers/XAiApiDataProviderHelper.cs @@ -4,6 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using MongoDB.Bson.Serialization.Conventions; +using xAiApi.AI.DataHelper.Events; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; using xAiApi.Data.Events; using xAiApi.Data.Extensions; using xAiApi.Data.Interfaces; @@ -105,6 +108,18 @@ namespace xAiApi.Data.Helpers // // XTest ... services.Add(new ServiceDescriptor(typeof(IXTestEvents), typeof(XTestEvents), ServiceLifetime.Singleton)); + + // + // XAiProject ... + services.Add(new ServiceDescriptor(typeof(IXAiProjectEvents), typeof(XAiProjectEvents), ServiceLifetime.Singleton)); + + // + // XAiMessage ... + services.Add(new ServiceDescriptor(typeof(IXAiMessageEvents), typeof(XAiMessageEvents), ServiceLifetime.Singleton)); + + // + // XAiConversation ... + services.Add(new ServiceDescriptor(typeof(IXAiConversationEvents), typeof(XAiConversationEvents), ServiceLifetime.Singleton)); #endregion // @@ -120,6 +135,18 @@ namespace xAiApi.Data.Helpers // // XTest ... services.Add(new ServiceDescriptor(typeof(IXTestRepository), typeof(XTestEfRepository), lifetime)); + + // + // XAiProject ... + services.Add(new ServiceDescriptor(typeof(IXAiProjectRepository), typeof(XAiProjectEfRepository), lifetime)); + + // + // XAiMessage ... + services.Add(new ServiceDescriptor(typeof(IXAiMessageRepository), typeof(XAiMessageEfRepository), lifetime)); + + // + // XAiConversation ... + services.Add(new ServiceDescriptor(typeof(IXAiConversationRepository), typeof(XAiConversationEfRepository), lifetime)); break; // @@ -127,6 +154,18 @@ namespace xAiApi.Data.Helpers // // XTest ... services.Add(new ServiceDescriptor(typeof(IXTestRepository), typeof(XTestMongoRepository), lifetime)); + + // + // XAiProject ... + services.Add(new ServiceDescriptor(typeof(IXAiProjectRepository), typeof(XAiProjectMongoRepository), lifetime)); + + // + // XAiMessage ... + services.Add(new ServiceDescriptor(typeof(IXAiMessageRepository), typeof(XAiMessageMongoRepository), lifetime)); + + // + // XAiConversation ... + services.Add(new ServiceDescriptor(typeof(IXAiConversationRepository), typeof(XAiConversationMongoRepository), lifetime)); break; // @@ -145,6 +184,9 @@ namespace xAiApi.Data.Helpers { // services.AddSingleton, XIntKeyGenerator>(); + services.AddSingleton, XGuidKeyGenerator>(); + services.AddSingleton, XGuidKeyGenerator>(); + services.AddSingleton, XGuidKeyGenerator>(); } public void AddDbSeederConfiguration( diff --git a/Data/Repositories/Ef/XAiConversationEfRepository.cs b/Data/Repositories/Ef/XAiConversationEfRepository.cs new file mode 100644 index 0000000..995c078 --- /dev/null +++ b/Data/Repositories/Ef/XAiConversationEfRepository.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.Db; +using xDataService.EFRepositories; +using xDataService.Interfaces; + +namespace xAiApi.Data.Repositories.Ef +{ + public class XAiConversationEfRepository : XBaseEFRepository, IXAiConversationRepository + where TDbContext : XDbContext + { + // + public XAiConversationEfRepository( + IXUnitOfWorks unitOfWorks, + XDataServiceConfiguration configuration, + IXKeyGenerator keyGenerator = null, + IXAiConversationEvents baseRepositoryEvents = null + ) : base( + unitOfWorks, + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + + public override IQueryable GetFullDbSet() + { + return dbSet; + } + + // + #region Special ... + #endregion + } +} \ No newline at end of file diff --git a/Data/Repositories/Ef/XAiMessageEfRepository.cs b/Data/Repositories/Ef/XAiMessageEfRepository.cs new file mode 100644 index 0000000..a04011d --- /dev/null +++ b/Data/Repositories/Ef/XAiMessageEfRepository.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.Db; +using xDataService.EFRepositories; +using xDataService.Interfaces; + +namespace xAiApi.Data.Repositories.Ef +{ + public class XAiMessageEfRepository : XBaseEFRepository, IXAiMessageRepository + where TDbContext : XDbContext + { + // + public XAiMessageEfRepository( + IXUnitOfWorks unitOfWorks, + XDataServiceConfiguration configuration, + IXKeyGenerator keyGenerator = null, + IXAiMessageEvents baseRepositoryEvents = null + ) : base( + unitOfWorks, + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + + public override IQueryable GetFullDbSet() + { + return dbSet; + } + + // + #region Special ... + #endregion + } +} \ No newline at end of file diff --git a/Data/Repositories/Ef/XAiProjectEfRepository.cs b/Data/Repositories/Ef/XAiProjectEfRepository.cs new file mode 100644 index 0000000..9970d39 --- /dev/null +++ b/Data/Repositories/Ef/XAiProjectEfRepository.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.Db; +using xDataService.EFRepositories; +using xDataService.Interfaces; + +namespace xAiApi.Data.Repositories.Ef +{ + public class XAiProjectEfRepository : XBaseEFRepository, IXAiProjectRepository + where TDbContext : XDbContext + { + // + public XAiProjectEfRepository( + IXUnitOfWorks unitOfWorks, + XDataServiceConfiguration configuration, + IXKeyGenerator keyGenerator = null, + IXAiProjectEvents baseRepositoryEvents = null + ) : base( + unitOfWorks, + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + + public override IQueryable GetFullDbSet() + { + return dbSet; + } + + // + #region Special ... + #endregion + } +} \ No newline at end of file diff --git a/Data/Repositories/Mongo/XAiConversationMongoRepository.cs b/Data/Repositories/Mongo/XAiConversationMongoRepository.cs new file mode 100644 index 0000000..f7139af --- /dev/null +++ b/Data/Repositories/Mongo/XAiConversationMongoRepository.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +using MongoDB.Driver; +using MongoDB.Driver.Linq; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.Interfaces; +using xDataService.MongoRepositories; + +namespace xAiApi.Data.Repositories.Mongo +{ + public class XAiConversationMongoRepository : XBaseMongoRepository, IXAiConversationRepository + { + // + public XAiConversationMongoRepository( + XDataServiceConfiguration configuration, + string collectionName = null, + IXKeyGenerator keyGenerator = null, + IXAiConversationEvents baseRepositoryEvents = null + ) : base( + configuration, + collectionName, + keyGenerator, + baseRepositoryEvents + ) + { } + + public override IMongoQueryable GetFullDbSet() + { + return collection + .AsQueryable(); + } + + // + #region Special ... + #endregion + } +} \ No newline at end of file diff --git a/Data/Repositories/Mongo/XAiMessageMongoRepository.cs b/Data/Repositories/Mongo/XAiMessageMongoRepository.cs new file mode 100644 index 0000000..dc78dc1 --- /dev/null +++ b/Data/Repositories/Mongo/XAiMessageMongoRepository.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +using MongoDB.Driver; +using MongoDB.Driver.Linq; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.Interfaces; +using xDataService.MongoRepositories; + +namespace xAiApi.Data.Repositories.Mongo +{ + public class XAiMessageMongoRepository : XBaseMongoRepository, IXAiMessageRepository + { + // + public XAiMessageMongoRepository( + XDataServiceConfiguration configuration, + string collectionName = null, + IXKeyGenerator keyGenerator = null, + IXAiMessageEvents baseRepositoryEvents = null + ) : base( + configuration, + collectionName, + keyGenerator, + baseRepositoryEvents + ) + { } + + public override IMongoQueryable GetFullDbSet() + { + return collection + .AsQueryable(); + } + + // + #region Special ... + #endregion + } +} \ No newline at end of file diff --git a/Data/Repositories/Mongo/XAiProjectMongoRepository.cs b/Data/Repositories/Mongo/XAiProjectMongoRepository.cs new file mode 100644 index 0000000..0196e9e --- /dev/null +++ b/Data/Repositories/Mongo/XAiProjectMongoRepository.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +using MongoDB.Driver; +using MongoDB.Driver.Linq; +using xAiApi.AI.Interfaces.Entities; +using xAiApi.AI.Models.Entities; +using xDataService.Configuration; +using xDataService.Interfaces; +using xDataService.MongoRepositories; + +namespace xAiApi.Data.Repositories.Mongo +{ + public class XAiProjectMongoRepository : XBaseMongoRepository, IXAiProjectRepository + { + // + public XAiProjectMongoRepository( + XDataServiceConfiguration configuration, + string collectionName = null, + IXKeyGenerator keyGenerator = null, + IXAiProjectEvents baseRepositoryEvents = null + ) : base( + configuration, + collectionName, + keyGenerator, + baseRepositoryEvents + ) + { } + + public override IMongoQueryable GetFullDbSet() + { + return collection + .AsQueryable(); + } + + // + #region Special ... + #endregion + } +} \ No newline at end of file diff --git a/Data/XAiApiDbContext.cs b/Data/XAiApiDbContext.cs index 9e7ba01..bdd503c 100644 --- a/Data/XAiApiDbContext.cs +++ b/Data/XAiApiDbContext.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using xAiApi.AI.Models.Entities; using xAiApi.Data.Models.Entities; using xDataService.Configuration; using xDataService.Db; @@ -10,6 +11,13 @@ namespace xAiApi.Data // #region DbSets ... public DbSet Tests { get; set; } + + // + // Ai Entities ... + + public DbSet AiMessages { get; set; } + public DbSet AiProjects { get; set; } + public DbSet AiConversations { get; set; } #endregion // diff --git a/xAiApi.csproj b/xAiApi.csproj index 832f180..e10ea0e 100644 --- a/xAiApi.csproj +++ b/xAiApi.csproj @@ -18,6 +18,7 @@ +