---
## خلاصه کامل کارهای انجام شده: ### ✅ تمام فایلهای ایجاد شده برای 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 شد
This commit is contained in:
@@ -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<XAiVector, Guid>
|
||||||
|
{
|
||||||
|
public override void Configure(EntityTypeBuilder<XAiVector> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable(XAiModelsConstants.XAiVectorTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,10 @@ namespace xAiModels.Configurations
|
|||||||
// XAiMessage ...
|
// XAiMessage ...
|
||||||
CreateMap<XAiMessage, XAiMessageDto>();
|
CreateMap<XAiMessage, XAiMessageDto>();
|
||||||
|
|
||||||
|
//
|
||||||
|
// XAiVector ...
|
||||||
|
CreateMap<XAiVector, XAiVectorDto>();
|
||||||
|
|
||||||
//
|
//
|
||||||
// XAiProject ...
|
// XAiProject ...
|
||||||
CreateMap<XAiProject, XAiProjectDto>();
|
CreateMap<XAiProject, XAiProjectDto>();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace xAiModels.Constants
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Table Mapping Identifiers ...
|
// Table Mapping Identifiers ...
|
||||||
|
public const string XAiVectorTable = "AiVectors";
|
||||||
public const string XAiMessageTable = "AiMessages";
|
public const string XAiMessageTable = "AiMessages";
|
||||||
public const string XAiProjectTable = "AiProjects";
|
public const string XAiProjectTable = "AiProjects";
|
||||||
public const string XAiConversationTable = "AiConversations";
|
public const string XAiConversationTable = "AiConversations";
|
||||||
@@ -22,6 +23,9 @@ namespace xAiModels.Constants
|
|||||||
public const string XAiProjectCollectionName = "AiProjectsa";
|
public const string XAiProjectCollectionName = "AiProjectsa";
|
||||||
public const string XAiConversationCollectionName = "aiConversations";
|
public const string XAiConversationCollectionName = "aiConversations";
|
||||||
|
|
||||||
|
public const string XAiVectorSingleName = "aiVector";
|
||||||
|
public const string XAiVectorCollectionName = "aiVectors";
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hubs ...
|
// Hubs ...
|
||||||
public const string XAiMessageDtoHub = "aiMessageDto";
|
public const string XAiMessageDtoHub = "aiMessageDto";
|
||||||
@@ -33,6 +37,9 @@ namespace xAiModels.Constants
|
|||||||
public const string XAiConversationDtoHub = "aiConversationDto";
|
public const string XAiConversationDtoHub = "aiConversationDto";
|
||||||
public const string XAiConversationEntityHub = "aiConversationEntity";
|
public const string XAiConversationEntityHub = "aiConversationEntity";
|
||||||
|
|
||||||
|
public const string XAiVectorDtoHub = "aiVectorDto";
|
||||||
|
public const string XAiVectorEntityHub = "aiVectorEntity";
|
||||||
|
|
||||||
//
|
//
|
||||||
// Resource Provider Identifiers ...
|
// Resource Provider Identifiers ...
|
||||||
public const string XAiProjectTitleIdentifier = "AiPrjT";
|
public const string XAiProjectTitleIdentifier = "AiPrjT";
|
||||||
@@ -44,6 +51,7 @@ namespace xAiModels.Constants
|
|||||||
public const string GetXAiMessageEFRepositoryDescriptor = "GetXAiMessageEFRepositoryDescriptor";
|
public const string GetXAiMessageEFRepositoryDescriptor = "GetXAiMessageEFRepositoryDescriptor";
|
||||||
public const string GetXAiProjectEFRepositoryDescriptor = "GetXAiProjectEFRepositoryDescriptor";
|
public const string GetXAiProjectEFRepositoryDescriptor = "GetXAiProjectEFRepositoryDescriptor";
|
||||||
public const string GetXAiConversationEFRepositoryDescriptor = "GetXAiConversationEFRepositoryDescriptor";
|
public const string GetXAiConversationEFRepositoryDescriptor = "GetXAiConversationEFRepositoryDescriptor";
|
||||||
|
public const string GetXAiVectorEFRepositoryDescriptor = "GetXAiVectorEFRepositoryDescriptor";
|
||||||
|
|
||||||
//
|
//
|
||||||
public const string DefaultXAiProjectTitleResourceID = "XAiPrjT";
|
public const string DefaultXAiProjectTitleResourceID = "XAiPrjT";
|
||||||
|
|||||||
@@ -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<XAiVector, XAiVectorDto, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -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<XAiVector, XAiVectorDto, Guid>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, XAiVectorDto, Guid, XAiVectorDtoHub>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -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 ...
|
||||||
|
/// <summary>
|
||||||
|
/// Enrich Specified Item ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiVectorDto> Enrich(
|
||||||
|
XAiVector source,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enrich Specified Item ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<XAiVectorDto> Enrich(
|
||||||
|
XAiVectorDto source,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enrich Specified Items ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sources"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
||||||
|
IEnumerable<XAiVector> sources,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enrich Specified Items ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sources"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
||||||
|
IEnumerable<XAiVectorDto> sources,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiVectorEntityHub : IXBaseEntityHub<XAiVector, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiVectorGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XAiVector, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiVectorKeyGenerator : IXKeyGenerator<XAiVector, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiVectorRepository : IXBaseRepository<XAiVector, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiVectorRepositoryEvents : IXBaseRepositoryEvents<XAiVector>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid, XAiVectorEntityHub>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiVectorSeeder : IXBaseDbSeeder<XAiVector, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using xModels.Base;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace xAiModels.Models.Dtos
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Vector DTO for AI Vector data ...
|
||||||
|
/// </summary>
|
||||||
|
public class XAiVectorDto : XBaseGuidIDEntityDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Text content of the vector ...
|
||||||
|
/// </summary>
|
||||||
|
public string Text { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Embedding vector representation ...
|
||||||
|
/// </summary>
|
||||||
|
public ReadOnlyMemory<float> Embedding { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Metadata associated with the vector ...
|
||||||
|
/// </summary>
|
||||||
|
public virtual Dictionary<string, string> Metadata { get; set; } = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<string, string> Metadata { get; set; } = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<float> Embedding { get; set; }
|
||||||
|
public virtual Dictionary<string, string> Metadata { get; set; } = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, XAiVectorDto, Guid>, IXAiVectorDtoHub
|
||||||
|
{
|
||||||
|
public XAiVectorDtoHub(
|
||||||
|
ILogger<XAiVectorDtoHub> logger
|
||||||
|
) : base(logger)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, XAiVectorDto, Guid>, IXAiVectorRepositoryService
|
||||||
|
{
|
||||||
|
public XAiVectorRepositoryService(
|
||||||
|
IXAiVectorRepository repository
|
||||||
|
) : base(
|
||||||
|
repository,
|
||||||
|
mapperProfiles:
|
||||||
|
[
|
||||||
|
new XAiModelMappersProfile()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, XAiVectorDto, Guid, XAiVectorDtoHub>, IXAiVectorServiceProvider
|
||||||
|
{
|
||||||
|
public XAiVectorServiceProvider(
|
||||||
|
IHubContext<XAiVectorDtoHub> hub,
|
||||||
|
XDataServiceConfiguration dataConfiguration,
|
||||||
|
IXAiVectorRepositoryService service,
|
||||||
|
IXIdentityProvider identityProvider = null
|
||||||
|
) : base(
|
||||||
|
hub,
|
||||||
|
dataConfiguration,
|
||||||
|
service,
|
||||||
|
identityProvider
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 ...
|
||||||
|
/// <summary>
|
||||||
|
/// Enrich Specified Item ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiVectorDto> Enrich(
|
||||||
|
XAiVector source,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Mapping Default ...
|
||||||
|
var result = source.MapConvert<XAiVectorDto, XAiVector>();
|
||||||
|
result = await Enrich(
|
||||||
|
source: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enrich Specified Item ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<XAiVectorDto> Enrich(
|
||||||
|
XAiVectorDto source,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Currently no additional enrichment needed for XAiVector
|
||||||
|
// This can be extended in the future if needed
|
||||||
|
return await Task.FromResult(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enrich Specified Items ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sources"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
||||||
|
IEnumerable<XAiVector> sources,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var tasks = sources
|
||||||
|
.Select(x => Enrich(
|
||||||
|
source: x,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
));
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Task.WhenAll(tasks);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enrich Specified Items ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sources"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
||||||
|
IEnumerable<XAiVectorDto> sources,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var tasks = sources
|
||||||
|
.Select(x => Enrich(
|
||||||
|
source: x,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
));
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Task.WhenAll(tasks);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<TContext> : XBaseEFRepository<XAiVector, Guid, TContext>, IXAiVectorRepository
|
||||||
|
where TContext : XDbContext
|
||||||
|
{
|
||||||
|
public XAiVectorEFRepository(
|
||||||
|
IXUnitOfWorks<TContext> unitOfWorks,
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
IXAiVectorKeyGenerator keyGenerator = null,
|
||||||
|
IXAiVectorRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(
|
||||||
|
unitOfWorks,
|
||||||
|
configuration,
|
||||||
|
keyGenerator,
|
||||||
|
baseRepositoryEvents
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid>, IXAiVectorEntityHub
|
||||||
|
{
|
||||||
|
public XAiVectorEntityHub(
|
||||||
|
ILogger<XAiVectorEntityHub> logger
|
||||||
|
) : base(logger)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid>, IXAiVectorRepository
|
||||||
|
{
|
||||||
|
public XAiVectorInMemoryRepository(
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
IXAiVectorKeyGenerator keyGenerator = null,
|
||||||
|
IXAiVectorRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(
|
||||||
|
configuration,
|
||||||
|
keyGenerator,
|
||||||
|
baseRepositoryEvents
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using xDataService.Providers;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XAiVectorKeyGenerator : XGuidKeyGenerator<XAiVector>, IXAiVectorKeyGenerator
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid>, IXAiVectorRepository
|
||||||
|
{
|
||||||
|
public XAiVectorMongoRepository(
|
||||||
|
XDataBaseConfiguration dbConfiguration,
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
string collectionName = null,
|
||||||
|
IXAiVectorKeyGenerator keyGenerator = null,
|
||||||
|
IXAiVectorRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(
|
||||||
|
dbConfiguration,
|
||||||
|
configuration,
|
||||||
|
collectionName,
|
||||||
|
keyGenerator,
|
||||||
|
baseRepositoryEvents
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using xDataService.Providers;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XAiVectorRepositoryEvents : XBaseRepositoryEvents<XAiVector>, IXAiVectorRepositoryEvents
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid, XAiVectorEntityHub>, IXAiVectorRepositoryProvider
|
||||||
|
{
|
||||||
|
public XAiVectorRepositoryProvider(
|
||||||
|
IHubContext<XAiVectorEntityHub> hub,
|
||||||
|
IXAiVectorRepository repository,
|
||||||
|
XDataServiceConfiguration dataConfiguration,
|
||||||
|
IXIdentityProvider identityProvider = null
|
||||||
|
) : base(
|
||||||
|
hub,
|
||||||
|
repository,
|
||||||
|
dataConfiguration,
|
||||||
|
identityProvider
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid>, IXAiVectorSeeder
|
||||||
|
{
|
||||||
|
protected XAiVectorSeederBase(
|
||||||
|
string entity,
|
||||||
|
string database,
|
||||||
|
IXAiVectorRepository repository,
|
||||||
|
XDataServiceConfiguration dataServiceConfiguration
|
||||||
|
) : base(
|
||||||
|
entity,
|
||||||
|
database,
|
||||||
|
repository,
|
||||||
|
dataServiceConfiguration
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid>, IXAiVectorGraphQLTypeHelper
|
||||||
|
{
|
||||||
|
public override string GetInQueryCollectionName()
|
||||||
|
{
|
||||||
|
return XAiModelsConstants.XAiVectorCollectionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetInQuerySingleName()
|
||||||
|
{
|
||||||
|
return XAiModelsConstants.XAiVectorSingleName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid, XAiVectorGraphType, GuidGraphType>
|
||||||
|
{
|
||||||
|
public XAiVectorGraphQuery(
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
IXAiVectorRepository repository,
|
||||||
|
IXAiVectorGraphQLTypeHelper helper
|
||||||
|
) : base(
|
||||||
|
configuration,
|
||||||
|
repository,
|
||||||
|
helper
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.GraphQL;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.GraphQL
|
||||||
|
{
|
||||||
|
public class XAiVectorGraphType : XBaseGraphObjectType<XAiVector, Guid>
|
||||||
|
{
|
||||||
|
public XAiVectorGraphType() : base()
|
||||||
|
{
|
||||||
|
Field(x => x.Text);
|
||||||
|
Field(x => x.Metadata);
|
||||||
|
Field(x => x.Embedding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<XAiVector, Guid>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configure Entities ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelBuilder"></param>
|
||||||
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Configure Entity Using Provided ...
|
||||||
|
modelBuilder
|
||||||
|
.ApplyConfigurationsFromAssembly(typeof(XAiVectorEntityConfiguration).Assembly);
|
||||||
|
|
||||||
|
//
|
||||||
|
base.ConfigureEntities(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user