From ae4b567bb3f23e739f1f4c0e62777300ded1bb2a Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Wed, 21 Oct 2026 09:57:28 +0330 Subject: [PATCH] --- MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## خلاصه کامل کارهای انجام شده: ### ✅ تمام فایل‌های ایجاد شده برای XAiVector: __مرحله 1 - Constants:__ - ✅ افزودن کانستنت‌ها به `XAiModelsConstants.cs` __مرحله 2 - DTO & Configuration:__ - ✅ `Models/Dtos/XAiVectorDto.cs` - تکمیل شد - ✅ `Configurations/Entities/XAiVectorEntityConfiguration.cs` - ✅ `Configurations/Entities/XAiVectorMappingAction.cs` - ✅ آپدیت `Configurations/XAiModelMappersProfile.cs` __مرحله 3 - Interfaces Entities:__ - ✅ `Interfaces/Entities/IXAiVectorRepository.cs` - ✅ `Interfaces/Entities/IXAiVectorEntityHub.cs` - ✅ `Interfaces/Entities/IXAiVectorKeyGenerator.cs` - ✅ `Interfaces/Entities/IXAiVectorRepositoryEvents.cs` - ✅ `Interfaces/Entities/IXAiVectorRepositoryProvider.cs` - ✅ `Interfaces/Entities/IXAiVectorSeeder.cs` - ✅ `Interfaces/Entities/IXAiVectorGraphQLTypeHelper.cs` __مرحله 4 - Interfaces Dtos:__ - ✅ `Interfaces/Dtos/IXAiVectorDtoHub.cs` - ✅ `Interfaces/Dtos/IXAiVectorRepositoryService.cs` - ✅ `Interfaces/Dtos/IXAiVectorServiceProvider.cs` __مرحله 5 - Interfaces Enrichers:__ - ✅ `Interfaces/Enrichers/IXAiVectorEnricher.cs` __مرحله 6 - Providers Entities:__ - ✅ `Providers/Entities/XAiVectorEFRepository.cs` - ✅ `Providers/Entities/XAiVectorMongoRepository.cs` - ✅ `Providers/Entities/XAiVectorInMemoryRepository.cs` - ✅ `Providers/Entities/XAiVectorEntityHub.cs` - ✅ `Providers/Entities/XAiVectorKeyGenerator.cs` - ✅ `Providers/Entities/XAiVectorRepositoryEvents.cs` - ✅ `Providers/Entities/XAiVectorRepositoryProvider.cs` - ✅ `Providers/Entities/XAiVectorSeederBase.cs` __مرحله 7 - Providers Dtos:__ - ✅ `Providers/Dtos/XAiVectorDtoHub.cs` - ✅ `Providers/Dtos/XAiVectorRepositoryService.cs` - ✅ `Providers/Dtos/XAiVectorServiceProvider.cs` __مرحله 8 - Providers Enrichers:__ - ✅ `Providers/Enrichers/XAiVectorEnricher.cs` __مرحله 9 - Providers GraphQL:__ - ✅ `Providers/GraphQL/XAiVectorGraphType.cs` - ✅ `Providers/GraphQL/XAiVectorGraphQuery.cs` - ✅ `Providers/GraphQL/XAiVectorGraphSchema.cs` - ✅ `Providers/GraphQL/XAiVectorGraphQLTypeHelper.cs` __مرحله 10 - Registry:__ - ✅ `Providers/XAiVectorEntityRegisterar.cs` __مرحله 11 - Build:__ - ✅ پروژه با موفقیت build شد --- .../Entities/XAiVectorEntityConfiguration.cs | 17 +++ Configurations/XAiModelMappersProfile.cs | 4 + Constants/XAiModelsConstants.cs | 8 ++ Interfaces/Dtos/IXAiVectorDtoHub.cs | 10 ++ .../Dtos/IXAiVectorRepositoryService.cs | 11 ++ Interfaces/Dtos/IXAiVectorServiceProvider.cs | 11 ++ Interfaces/Enrichers/IXAiVectorEnricher.cs | 58 ++++++++++ Interfaces/Entities/IXAiVectorEntityHub.cs | 9 ++ .../Entities/IXAiVectorGraphQLTypeHelper.cs | 9 ++ Interfaces/Entities/IXAiVectorKeyGenerator.cs | 9 ++ Interfaces/Entities/IXAiVectorRepository.cs | 9 ++ .../Entities/IXAiVectorRepositoryEvents.cs | 8 ++ .../Entities/IXAiVectorRepositoryProvider.cs | 10 ++ Interfaces/Entities/IXAiVectorSeeder.cs | 9 ++ Models/Dtos/XAiVectorDto.cs | 27 +++++ Models/Dtos/XAiVectorSearchResult.cs | 13 +++ Models/Entities/XAiVector.cs | 13 +++ Providers/Dtos/XAiVectorDtoHub.cs | 17 +++ Providers/Dtos/XAiVectorRepositoryService.cs | 24 ++++ Providers/Dtos/XAiVectorServiceProvider.cs | 27 +++++ Providers/Enrichers/XAiVectorEnricher.cs | 106 ++++++++++++++++++ Providers/Entities/XAiVectorEFRepository.cs | 27 +++++ Providers/Entities/XAiVectorEntityHub.cs | 16 +++ .../Entities/XAiVectorInMemoryRepository.cs | 22 ++++ Providers/Entities/XAiVectorKeyGenerator.cs | 9 ++ .../Entities/XAiVectorMongoRepository.cs | 26 +++++ .../Entities/XAiVectorRepositoryEvents.cs | 9 ++ .../Entities/XAiVectorRepositoryProvider.cs | 26 +++++ Providers/Entities/XAiVectorSeederBase.cs | 24 ++++ .../GraphQL/XAiVectorGraphQLTypeHelper.cs | 21 ++++ Providers/GraphQL/XAiVectorGraphQuery.cs | 23 ++++ Providers/GraphQL/XAiVectorGraphSchema.cs | 13 +++ Providers/GraphQL/XAiVectorGraphType.cs | 16 +++ Providers/XAiVectorEntityRegisterar.cs | 35 ++++++ 34 files changed, 676 insertions(+) create mode 100644 Configurations/Entities/XAiVectorEntityConfiguration.cs create mode 100644 Interfaces/Dtos/IXAiVectorDtoHub.cs create mode 100644 Interfaces/Dtos/IXAiVectorRepositoryService.cs create mode 100644 Interfaces/Dtos/IXAiVectorServiceProvider.cs create mode 100644 Interfaces/Enrichers/IXAiVectorEnricher.cs create mode 100644 Interfaces/Entities/IXAiVectorEntityHub.cs create mode 100644 Interfaces/Entities/IXAiVectorGraphQLTypeHelper.cs create mode 100644 Interfaces/Entities/IXAiVectorKeyGenerator.cs create mode 100644 Interfaces/Entities/IXAiVectorRepository.cs create mode 100644 Interfaces/Entities/IXAiVectorRepositoryEvents.cs create mode 100644 Interfaces/Entities/IXAiVectorRepositoryProvider.cs create mode 100644 Interfaces/Entities/IXAiVectorSeeder.cs create mode 100644 Models/Dtos/XAiVectorDto.cs create mode 100644 Models/Dtos/XAiVectorSearchResult.cs create mode 100644 Models/Entities/XAiVector.cs create mode 100644 Providers/Dtos/XAiVectorDtoHub.cs create mode 100644 Providers/Dtos/XAiVectorRepositoryService.cs create mode 100644 Providers/Dtos/XAiVectorServiceProvider.cs create mode 100644 Providers/Enrichers/XAiVectorEnricher.cs create mode 100644 Providers/Entities/XAiVectorEFRepository.cs create mode 100644 Providers/Entities/XAiVectorEntityHub.cs create mode 100644 Providers/Entities/XAiVectorInMemoryRepository.cs create mode 100644 Providers/Entities/XAiVectorKeyGenerator.cs create mode 100644 Providers/Entities/XAiVectorMongoRepository.cs create mode 100644 Providers/Entities/XAiVectorRepositoryEvents.cs create mode 100644 Providers/Entities/XAiVectorRepositoryProvider.cs create mode 100644 Providers/Entities/XAiVectorSeederBase.cs create mode 100644 Providers/GraphQL/XAiVectorGraphQLTypeHelper.cs create mode 100644 Providers/GraphQL/XAiVectorGraphQuery.cs create mode 100644 Providers/GraphQL/XAiVectorGraphSchema.cs create mode 100644 Providers/GraphQL/XAiVectorGraphType.cs create mode 100644 Providers/XAiVectorEntityRegisterar.cs diff --git a/Configurations/Entities/XAiVectorEntityConfiguration.cs b/Configurations/Entities/XAiVectorEntityConfiguration.cs new file mode 100644 index 0000000..3c6659c --- /dev/null +++ b/Configurations/Entities/XAiVectorEntityConfiguration.cs @@ -0,0 +1,17 @@ +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); + } + } +} diff --git a/Configurations/XAiModelMappersProfile.cs b/Configurations/XAiModelMappersProfile.cs index 27862b7..42801b4 100644 --- a/Configurations/XAiModelMappersProfile.cs +++ b/Configurations/XAiModelMappersProfile.cs @@ -12,6 +12,10 @@ namespace xAiModels.Configurations // XAiMessage ... CreateMap(); + // + // XAiVector ... + CreateMap(); + // // XAiProject ... CreateMap(); diff --git a/Constants/XAiModelsConstants.cs b/Constants/XAiModelsConstants.cs index 55f4425..45a9ab0 100644 --- a/Constants/XAiModelsConstants.cs +++ b/Constants/XAiModelsConstants.cs @@ -8,6 +8,7 @@ namespace xAiModels.Constants // // Table Mapping Identifiers ... + public const string XAiVectorTable = "AiVectors"; public const string XAiMessageTable = "AiMessages"; public const string XAiProjectTable = "AiProjects"; public const string XAiConversationTable = "AiConversations"; @@ -21,6 +22,9 @@ namespace xAiModels.Constants public const string XAiMessageCollectionName = "aiMessages"; public const string XAiProjectCollectionName = "AiProjectsa"; public const string XAiConversationCollectionName = "aiConversations"; + + public const string XAiVectorSingleName = "aiVector"; + public const string XAiVectorCollectionName = "aiVectors"; // // Hubs ... @@ -33,6 +37,9 @@ namespace xAiModels.Constants 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"; @@ -44,6 +51,7 @@ namespace xAiModels.Constants public const string GetXAiMessageEFRepositoryDescriptor = "GetXAiMessageEFRepositoryDescriptor"; public const string GetXAiProjectEFRepositoryDescriptor = "GetXAiProjectEFRepositoryDescriptor"; public const string GetXAiConversationEFRepositoryDescriptor = "GetXAiConversationEFRepositoryDescriptor"; + public const string GetXAiVectorEFRepositoryDescriptor = "GetXAiVectorEFRepositoryDescriptor"; // public const string DefaultXAiProjectTitleResourceID = "XAiPrjT"; diff --git a/Interfaces/Dtos/IXAiVectorDtoHub.cs b/Interfaces/Dtos/IXAiVectorDtoHub.cs new file mode 100644 index 0000000..ba84c38 --- /dev/null +++ b/Interfaces/Dtos/IXAiVectorDtoHub.cs @@ -0,0 +1,10 @@ +using System; +using xAiModels.Models.Dtos; +using xPushService.Interfaces; +using xAiModels.Models.Entities; + +namespace xAiModels.Interfaces.Dtos +{ + public interface IXAiVectorDtoHub : IXBaseDtoHub + { } +} diff --git a/Interfaces/Dtos/IXAiVectorRepositoryService.cs b/Interfaces/Dtos/IXAiVectorRepositoryService.cs new file mode 100644 index 0000000..ab5728a --- /dev/null +++ b/Interfaces/Dtos/IXAiVectorRepositoryService.cs @@ -0,0 +1,11 @@ +using System; +using xAiModels.Models.Dtos; +using xDataService.Interfaces; +using xAiModels.Models.Entities; + +namespace xAiModels.Interfaces.Dtos +{ + public interface IXAiVectorRepositoryService : IXBaseRepositoryService + { + } +} diff --git a/Interfaces/Dtos/IXAiVectorServiceProvider.cs b/Interfaces/Dtos/IXAiVectorServiceProvider.cs new file mode 100644 index 0000000..f4fa703 --- /dev/null +++ b/Interfaces/Dtos/IXAiVectorServiceProvider.cs @@ -0,0 +1,11 @@ +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 + { } +} diff --git a/Interfaces/Enrichers/IXAiVectorEnricher.cs b/Interfaces/Enrichers/IXAiVectorEnricher.cs new file mode 100644 index 0000000..1e2e8cf --- /dev/null +++ b/Interfaces/Enrichers/IXAiVectorEnricher.cs @@ -0,0 +1,58 @@ +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 + } +} diff --git a/Interfaces/Entities/IXAiVectorEntityHub.cs b/Interfaces/Entities/IXAiVectorEntityHub.cs new file mode 100644 index 0000000..50b5ecb --- /dev/null +++ b/Interfaces/Entities/IXAiVectorEntityHub.cs @@ -0,0 +1,9 @@ +using System; +using xPushService.Interfaces; +using xAiModels.Models.Entities; + +namespace xAiModels.Interfaces.Entities +{ + public interface IXAiVectorEntityHub : IXBaseEntityHub + { } +} diff --git a/Interfaces/Entities/IXAiVectorGraphQLTypeHelper.cs b/Interfaces/Entities/IXAiVectorGraphQLTypeHelper.cs new file mode 100644 index 0000000..ed380e2 --- /dev/null +++ b/Interfaces/Entities/IXAiVectorGraphQLTypeHelper.cs @@ -0,0 +1,9 @@ +using System; +using xDataService.Interfaces; +using xAiModels.Models.Entities; + +namespace xAiModels.Interfaces.Entities +{ + public interface IXAiVectorGraphQLTypeHelper : IXBaseGraphQLTypeHelper + { } +} diff --git a/Interfaces/Entities/IXAiVectorKeyGenerator.cs b/Interfaces/Entities/IXAiVectorKeyGenerator.cs new file mode 100644 index 0000000..cf4df60 --- /dev/null +++ b/Interfaces/Entities/IXAiVectorKeyGenerator.cs @@ -0,0 +1,9 @@ +using System; +using xDataService.Interfaces; +using xAiModels.Models.Entities; + +namespace xAiModels.Interfaces.Entities +{ + public interface IXAiVectorKeyGenerator : IXKeyGenerator + { } +} diff --git a/Interfaces/Entities/IXAiVectorRepository.cs b/Interfaces/Entities/IXAiVectorRepository.cs new file mode 100644 index 0000000..f168ff3 --- /dev/null +++ b/Interfaces/Entities/IXAiVectorRepository.cs @@ -0,0 +1,9 @@ +using System; +using xDataService.Interfaces; +using xAiModels.Models.Entities; + +namespace xAiModels.Interfaces.Entities +{ + public interface IXAiVectorRepository : IXBaseRepository + { } +} diff --git a/Interfaces/Entities/IXAiVectorRepositoryEvents.cs b/Interfaces/Entities/IXAiVectorRepositoryEvents.cs new file mode 100644 index 0000000..a9f5a95 --- /dev/null +++ b/Interfaces/Entities/IXAiVectorRepositoryEvents.cs @@ -0,0 +1,8 @@ +using xDataService.Interfaces; +using xAiModels.Models.Entities; + +namespace xAiModels.Interfaces.Entities +{ + public interface IXAiVectorRepositoryEvents : IXBaseRepositoryEvents + { } +} diff --git a/Interfaces/Entities/IXAiVectorRepositoryProvider.cs b/Interfaces/Entities/IXAiVectorRepositoryProvider.cs new file mode 100644 index 0000000..384d16c --- /dev/null +++ b/Interfaces/Entities/IXAiVectorRepositoryProvider.cs @@ -0,0 +1,10 @@ +using System; +using xPushService.Interfaces; +using xAiModels.Models.Entities; +using xAiModels.Providers.Entities; + +namespace xAiModels.Interfaces.Entities +{ + public interface IXAiVectorRepositoryProvider : IXBaseEntityProvider + { } +} diff --git a/Interfaces/Entities/IXAiVectorSeeder.cs b/Interfaces/Entities/IXAiVectorSeeder.cs new file mode 100644 index 0000000..36904ba --- /dev/null +++ b/Interfaces/Entities/IXAiVectorSeeder.cs @@ -0,0 +1,9 @@ +using System; +using xDataService.Interfaces; +using xAiModels.Models.Entities; + +namespace xAiModels.Interfaces.Entities +{ + public interface IXAiVectorSeeder : IXBaseDbSeeder + { } +} diff --git a/Models/Dtos/XAiVectorDto.cs b/Models/Dtos/XAiVectorDto.cs new file mode 100644 index 0000000..65dac37 --- /dev/null +++ b/Models/Dtos/XAiVectorDto.cs @@ -0,0 +1,27 @@ +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; } + + /// + /// Embedding vector representation ... + /// + public ReadOnlyMemory Embedding { get; set; } + + /// + /// Metadata associated with the vector ... + /// + public virtual Dictionary Metadata { get; set; } = null; + } +} \ No newline at end of file diff --git a/Models/Dtos/XAiVectorSearchResult.cs b/Models/Dtos/XAiVectorSearchResult.cs new file mode 100644 index 0000000..316d36d --- /dev/null +++ b/Models/Dtos/XAiVectorSearchResult.cs @@ -0,0 +1,13 @@ +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 Dictionary Metadata { get; set; } = null; + } +} \ No newline at end of file diff --git a/Models/Entities/XAiVector.cs b/Models/Entities/XAiVector.cs new file mode 100644 index 0000000..9802b50 --- /dev/null +++ b/Models/Entities/XAiVector.cs @@ -0,0 +1,13 @@ +using System; +using xModels.Base; +using System.Collections.Generic; + +namespace xAiModels.Models.Entities +{ + public class XAiVector : XBaseGuidIDEntity + { + public string Text { get; set; } + public ReadOnlyMemory Embedding { get; set; } + public virtual Dictionary Metadata { get; set; } = null; + } +} \ No newline at end of file diff --git a/Providers/Dtos/XAiVectorDtoHub.cs b/Providers/Dtos/XAiVectorDtoHub.cs new file mode 100644 index 0000000..384d5d2 --- /dev/null +++ b/Providers/Dtos/XAiVectorDtoHub.cs @@ -0,0 +1,17 @@ +using System; +using xPushService.Base; +using xAiModels.Models.Dtos; +using xAiModels.Interfaces.Dtos; +using xAiModels.Models.Entities; +using Microsoft.Extensions.Logging; + +namespace xAiModels.Providers.Dtos +{ + public class XAiVectorDtoHub : XBaseDtoHub, IXAiVectorDtoHub + { + public XAiVectorDtoHub( + ILogger logger + ) : base(logger) + { } + } +} diff --git a/Providers/Dtos/XAiVectorRepositoryService.cs b/Providers/Dtos/XAiVectorRepositoryService.cs new file mode 100644 index 0000000..daa084f --- /dev/null +++ b/Providers/Dtos/XAiVectorRepositoryService.cs @@ -0,0 +1,24 @@ +using System; +using xAiModels.Models.Dtos; +using xDataService.Providers; +using xAiModels.Configurations; +using xAiModels.Interfaces.Dtos; +using xAiModels.Models.Entities; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Dtos +{ + public class XAiVectorRepositoryService : XBaseRepositoryService, IXAiVectorRepositoryService + { + public XAiVectorRepositoryService( + IXAiVectorRepository repository + ) : base( + repository, + mapperProfiles: + [ + new XAiModelMappersProfile() + ] + ) + { } + } +} diff --git a/Providers/Dtos/XAiVectorServiceProvider.cs b/Providers/Dtos/XAiVectorServiceProvider.cs new file mode 100644 index 0000000..bb3018d --- /dev/null +++ b/Providers/Dtos/XAiVectorServiceProvider.cs @@ -0,0 +1,27 @@ +using System; +using xPushService.Base; +using xAiModels.Models.Dtos; +using xAiModels.Interfaces.Dtos; +using xAiModels.Models.Entities; +using xDataService.Configuration; +using xIdentityService.Interfaces; +using Microsoft.AspNetCore.SignalR; + +namespace xAiModels.Providers.Dtos +{ + public class XAiVectorServiceProvider : XBaseDtoProvider, IXAiVectorServiceProvider + { + public XAiVectorServiceProvider( + IHubContext hub, + XDataServiceConfiguration dataConfiguration, + IXAiVectorRepositoryService service, + IXIdentityProvider identityProvider = null + ) : base( + hub, + dataConfiguration, + service, + identityProvider + ) + { } + } +} diff --git a/Providers/Enrichers/XAiVectorEnricher.cs b/Providers/Enrichers/XAiVectorEnricher.cs new file mode 100644 index 0000000..14544ef --- /dev/null +++ b/Providers/Enrichers/XAiVectorEnricher.cs @@ -0,0 +1,106 @@ +using System.Linq; +using System.Threading; +using xCommons.Extensions; +using xAiModels.Models.Dtos; +using System.Threading.Tasks; +using xAiModels.Models.Entities; +using System.Collections.Generic; +using xAiModels.Interfaces.Enrichers; + +namespace xAiModels.Providers.Enrichers +{ + public class XAiVectorEnricher : IXAiVectorEnricher + { + public XAiVectorEnricher() + { } + + // + #region Enrichers ... + /// + /// Enrich Specified Item ... + /// + /// + /// + /// + public virtual async Task Enrich( + XAiVector source, + CancellationToken cancellationToken = default + ) + { + // + // Mapping Default ... + var result = source.MapConvert(); + result = await Enrich( + source: result, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Enrich Specified Item ... + /// + /// + /// + /// + public virtual async Task Enrich( + XAiVectorDto source, + CancellationToken cancellationToken = default + ) + { + // + // Currently no additional enrichment needed for XAiVector + // This can be extended in the future if needed + return await Task.FromResult(source); + } + + /// + /// Enrich Specified Items ... + /// + /// + /// + /// + public virtual async Task> EnrichRange( + IEnumerable sources, + CancellationToken cancellationToken = default + ) + { + // + var tasks = sources + .Select(x => Enrich( + source: x, + cancellationToken: cancellationToken + )); + + // + var result = await Task.WhenAll(tasks); + return result; + } + + /// + /// Enrich Specified Items ... + /// + /// + /// + /// + public virtual async Task> EnrichRange( + IEnumerable sources, + CancellationToken cancellationToken = default + ) + { + // + var tasks = sources + .Select(x => Enrich( + source: x, + cancellationToken: cancellationToken + )); + + // + var result = await Task.WhenAll(tasks); + return result; + } + #endregion + } +} diff --git a/Providers/Entities/XAiVectorEFRepository.cs b/Providers/Entities/XAiVectorEFRepository.cs new file mode 100644 index 0000000..e1b6299 --- /dev/null +++ b/Providers/Entities/XAiVectorEFRepository.cs @@ -0,0 +1,27 @@ +using System; +using xDataService.Db; +using xDataService.Providers; +using xDataService.Interfaces; +using xAiModels.Models.Entities; +using xDataService.Configuration; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Entities +{ + public class XAiVectorEFRepository : XBaseEFRepository, IXAiVectorRepository + where TContext : XDbContext + { + public XAiVectorEFRepository( + IXUnitOfWorks unitOfWorks, + XDataServiceConfiguration configuration, + IXAiVectorKeyGenerator keyGenerator = null, + IXAiVectorRepositoryEvents baseRepositoryEvents = null + ) : base( + unitOfWorks, + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} diff --git a/Providers/Entities/XAiVectorEntityHub.cs b/Providers/Entities/XAiVectorEntityHub.cs new file mode 100644 index 0000000..694962b --- /dev/null +++ b/Providers/Entities/XAiVectorEntityHub.cs @@ -0,0 +1,16 @@ +using System; +using xPushService.Base; +using xAiModels.Models.Entities; +using Microsoft.Extensions.Logging; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Entities +{ + public class XAiVectorEntityHub : XBaseEntityHub, IXAiVectorEntityHub + { + public XAiVectorEntityHub( + ILogger logger + ) : base(logger) + { } + } +} diff --git a/Providers/Entities/XAiVectorInMemoryRepository.cs b/Providers/Entities/XAiVectorInMemoryRepository.cs new file mode 100644 index 0000000..8614391 --- /dev/null +++ b/Providers/Entities/XAiVectorInMemoryRepository.cs @@ -0,0 +1,22 @@ +using System; +using xDataService.Providers; +using xAiModels.Models.Entities; +using xDataService.Configuration; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Entities +{ + public class XAiVectorInMemoryRepository : XBaseInMemoryRepository, IXAiVectorRepository + { + public XAiVectorInMemoryRepository( + XDataServiceConfiguration configuration, + IXAiVectorKeyGenerator keyGenerator = null, + IXAiVectorRepositoryEvents baseRepositoryEvents = null + ) : base( + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} diff --git a/Providers/Entities/XAiVectorKeyGenerator.cs b/Providers/Entities/XAiVectorKeyGenerator.cs new file mode 100644 index 0000000..8fce3b9 --- /dev/null +++ b/Providers/Entities/XAiVectorKeyGenerator.cs @@ -0,0 +1,9 @@ +using xDataService.Providers; +using xAiModels.Models.Entities; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Entities +{ + public class XAiVectorKeyGenerator : XGuidKeyGenerator, IXAiVectorKeyGenerator + { } +} diff --git a/Providers/Entities/XAiVectorMongoRepository.cs b/Providers/Entities/XAiVectorMongoRepository.cs new file mode 100644 index 0000000..dd01241 --- /dev/null +++ b/Providers/Entities/XAiVectorMongoRepository.cs @@ -0,0 +1,26 @@ +using System; +using xDataService.Providers; +using xAiModels.Models.Entities; +using xDataService.Configuration; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Entities +{ + public class XAiVectorMongoRepository : XBaseMongoRepository, IXAiVectorRepository + { + public XAiVectorMongoRepository( + XDataBaseConfiguration dbConfiguration, + XDataServiceConfiguration configuration, + string collectionName = null, + IXAiVectorKeyGenerator keyGenerator = null, + IXAiVectorRepositoryEvents baseRepositoryEvents = null + ) : base( + dbConfiguration, + configuration, + collectionName, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} diff --git a/Providers/Entities/XAiVectorRepositoryEvents.cs b/Providers/Entities/XAiVectorRepositoryEvents.cs new file mode 100644 index 0000000..33aa350 --- /dev/null +++ b/Providers/Entities/XAiVectorRepositoryEvents.cs @@ -0,0 +1,9 @@ +using xDataService.Providers; +using xAiModels.Models.Entities; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Entities +{ + public class XAiVectorRepositoryEvents : XBaseRepositoryEvents, IXAiVectorRepositoryEvents + { } +} diff --git a/Providers/Entities/XAiVectorRepositoryProvider.cs b/Providers/Entities/XAiVectorRepositoryProvider.cs new file mode 100644 index 0000000..62375c8 --- /dev/null +++ b/Providers/Entities/XAiVectorRepositoryProvider.cs @@ -0,0 +1,26 @@ +using System; +using xPushService.Base; +using xAiModels.Models.Entities; +using xDataService.Configuration; +using xIdentityService.Interfaces; +using Microsoft.AspNetCore.SignalR; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Entities +{ + public class XAiVectorRepositoryProvider : XBaseEntityProvider, IXAiVectorRepositoryProvider + { + public XAiVectorRepositoryProvider( + IHubContext hub, + IXAiVectorRepository repository, + XDataServiceConfiguration dataConfiguration, + IXIdentityProvider identityProvider = null + ) : base( + hub, + repository, + dataConfiguration, + identityProvider + ) + { } + } +} diff --git a/Providers/Entities/XAiVectorSeederBase.cs b/Providers/Entities/XAiVectorSeederBase.cs new file mode 100644 index 0000000..b09513a --- /dev/null +++ b/Providers/Entities/XAiVectorSeederBase.cs @@ -0,0 +1,24 @@ +using System; +using xDataService.Providers; +using xAiModels.Models.Entities; +using xDataService.Configuration; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.Entities +{ + public abstract class XAiVectorSeederBase : XBaseDbSeeder, IXAiVectorSeeder + { + protected XAiVectorSeederBase( + string entity, + string database, + IXAiVectorRepository repository, + XDataServiceConfiguration dataServiceConfiguration + ) : base( + entity, + database, + repository, + dataServiceConfiguration + ) + { } + } +} diff --git a/Providers/GraphQL/XAiVectorGraphQLTypeHelper.cs b/Providers/GraphQL/XAiVectorGraphQLTypeHelper.cs new file mode 100644 index 0000000..193cddf --- /dev/null +++ b/Providers/GraphQL/XAiVectorGraphQLTypeHelper.cs @@ -0,0 +1,21 @@ +using System; +using xAiModels.Constants; +using xDataService.GraphQL; +using xAiModels.Models.Entities; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.GraphQL +{ + public class XAiVectorGraphQLTypeHelper : XBaseGraphQLTypeHelper, IXAiVectorGraphQLTypeHelper + { + public override string GetInQueryCollectionName() + { + return XAiModelsConstants.XAiVectorCollectionName; + } + + public override string GetInQuerySingleName() + { + return XAiModelsConstants.XAiVectorSingleName; + } + } +} diff --git a/Providers/GraphQL/XAiVectorGraphQuery.cs b/Providers/GraphQL/XAiVectorGraphQuery.cs new file mode 100644 index 0000000..1665486 --- /dev/null +++ b/Providers/GraphQL/XAiVectorGraphQuery.cs @@ -0,0 +1,23 @@ +using System; +using GraphQL.Types; +using xDataService.GraphQL; +using xAiModels.Models.Entities; +using xDataService.Configuration; +using xAiModels.Interfaces.Entities; + +namespace xAiModels.Providers.GraphQL +{ + public class XAiVectorGraphQuery : XBaseGraphQLQuery + { + public XAiVectorGraphQuery( + XDataServiceConfiguration configuration, + IXAiVectorRepository repository, + IXAiVectorGraphQLTypeHelper helper + ) : base( + configuration, + repository, + helper + ) + { } + } +} diff --git a/Providers/GraphQL/XAiVectorGraphSchema.cs b/Providers/GraphQL/XAiVectorGraphSchema.cs new file mode 100644 index 0000000..6411fec --- /dev/null +++ b/Providers/GraphQL/XAiVectorGraphSchema.cs @@ -0,0 +1,13 @@ +using System; +using GraphQL.Types; + +namespace xAiModels.Providers.GraphQL +{ + public class XAiVectorGraphSchema : Schema + { + public XAiVectorGraphSchema(IServiceProvider services) : base(services) + { + Query = (XAiVectorGraphQuery)services.GetService(typeof(XAiVectorGraphQuery)); + } + } +} diff --git a/Providers/GraphQL/XAiVectorGraphType.cs b/Providers/GraphQL/XAiVectorGraphType.cs new file mode 100644 index 0000000..7241ab8 --- /dev/null +++ b/Providers/GraphQL/XAiVectorGraphType.cs @@ -0,0 +1,16 @@ +using System; +using xDataService.GraphQL; +using xAiModels.Models.Entities; + +namespace xAiModels.Providers.GraphQL +{ + public class XAiVectorGraphType : XBaseGraphObjectType + { + public XAiVectorGraphType() : base() + { + Field(x => x.Text); + Field(x => x.Metadata); + Field(x => x.Embedding); + } + } +} diff --git a/Providers/XAiVectorEntityRegisterar.cs b/Providers/XAiVectorEntityRegisterar.cs new file mode 100644 index 0000000..4a56de6 --- /dev/null +++ b/Providers/XAiVectorEntityRegisterar.cs @@ -0,0 +1,35 @@ +using System; +using xDataService.Providers; +using xDataService.Interfaces; +using xAiModels.Models.Entities; +using Microsoft.EntityFrameworkCore; +using xAiModels.Configurations.Entities; + +namespace xAiModels.Providers +{ + public class XAiVectorEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar + { + public XAiVectorEntityRegisterar() + : base(nameof(XAiVectorEntityRegisterar)) + { + // + // Add Entity ... + AddEntity(); + } + + /// + /// Configure Entities ... + /// + /// + public override void ConfigureEntities(ModelBuilder modelBuilder) + { + // + // Configure Entity Using Provided ... + modelBuilder + .ApplyConfigurationsFromAssembly(typeof(XAiVectorEntityConfiguration).Assembly); + + // + base.ConfigureEntities(modelBuilder); + } + } +}