Compare commits
22
Commits
90ce6842f6
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c05a389a44 | ||
|
|
185aaae19a | ||
|
|
4fe5d57d37 | ||
|
|
27b9f51dc9 | ||
|
|
08fd26ffac | ||
|
|
476ace743d | ||
|
|
c53553e1cf | ||
|
|
33dda6bee7 | ||
|
|
7ba0916461 | ||
|
|
2d44ec8744 | ||
|
|
25534f0273 | ||
|
|
9668f26ffe | ||
|
|
62aa8d51e6 | ||
|
|
9e7710e345 | ||
|
|
c4b7e86174 | ||
|
|
1b74f23a18 | ||
|
|
146137c908 | ||
|
|
31a0d097c0 | ||
|
|
ef1421def4 | ||
|
|
093fc08e14 | ||
|
|
5f518b86b2 | ||
|
|
34539cd764 |
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace xAiModels.Attributes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Decorate and Describe Specified MCP Tool to LLM ...
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
|
||||||
|
public class XAiMcpToolAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tools Unique Name (Default: Method Name) ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tools Description for LLM ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specify it's Required to Authenticated or not ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public bool RequiresAuthentication { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Authorization and Policiy ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string RequiredPolicy { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public XAiMcpToolAttribute(string name = null)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace xAiModels.Attributes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describe Specific Tools Parameter Metadata ...
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
|
||||||
|
public sealed class XAiMcpToolParamAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parameter Name in JSON (Default Parameter Name) ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describe Parameter to LLM ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specified this Parameter is Required or not (Default is true) ...
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public bool Required { get; set; } = true;
|
||||||
|
|
||||||
|
public XAiMcpToolParamAttribute(string name = null)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace xAiModels.Attributes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Decorate Tools Classes ...
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
||||||
|
public class XAiMcpToolTypeAttribute : Attribute { }
|
||||||
|
}
|
||||||
@@ -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 XAiMcpServerEntityConfiguration : XBaseEntityTypeConfiguration<XAiMcpServer, Guid>
|
||||||
|
{
|
||||||
|
public override void Configure(EntityTypeBuilder<XAiMcpServer> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable(XAiModelsConstants.XAiMcpServerTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,16 @@ namespace xAiModels.Configurations.Entities
|
|||||||
{
|
{
|
||||||
public override void Configure(EntityTypeBuilder<XAiVector> builder)
|
public override void Configure(EntityTypeBuilder<XAiVector> builder)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
builder.ToTable(XAiModelsConstants.XAiVectorTable);
|
builder.ToTable(XAiModelsConstants.XAiVectorTable);
|
||||||
|
|
||||||
|
//
|
||||||
|
builder.Property(x => x.Type).HasMaxLength(100);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Indexes for Prefix Scoped Search and Type Filtering ...
|
||||||
|
builder.HasIndex(x => x.Identifier);
|
||||||
|
builder.HasIndex(x => x.Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
using xAiModels.Models;
|
|
||||||
using xAiModels.Constants;
|
|
||||||
|
|
||||||
namespace xAiModels.Configurations
|
|
||||||
{
|
|
||||||
public class XAiApiConfiguration
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Model Providers ...
|
|
||||||
/// </summary>
|
|
||||||
public XAiModelDescriptor[] Models { get; set; } = [];
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Each User must Has a Default Project, this is Title Resource Identifier ...
|
|
||||||
/// </summary>
|
|
||||||
public string DefaultProjectTitleResource { get; set; } = XAiModelsConstants.DefaultXAiProjectTitleResourceID;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Each User must Has a Default Project, this is Description Resource Identifier ...
|
|
||||||
/// </summary>
|
|
||||||
public string DefaultProjectDescriptionResource { get; set; } = XAiModelsConstants.DefaultXAiProjectDescriptionResourceID;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Each User must Has a Default Conversation, this is Title Resource Identifier ... ...
|
|
||||||
/// </summary>
|
|
||||||
public string DefaultConversationTitleResource { get; set; } = XAiModelsConstants.DefaultXAiConversationTitleResourceID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,6 +25,10 @@ namespace xAiModels.Configurations
|
|||||||
// XAiProject ...
|
// XAiProject ...
|
||||||
CreateMap<XAiProject, XAiProjectDto>();
|
CreateMap<XAiProject, XAiProjectDto>();
|
||||||
|
|
||||||
|
//
|
||||||
|
CreateMap<XAiMcpServer, XAiMcpServerDto>();
|
||||||
|
CreateMap<XAiMcpServerDto, XAiMcpServer>();
|
||||||
|
|
||||||
//
|
//
|
||||||
// XAiConversation ...
|
// XAiConversation ...
|
||||||
CreateMap<XAiConversation, XAiConversationDto>();
|
CreateMap<XAiConversation, XAiConversationDto>();
|
||||||
|
|||||||
@@ -21,17 +21,6 @@ namespace xAiModels.Constants
|
|||||||
[StringValue("ProjectRemoved")]
|
[StringValue("ProjectRemoved")]
|
||||||
ProjectRemoved,
|
ProjectRemoved,
|
||||||
|
|
||||||
//
|
|
||||||
// Conversation ...
|
|
||||||
[StringValue("ConversationCreated")]
|
|
||||||
ConversationCreated,
|
|
||||||
|
|
||||||
[StringValue("ConversationUpdated")]
|
|
||||||
ConversationUpdated,
|
|
||||||
|
|
||||||
[StringValue("ConversationRemoved")]
|
|
||||||
ConversationRemoved,
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Message ...
|
// Message ...
|
||||||
[StringValue("MessageCreated")]
|
[StringValue("MessageCreated")]
|
||||||
@@ -42,5 +31,27 @@ namespace xAiModels.Constants
|
|||||||
|
|
||||||
[StringValue("MessageRemoved")]
|
[StringValue("MessageRemoved")]
|
||||||
MessageRemoved,
|
MessageRemoved,
|
||||||
|
|
||||||
|
//
|
||||||
|
// MCPServer ...
|
||||||
|
[StringValue("McpServerCreated")]
|
||||||
|
McpServerCreated,
|
||||||
|
|
||||||
|
[StringValue("McpServerUpdated")]
|
||||||
|
McpServerUpdated,
|
||||||
|
|
||||||
|
[StringValue("McpServerRemoved")]
|
||||||
|
McpServerRemoved,
|
||||||
|
|
||||||
|
//
|
||||||
|
// Conversation ...
|
||||||
|
[StringValue("ConversationCreated")]
|
||||||
|
ConversationCreated,
|
||||||
|
|
||||||
|
[StringValue("ConversationUpdated")]
|
||||||
|
ConversationUpdated,
|
||||||
|
|
||||||
|
[StringValue("ConversationRemoved")]
|
||||||
|
ConversationRemoved,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using xExceptions.Attributes;
|
||||||
|
|
||||||
|
namespace xAiModels.Constants
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Knowledge Base Scope (Where Ingested Vectors are Visible) ...
|
||||||
|
/// Identifier Layout: "{scopePrefix}/{scopeKey}/{fileName}#{chunkIndex}" (Global has no scopeKey) ...
|
||||||
|
/// </summary>
|
||||||
|
public enum XAiKnowledgeScope
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Visible only Inside a Conversation (Key = ConversationId) ...
|
||||||
|
/// </summary>
|
||||||
|
[StringValue(XAiModelsConstants.XAiKnowledgeConversationPrefix)]
|
||||||
|
Conversation = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Visible to all Conversations of a Project (Key = ProjectId) ...
|
||||||
|
/// </summary>
|
||||||
|
[StringValue(XAiModelsConstants.XAiKnowledgeProjectPrefix)]
|
||||||
|
Project = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Visible to Everyone (Write Requires Admin Role) ...
|
||||||
|
/// </summary>
|
||||||
|
[StringValue(XAiModelsConstants.XAiKnowledgeGlobalPrefix)]
|
||||||
|
Global = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Personal Knowledge Base of Owner (Key = UserId) ...
|
||||||
|
/// </summary>
|
||||||
|
[StringValue(XAiModelsConstants.XAiKnowledgeUserPrefix)]
|
||||||
|
User = 3,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
namespace xAiModels.Constants
|
||||||
|
{
|
||||||
|
public struct XAiMcpConstants
|
||||||
|
{
|
||||||
|
//
|
||||||
|
public const string XAiMcpProtocol = "2024-11-05";
|
||||||
|
public const string XAiMcpClientName = "XAiMcpClient";
|
||||||
|
public const string XAiMcpSessionIdentifier = "Mcp-Session-Id";
|
||||||
|
public const string XAiMcpProtocolIdentifier = "MCP-Protocol-Version";
|
||||||
|
|
||||||
|
//
|
||||||
|
public const string TextKey = "text";
|
||||||
|
public const string ContentKey = "content";
|
||||||
|
public const string ServerInfoNameKey = "name";
|
||||||
|
public const string ServerInfoKey = "serverInfo";
|
||||||
|
public const string ServerInfoVersionKey = "version";
|
||||||
|
public const string ProtocolVersionKey = "protocolVersion";
|
||||||
|
|
||||||
|
//
|
||||||
|
public const string serverInfoNameValue = "xAiApi";
|
||||||
|
public const string serverInfoVersionValue = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using xExceptions.Attributes;
|
||||||
|
|
||||||
|
namespace xAiModels.Constants
|
||||||
|
{
|
||||||
|
public enum XAiMcpMethods
|
||||||
|
{
|
||||||
|
[StringValue("initialize")]
|
||||||
|
Initialize,
|
||||||
|
|
||||||
|
[StringValue("tools/list")]
|
||||||
|
ToolsList,
|
||||||
|
|
||||||
|
[StringValue("tools/call")]
|
||||||
|
ToolsCall,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using xExceptions.Attributes;
|
||||||
|
|
||||||
|
namespace xAiModels.Constants
|
||||||
|
{
|
||||||
|
public enum XAiMcpServerUsageScope
|
||||||
|
{
|
||||||
|
[StringValue(XAiModelsConstants.XAiMcpServerUsageScopeAll)]
|
||||||
|
All = 1,
|
||||||
|
|
||||||
|
[StringValue(XAiModelsConstants.XAiMcpServerUsageScopeOwner)]
|
||||||
|
Owner = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,16 +11,19 @@ namespace xAiModels.Constants
|
|||||||
public const string XAiVectorTable = "AiVectors";
|
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 XAiMcpServerTable = "AiMcpServers";
|
||||||
public const string XAiConversationTable = "AiConversations";
|
public const string XAiConversationTable = "AiConversations";
|
||||||
|
|
||||||
//
|
//
|
||||||
// GraphQL Collection Mappings ...
|
// GraphQL Collection Mappings ...
|
||||||
public const string XAiMessageSingleName = "aiMessage";
|
public const string XAiMessageSingleName = "aiMessage";
|
||||||
public const string XAiProjectSingleName = "aiProject";
|
public const string XAiProjectSingleName = "aiProject";
|
||||||
|
public const string XAiMcpServerSingleName = "aiMcpServer";
|
||||||
public const string XAiConversationSignleName = "aiConversation";
|
public const string XAiConversationSignleName = "aiConversation";
|
||||||
|
|
||||||
public const string XAiMessageCollectionName = "aiMessages";
|
public const string XAiMessageCollectionName = "aiMessages";
|
||||||
public const string XAiProjectCollectionName = "AiProjectsa";
|
public const string XAiProjectCollectionName = "AiProjectsa";
|
||||||
|
public const string XAiMcpServerCollectionName = "aiMcpServers";
|
||||||
public const string XAiConversationCollectionName = "aiConversations";
|
public const string XAiConversationCollectionName = "aiConversations";
|
||||||
|
|
||||||
public const string XAiVectorSingleName = "aiVector";
|
public const string XAiVectorSingleName = "aiVector";
|
||||||
@@ -34,6 +37,9 @@ namespace xAiModels.Constants
|
|||||||
public const string XAiProjectDtoHub = "aiProjectDto";
|
public const string XAiProjectDtoHub = "aiProjectDto";
|
||||||
public const string XAiProjectEntityHub = "aiProjectEntity";
|
public const string XAiProjectEntityHub = "aiProjectEntity";
|
||||||
|
|
||||||
|
public const string XAiMcpServerDtoHub = "aiMcpServerDto";
|
||||||
|
public const string XAiMcpServerEntityHub = "aiMcpServerEntity";
|
||||||
|
|
||||||
public const string XAiConversationDtoHub = "aiConversationDto";
|
public const string XAiConversationDtoHub = "aiConversationDto";
|
||||||
public const string XAiConversationEntityHub = "aiConversationEntity";
|
public const string XAiConversationEntityHub = "aiConversationEntity";
|
||||||
|
|
||||||
@@ -48,10 +54,11 @@ namespace xAiModels.Constants
|
|||||||
|
|
||||||
//
|
//
|
||||||
// EF Repositories Helper Extensions ...
|
// EF Repositories Helper Extensions ...
|
||||||
|
public const string GetXAiVectorEFRepositoryDescriptor = "GetXAiVectorEFRepositoryDescriptor";
|
||||||
public const string GetXAiMessageEFRepositoryDescriptor = "GetXAiMessageEFRepositoryDescriptor";
|
public const string GetXAiMessageEFRepositoryDescriptor = "GetXAiMessageEFRepositoryDescriptor";
|
||||||
public const string GetXAiProjectEFRepositoryDescriptor = "GetXAiProjectEFRepositoryDescriptor";
|
public const string GetXAiProjectEFRepositoryDescriptor = "GetXAiProjectEFRepositoryDescriptor";
|
||||||
|
public const string GetXAiMcpServerEFRepositoryDescriptor = "GetXAiMcpServerEFRepositoryDescriptor";
|
||||||
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";
|
||||||
@@ -59,6 +66,35 @@ namespace xAiModels.Constants
|
|||||||
public const string DefaultXAiProjectDescriptionResourceID = "XAiPrjD";
|
public const string DefaultXAiProjectDescriptionResourceID = "XAiPrjD";
|
||||||
|
|
||||||
//
|
//
|
||||||
public const string XOpenAINoKey = "no-key-required";
|
public const string XOpenAINoKey = "no-key-required";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Knowledge (Persistent RAG) ...
|
||||||
|
public const string XAiDefaultKnowledgeType = "XAiKnowledge";
|
||||||
|
public const string XAiKnowledgeSeparator = "/";
|
||||||
|
public const string XAiKnowledgeOwnerSeparator = "/";
|
||||||
|
public const string XAiKnowledgeChunkSeparator = "#";
|
||||||
|
public const string XAiKnowledgeUserPrefix = "user";
|
||||||
|
public const string XAiKnowledgeGlobalPrefix = "global";
|
||||||
|
public const string XAiKnowledgeProjectPrefix = "project";
|
||||||
|
public const string XAiKnowledgeConversationPrefix = "conversation";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Error Handler Route (Production) ...
|
||||||
|
public const string XAiErrorRoute = "/error";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Knowledge Metadata Keys ...
|
||||||
|
public const string XAiKnowledgeMetadataType = "type";
|
||||||
|
public const string XAiKnowledgeMetadataScope = "scope";
|
||||||
|
public const string XAiKnowledgeMetadataScopeId = "scopeId";
|
||||||
|
public const string XAiKnowledgeMetadataOwnerId = "ownerId";
|
||||||
|
public const string XAiKnowledgeMetadataIngestedAtUtc = "ingestedAtUtc";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Mcp Server ...
|
||||||
|
public const int XAiMcpServerMinTimeoutSeconds = 30;
|
||||||
|
public const string XAiMcpServerUsageScopeAll = "All";
|
||||||
|
public const string XAiMcpServerUsageScopeOwner = "Owner";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+63
-103
@@ -100,6 +100,11 @@ namespace xAiModels.DI
|
|||||||
pushHelper.AddHub<XAiProjectDtoHub>(XAiModelsConstants.XAiProjectDtoHub);
|
pushHelper.AddHub<XAiProjectDtoHub>(XAiModelsConstants.XAiProjectDtoHub);
|
||||||
pushHelper.AddHub<XAiProjectEntityHub>(XAiModelsConstants.XAiProjectEntityHub);
|
pushHelper.AddHub<XAiProjectEntityHub>(XAiModelsConstants.XAiProjectEntityHub);
|
||||||
|
|
||||||
|
//
|
||||||
|
// XAiMcpServer ...
|
||||||
|
pushHelper.AddHub<XAiMcpServerDtoHub>(XAiModelsConstants.XAiMcpServerDtoHub);
|
||||||
|
pushHelper.AddHub<XAiMcpServerEntityHub>(XAiModelsConstants.XAiMcpServerEntityHub);
|
||||||
|
|
||||||
//
|
//
|
||||||
// XAiConversation ...
|
// XAiConversation ...
|
||||||
pushHelper.AddHub<XAiConversationDtoHub>(XAiModelsConstants.XAiConversationDtoHub);
|
pushHelper.AddHub<XAiConversationDtoHub>(XAiModelsConstants.XAiConversationDtoHub);
|
||||||
@@ -143,109 +148,15 @@ namespace xAiModels.DI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create an Scope for Services Acces ...
|
// Using XAiMcpServer Repository Descriptor ...
|
||||||
// Handle Seeding Category/SubCategory Resources ...
|
if (!aiMcpServerDescriptor.IsNull())
|
||||||
// TODO: Enable Seeding if Required ...
|
{
|
||||||
// using (var scope = app.ApplicationServices.CreateScope())
|
//
|
||||||
// {
|
app.UseXRepository(
|
||||||
// //
|
descriptor: aiMcpServerDescriptor,
|
||||||
// // Retrieve Configuratuions ...
|
isDevelopmentEnvironment: isDevelopmentEnvironment
|
||||||
// var aiMessageProvider = scope.ServiceProvider.GetService<IXAiMessageServiceProvider>();
|
);
|
||||||
// var aiProjectProvider = scope.ServiceProvider.GetService<IXAiProjectServiceProvider>();
|
}
|
||||||
// var aiConversationProvider = scope.ServiceProvider.GetService<IXAiConversationServiceProvider>();
|
|
||||||
// var configuration = scope.ServiceProvider.GetService<XAiDataServiceServiceConfiguration>();
|
|
||||||
// if (!configuration.IsNullOrDefault() &&
|
|
||||||
// !categoryProvider.IsNullOrDefault() &&
|
|
||||||
// !subaiConversationDescriptor.IsNullOrDefault()
|
|
||||||
// )
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// // Logging ...
|
|
||||||
// Log("Start Seeding ...");
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Count Data in Category ...
|
|
||||||
// var hasCategory = (categoryProvider.Count().GetAwaiter().GetResult()) > 0;
|
|
||||||
// var hasSubCategory = (subCategoryProvider.Count().GetAwaiter().GetResult()) > 0;
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Seed Category Resources ...
|
|
||||||
// var canSeed =
|
|
||||||
// !hasCategory &&
|
|
||||||
// configuration.Categories.HasChild();
|
|
||||||
// if (canSeed)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// // Loop through Provided items ...
|
|
||||||
// foreach (var cat in configuration.Categories)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// Log($"Start Seeding Category: {cat.Titles.Locales.ToArray()[0].Value} ...");
|
|
||||||
|
|
||||||
// //
|
|
||||||
// categoryProvider.Refresh(
|
|
||||||
// resource: cat,
|
|
||||||
// userInfo: null,
|
|
||||||
// connectionId: null,
|
|
||||||
// cancellationToken: default
|
|
||||||
// )
|
|
||||||
// .GetAwaiter()
|
|
||||||
// .GetResult();
|
|
||||||
|
|
||||||
// //
|
|
||||||
// Log($"Seeding Category: {cat.Titles.Locales.ToArray()[0].Value} Finished Successfully ...");
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// Log($"Seeding Category: {cat.Titles.Locales.ToArray()[0].Value} Failed due: {ex.Message} ...");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Seed SubCategory Resources ...
|
|
||||||
// canSeed =
|
|
||||||
// !hasSubCategory &&
|
|
||||||
// configuration.SubCategories.HasChild();
|
|
||||||
// if (canSeed)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// // Loop through Provided items ...
|
|
||||||
// foreach (var subcat in configuration.SubCategories)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// Log($"Start Seeding SubCategory: {subcat.Titles.Locales.ToArray()[0].Value} ...");
|
|
||||||
|
|
||||||
// //
|
|
||||||
// subCategoryProvider.Refresh(
|
|
||||||
// userInfo: null,
|
|
||||||
// resource: subcat,
|
|
||||||
// connectionId: null,
|
|
||||||
// cancellationToken: default
|
|
||||||
// )
|
|
||||||
// .GetAwaiter()
|
|
||||||
// .GetResult();
|
|
||||||
|
|
||||||
// //
|
|
||||||
// Log($"Seeding SubCategory: {subcat.Titles.Locales.ToArray()[0].Value} Finished Successfully ...");
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// Log($"Seeding SubCategory: {subcat.Titles.Locales.ToArray()[0].Value} Failed due: {ex.Message} ...");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// Log("Finish Seeding ...");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -253,6 +164,7 @@ namespace xAiModels.DI
|
|||||||
private static XRepositoryDescriptor aiVectorDescriptor = null;
|
private static XRepositoryDescriptor aiVectorDescriptor = null;
|
||||||
private static XRepositoryDescriptor aiMessageDescriptor = null;
|
private static XRepositoryDescriptor aiMessageDescriptor = null;
|
||||||
private static XRepositoryDescriptor aiProjectDescriptor = null;
|
private static XRepositoryDescriptor aiProjectDescriptor = null;
|
||||||
|
private static XRepositoryDescriptor aiMcpServerDescriptor = null;
|
||||||
private static XRepositoryDescriptor aiConversationDescriptor = null;
|
private static XRepositoryDescriptor aiConversationDescriptor = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -355,6 +267,15 @@ namespace xAiModels.DI
|
|||||||
methodName: XAiModelsConstants.GetXAiProjectEFRepositoryDescriptor
|
methodName: XAiModelsConstants.GetXAiProjectEFRepositoryDescriptor
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// XAiMcpServer ...
|
||||||
|
aiMcpServerDescriptor = typeof(XAiModelsHelper)
|
||||||
|
.InvokeGenericMethod<XRepositoryDescriptor>(
|
||||||
|
args: null,
|
||||||
|
runtimeType: contextType,
|
||||||
|
methodName: XAiModelsConstants.GetXAiMcpServerEFRepositoryDescriptor
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// XAiConversation ...
|
// XAiConversation ...
|
||||||
aiConversationDescriptor = typeof(XAiModelsHelper)
|
aiConversationDescriptor = typeof(XAiModelsHelper)
|
||||||
@@ -379,6 +300,10 @@ namespace xAiModels.DI
|
|||||||
// XAiProject ...
|
// XAiProject ...
|
||||||
aiProjectDescriptor = XAiModelsHelper.GetXAiProjectMongoRepositoryDescriptor();
|
aiProjectDescriptor = XAiModelsHelper.GetXAiProjectMongoRepositoryDescriptor();
|
||||||
|
|
||||||
|
//
|
||||||
|
// XAiMcpServer ...
|
||||||
|
aiMcpServerDescriptor = XAiModelsHelper.GetXAiMcpServerMongoRepositoryDescriptor();
|
||||||
|
|
||||||
//
|
//
|
||||||
// XAiConversation ...
|
// XAiConversation ...
|
||||||
aiConversationDescriptor = XAiModelsHelper.GetXAiConversationMongoRepositoryDescriptor();
|
aiConversationDescriptor = XAiModelsHelper.GetXAiConversationMongoRepositoryDescriptor();
|
||||||
@@ -398,6 +323,10 @@ namespace xAiModels.DI
|
|||||||
// XAiProject ...
|
// XAiProject ...
|
||||||
aiProjectDescriptor = XAiModelsHelper.GetXAiProjectInMemoryRepositoryDescriptor();
|
aiProjectDescriptor = XAiModelsHelper.GetXAiProjectInMemoryRepositoryDescriptor();
|
||||||
|
|
||||||
|
//
|
||||||
|
// XAiMcpServer ...
|
||||||
|
aiMcpServerDescriptor = XAiModelsHelper.GetXAiMcpServerInMemoryRepositoryDescriptor();
|
||||||
|
|
||||||
//
|
//
|
||||||
// XAiConversation ...
|
// XAiConversation ...
|
||||||
aiConversationDescriptor = XAiModelsHelper.GetXAiConversationInMemoryRepositoryDescriptor();
|
aiConversationDescriptor = XAiModelsHelper.GetXAiConversationInMemoryRepositoryDescriptor();
|
||||||
@@ -439,6 +368,17 @@ namespace xAiModels.DI
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XAiMcpServer ...
|
||||||
|
if (!aiMcpServerDescriptor.IsNull())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
services.AddXRepository(
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
descriptor: aiMcpServerDescriptor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// XAiConversation ...
|
// XAiConversation ...
|
||||||
if (!aiConversationDescriptor.IsNull())
|
if (!aiConversationDescriptor.IsNull())
|
||||||
@@ -522,6 +462,26 @@ namespace xAiModels.DI
|
|||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region AiMcpServer ...
|
||||||
|
//
|
||||||
|
services.Add(
|
||||||
|
new ServiceDescriptor(typeof(IXAiMcpServerServiceProvider), typeof(XAiMcpServerServiceProvider), lifeTime)
|
||||||
|
);
|
||||||
|
services.Add(
|
||||||
|
new ServiceDescriptor(typeof(IXAiMcpServerRepositoryService), typeof(XAiMcpServerRepositoryService), lifeTime)
|
||||||
|
);
|
||||||
|
services.Add(
|
||||||
|
new ServiceDescriptor(typeof(IXAiMcpServerRepositoryProvider), typeof(XAiMcpServerRepositoryProvider), lifeTime)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enrichers ...
|
||||||
|
services.Add(
|
||||||
|
new ServiceDescriptor(typeof(IXAiMcpServerEnricher), typeof(XAiMcpServerEnricher), lifeTime)
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
#region AiConversation ...
|
#region AiConversation ...
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ namespace xAiModels.Extensions
|
|||||||
source is not null &&
|
source is not null &&
|
||||||
!source.IsNullOrDefault() &&
|
!source.IsNullOrDefault() &&
|
||||||
!string.IsNullOrWhiteSpace(source.Text) &&
|
!string.IsNullOrWhiteSpace(source.Text) &&
|
||||||
source.FinishReason == ChatFinishReason.Stop;
|
(source.FinishReason == ChatFinishReason.Stop ||
|
||||||
|
source.FinishReason == ChatFinishReason.ToolCalls);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using xAiModels.Models;
|
|
||||||
using xCommons.Extensions;
|
|
||||||
using xAiModels.Configurations;
|
|
||||||
|
|
||||||
namespace xAiModels.Extensions
|
|
||||||
{
|
|
||||||
public static class XAiApiConfigurationExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Validate Api Configuration ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool IsValid(this XAiApiConfiguration source)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
!source.IsNullOrDefault() &&
|
|
||||||
source.Models.HasChild();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve Default Model Descriptor ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static XAiModelDescriptor GetDefaultModel(this XAiApiConfiguration source)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XAiModelDescriptor result = null;
|
|
||||||
|
|
||||||
//
|
|
||||||
if (source.IsValid())
|
|
||||||
{
|
|
||||||
result = source.Models.First();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,8 +29,7 @@ namespace xAiModels.Extensions
|
|||||||
//
|
//
|
||||||
var result =
|
var result =
|
||||||
!source.IsNullOrDefault() &&
|
!source.IsNullOrDefault() &&
|
||||||
!source.OwnerId.IsNullOrEmpty() &&
|
!source.OwnerId.IsNullOrEmpty();
|
||||||
!source.Prompt.IsNullOrEmpty();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -40,8 +39,7 @@ namespace xAiModels.Extensions
|
|||||||
//
|
//
|
||||||
var result =
|
var result =
|
||||||
!source.IsNullOrDefault() &&
|
!source.IsNullOrDefault() &&
|
||||||
!source.OwnerId.IsNullOrEmpty() &&
|
!source.OwnerId.IsNullOrEmpty();
|
||||||
!source.Prompt.IsNullOrEmpty();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -57,9 +55,7 @@ namespace xAiModels.Extensions
|
|||||||
//
|
//
|
||||||
var result =
|
var result =
|
||||||
!source.IsNullOrDefault() &&
|
!source.IsNullOrDefault() &&
|
||||||
!source.OwnerId.IsNullOrEmpty() &&
|
!source.OwnerId.IsNullOrEmpty();
|
||||||
!source.ProjectId.IsNull() &&
|
|
||||||
!source.ProjectId.IsDefaultGuid();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -69,9 +65,7 @@ namespace xAiModels.Extensions
|
|||||||
//
|
//
|
||||||
var result =
|
var result =
|
||||||
!source.IsNullOrDefault() &&
|
!source.IsNullOrDefault() &&
|
||||||
!source.OwnerId.IsNullOrEmpty() &&
|
!source.OwnerId.IsNullOrEmpty();
|
||||||
!source.ProjectId.IsNull() &&
|
|
||||||
!source.ProjectId.IsDefaultGuid();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -111,6 +105,36 @@ namespace xAiModels.Extensions
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validate a McpServer for Add Or Update ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsValidForAddOrUpdate(this XAiMcpServer source)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result =
|
||||||
|
!source.IsNullOrDefault() &&
|
||||||
|
!source.Name.IsNullOrEmpty() &&
|
||||||
|
!source.OwnerId.IsNullOrEmpty() &&
|
||||||
|
!source.Endpoint.IsNullOrEmpty();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public static bool IsValidForAddOrUpdate(this XAiMcpServerDto source)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result =
|
||||||
|
!source.IsNullOrDefault() &&
|
||||||
|
!source.Name.IsNullOrEmpty() &&
|
||||||
|
!source.OwnerId.IsNullOrEmpty() &&
|
||||||
|
!source.Endpoint.IsNullOrEmpty();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validate a Model Descriptor ...
|
/// Validate a Model Descriptor ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -267,7 +291,7 @@ namespace xAiModels.Extensions
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate Args ...
|
// Validate Args ...
|
||||||
if (source.HasChild() ||
|
if (!source.HasChild() ||
|
||||||
ownerId.IsNullOrEmpty())
|
ownerId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
@@ -306,7 +330,7 @@ namespace xAiModels.Extensions
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate Args ...
|
// Validate Args ...
|
||||||
if (source.HasChild() ||
|
if (!source.HasChild() ||
|
||||||
projectId.IsDefaultGuid())
|
projectId.IsDefaultGuid())
|
||||||
{
|
{
|
||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
@@ -339,7 +363,7 @@ namespace xAiModels.Extensions
|
|||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
/// <param name="ownerId"></param>
|
/// <param name="ownerId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Guid GetDafualtProject(
|
public static Guid GetDafaultProject(
|
||||||
this IEnumerable<XAiProjectDto> source,
|
this IEnumerable<XAiProjectDto> source,
|
||||||
string ownerId
|
string ownerId
|
||||||
)
|
)
|
||||||
@@ -423,7 +447,7 @@ namespace xAiModels.Extensions
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static ChatMessage ToChatMessages(
|
public static ChatMessage ToChatMessages(
|
||||||
this XAiMessageDto source,
|
this XAiMessageDto source,
|
||||||
IList<AIContent> additionalContents = null
|
IList<AIContent> additionalContents = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -494,5 +518,35 @@ namespace xAiModels.Extensions
|
|||||||
value: $"{XAuthorization.TokenIdentifier} {apiKey}"
|
value: $"{XAuthorization.TokenIdentifier} {apiKey}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts To AITools ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IList<AITool> ToAITools(
|
||||||
|
this IList<XAiMcpToolDefinition> source
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new List<AITool>();
|
||||||
|
|
||||||
|
//
|
||||||
|
foreach (var tool in source)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var declaration = AIFunctionFactory.CreateDeclaration(
|
||||||
|
name: tool.Name,
|
||||||
|
jsonSchema: tool.InputSchema,
|
||||||
|
description: tool.Description
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result.Add(declaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
using System;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace xAiModels.Extensions
|
namespace xAiModels.Extensions
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,8 @@ namespace xAiModels.Extensions
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
if (source.IsNullOrEmpty()) {
|
if (source.IsNullOrEmpty())
|
||||||
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,24 +32,19 @@ namespace xAiModels.Extensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts to Meta Data Representation ...
|
/// Converts ReadOnly Memory to Embedding Representation ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Dictionary<string, string> AsMetadat(this string source)
|
public static string ToEmbedding(this ReadOnlyMemory<float> source)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate ...
|
var result = string.Empty;
|
||||||
if (source.IsNullOrEmpty()) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// JSON is expected to be like: [0.12, 0.34, ...] ...
|
if (!source.IsNull() && !source.IsEmpty)
|
||||||
var result = source.FromJSON<Dictionary<string, string>>();
|
|
||||||
if (!result.HasChild())
|
|
||||||
{
|
{
|
||||||
result = [];
|
result = source.ToArray().ToJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using System.Numerics.Tensors;
|
||||||
|
using xExceptions.Constants;
|
||||||
|
|
||||||
|
namespace xAiModels.Helpers
|
||||||
|
{
|
||||||
|
public static class VectorHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Normalize a Vector ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vector"></param>
|
||||||
|
public static void Normalize(float[] vector)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (vector.IsNull() || !vector.HasChild())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
float sum = 0f;
|
||||||
|
foreach (var value in vector)
|
||||||
|
{
|
||||||
|
sum += value * value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
float norm = MathF.Sqrt(sum);
|
||||||
|
if (norm <= 1e-9f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < vector.Length; i++)
|
||||||
|
{
|
||||||
|
vector[i] /= norm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Similarity Check ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="a"></param>
|
||||||
|
/// <param name="b"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static float CosineSimilarity(
|
||||||
|
float[] a,
|
||||||
|
float[] b
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (a.Length != b.Length)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Similarity ...
|
||||||
|
var result = TensorPrimitives
|
||||||
|
.CosineSimilarity(
|
||||||
|
a.AsSpan(),
|
||||||
|
b.AsSpan()
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
using xCommons.Constants;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using xAiModels.Constants;
|
||||||
|
using xIdentityModels.Models;
|
||||||
|
using xCommons.Configurations;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using xIdentityService.Constants;
|
||||||
|
|
||||||
|
namespace xAiModels.Helpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// a Helper Class for Prepare Headers of MCP Client ...
|
||||||
|
/// </summary>
|
||||||
|
public static class XAiMcpHeaderBuilder
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Build Headers for MCP Client Connection ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="appConfiguration"></param>
|
||||||
|
/// <param name="sessionId"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="protocolVersion"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Dictionary<string, string> Build(
|
||||||
|
XAppConfiguration appConfiguration,
|
||||||
|
string sessionId = null,
|
||||||
|
string connectionId = null,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
string protocolVersion = XAiMcpConstants.XAiMcpProtocol
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var headers = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
["Accept"] = "application/json, text/event-stream",
|
||||||
|
["Content-Type"] = "application/json",
|
||||||
|
[XAiMcpConstants.XAiMcpProtocolIdentifier] = protocolVersion,
|
||||||
|
[XAuthorization.XPoweredBy] = appConfiguration.XPoweredValue ?? "xAiApi"
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Adding Authorization Headers ...
|
||||||
|
if (!userInfo.IsNullOrDefault() && !userInfo.AccessToken.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
headers[XAuthorization.Header] = $"{XAuthorization.TokenIdentifier} {userInfo.AccessToken}";
|
||||||
|
headers[XAuthorization.ExpiresAt] = userInfo.ExpiresAt.ToString();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!userInfo.RefreshToken.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
headers[XAuthorization.RefreshToken] = userInfo.RefreshToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// شناسه اتصال (برای Push Notification ها)
|
||||||
|
if (!connectionId.IsNullOrEmpty()) {
|
||||||
|
headers[XHeader.ConnectionId.GetStringValue()] = connectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Session Id ...
|
||||||
|
if (!sessionId.IsNullOrEmpty()) {
|
||||||
|
headers[XAiMcpConstants.XAiMcpSessionIdentifier] = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using xHttpService.Constants;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace xAiModels.Helpers
|
||||||
|
{
|
||||||
|
public static class XAiMcpSseReader
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Read an SSE Event ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stream"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async IAsyncEnumerable<string> ReadAsync(
|
||||||
|
Stream stream,
|
||||||
|
[EnumeratorCancellation]
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||||
|
var dataBuffer = new StringBuilder();
|
||||||
|
while (!reader.EndOfStream)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var line = await reader.ReadLineAsync();
|
||||||
|
if (line is null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (cancellationToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Empty Line equals End of an Event ...
|
||||||
|
if (line.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (dataBuffer.Length > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
yield return dataBuffer.ToString();
|
||||||
|
dataBuffer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (line.StartsWith(XSSEConstants.DataIdentifier, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var data = line
|
||||||
|
.Substring(XSSEConstants.DataIdentifier.Length)
|
||||||
|
.TrimStart();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (dataBuffer.Length > 0)
|
||||||
|
{
|
||||||
|
dataBuffer.Append('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
dataBuffer.Append(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (dataBuffer.Length > 0)
|
||||||
|
{
|
||||||
|
yield return dataBuffer.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1079,5 +1079,272 @@ namespace xAiModels.Helpers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region XAiMcpServer ...
|
||||||
|
//
|
||||||
|
#region EF Repository Descriptor Provider(s) ...
|
||||||
|
public static XEFRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerEFRepository<TContext>,
|
||||||
|
TContext
|
||||||
|
> GetXAiMcpServerEFRepositoryDescriptor<TContext>()
|
||||||
|
where TContext : XDbContext
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XEFRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerEFRepository<TContext>,
|
||||||
|
TContext
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XEFRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerEFRepository<TContext>,
|
||||||
|
TContext,
|
||||||
|
IXAiMcpServerSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
> GetXAiMcpServerEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
||||||
|
where TContext : XDbContext
|
||||||
|
where TSeederImplementation : XBaseDbSeeder<XAiMcpServer, Guid>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XEFRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerEFRepository<TContext>,
|
||||||
|
TContext,
|
||||||
|
IXAiMcpServerSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Mongo Repository Descriptor Provider(s) ...
|
||||||
|
public static XMongoRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerMongoRepository
|
||||||
|
> GetXAiMcpServerMongoRepositoryDescriptor()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XMongoRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerMongoRepository
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XMongoRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerMongoRepository,
|
||||||
|
IXAiMcpServerSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
> GetXAiMcpServerMongoRepositoryDescriptor<TSeederImplementation>()
|
||||||
|
where TSeederImplementation : XBaseDbSeeder<XAiMcpServer, Guid>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XMongoRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerMongoRepository,
|
||||||
|
IXAiMcpServerSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region InMemory Repository Descriptor Provider(s) ...
|
||||||
|
public static XInMemoryRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerInMemoryRepository
|
||||||
|
> GetXAiMcpServerInMemoryRepositoryDescriptor()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XInMemoryRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerInMemoryRepository
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XInMemoryRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerInMemoryRepository,
|
||||||
|
IXAiMcpServerSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
> GetXAiMcpServerInMemoryRepositoryDescriptor<TSeederImplementation>()
|
||||||
|
where TSeederImplementation : XBaseDbSeeder<XAiMcpServer, Guid>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new XInMemoryRepositoryDescriptor<
|
||||||
|
XAiMcpServer,
|
||||||
|
Guid,
|
||||||
|
IXAiMcpServerKeyGenerator,
|
||||||
|
XAiMcpServerKeyGenerator,
|
||||||
|
IXAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerRepositoryEvents,
|
||||||
|
XAiMcpServerGraphType,
|
||||||
|
GuidGraphType,
|
||||||
|
XAiMcpServerGraphQuery,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphQLTypeHelper,
|
||||||
|
XAiMcpServerGraphSchema,
|
||||||
|
IXAiMcpServerRepository,
|
||||||
|
XAiMcpServerInMemoryRepository,
|
||||||
|
IXAiMcpServerSeeder,
|
||||||
|
TSeederImplementation
|
||||||
|
>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using xAiModels.Models.Dtos;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Dtos
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerDtoHub : IXBaseDtoHub<XAiMcpServer, XAiMcpServerDto, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using xAiModels.Models.Dtos;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Dtos
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerRepositoryService : IXBaseRepositoryService<XAiMcpServer, XAiMcpServerDto, 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 IXAiMcpServerServiceProvider : IXBaseDtoProvider<XAiMcpServer, XAiMcpServerDto, Guid, XAiMcpServerDtoHub>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using xAiModels.Models.Dtos;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Enrichers
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerEnricher
|
||||||
|
{
|
||||||
|
Task<XAiMcpServerDto> Enrich(
|
||||||
|
XAiMcpServer source,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
Task<XAiMcpServerDto> Enrich(
|
||||||
|
XAiMcpServerDto source,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
||||||
|
IEnumerable<XAiMcpServer> sources,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
|
||||||
|
Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
||||||
|
IEnumerable<XAiMcpServerDto> sources,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerEntityHub : IXBaseEntityHub<XAiMcpServer, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XAiMcpServer, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerKeyGenerator : IXKeyGenerator<XAiMcpServer, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerRepository : IXBaseRepository<XAiMcpServer, Guid> { }
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerRepositoryEvents : IXBaseRepositoryEvents<XAiMcpServer>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using xPushService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xAiModels.Providers.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerRepositoryProvider : IXBaseEntityProvider<XAiMcpServer, Guid, XAiMcpServerEntityHub>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Interfaces.Entities
|
||||||
|
{
|
||||||
|
public interface IXAiMcpServerSeeder : IXBaseDbSeeder<XAiMcpServer, Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -66,12 +66,14 @@ namespace xAiModels.Interfaces
|
|||||||
/// Load List of Conversations for Specified Project ...
|
/// Load List of Conversations for Specified Project ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="projectId"></param>
|
/// <param name="projectId"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
/// <param name="fillMessages"></param>
|
/// <param name="fillMessages"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="connectionId"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
||||||
Guid projectId,
|
Guid? projectId,
|
||||||
|
string ownerId = null,
|
||||||
bool fillMessages = false,
|
bool fillMessages = false,
|
||||||
string connectionId = null,
|
string connectionId = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
@@ -81,10 +83,14 @@ namespace xAiModels.Interfaces
|
|||||||
/// Load Messages of Specified Conversation ...
|
/// Load Messages of Specified Conversation ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="conversationId"></param>
|
/// <param name="conversationId"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<XAiMessageDto>> LoadMessages(
|
Task<IEnumerable<XAiMessageDto>> LoadMessages(
|
||||||
Guid conversationId,
|
Guid? conversationId,
|
||||||
|
string ownerId = null,
|
||||||
|
string connectionId = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
@@ -197,7 +203,7 @@ namespace xAiModels.Interfaces
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XAiConversationDto> GetDefaultConversation(
|
Task<XAiConversationDto> GetDefaultConversation(
|
||||||
string ownerId,
|
string ownerId,
|
||||||
Guid projectId,
|
Guid? projectId,
|
||||||
string connectionId = null,
|
string connectionId = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
@@ -231,7 +237,7 @@ namespace xAiModels.Interfaces
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XAiConversationDto> CreateConversation(
|
Task<XAiConversationDto> CreateConversation(
|
||||||
string ownerId,
|
string ownerId,
|
||||||
Guid projectId,
|
Guid? projectId,
|
||||||
XAiConversationDto item = null,
|
XAiConversationDto item = null,
|
||||||
string connectionId = null,
|
string connectionId = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
@@ -308,6 +314,7 @@ namespace xAiModels.Interfaces
|
|||||||
/// <param name="text"></param>
|
/// <param name="text"></param>
|
||||||
/// <param name="embedding"></param>
|
/// <param name="embedding"></param>
|
||||||
/// <param name="metadata"></param>
|
/// <param name="metadata"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task UpsertVectorAsync(
|
Task UpsertVectorAsync(
|
||||||
@@ -315,6 +322,7 @@ namespace xAiModels.Interfaces
|
|||||||
string text,
|
string text,
|
||||||
ReadOnlyMemory<float> embedding,
|
ReadOnlyMemory<float> embedding,
|
||||||
Dictionary<string, string> metadata = null,
|
Dictionary<string, string> metadata = null,
|
||||||
|
string type = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -336,6 +344,7 @@ namespace xAiModels.Interfaces
|
|||||||
/// <param name="topK"></param>
|
/// <param name="topK"></param>
|
||||||
/// <param name="minScore"></param>
|
/// <param name="minScore"></param>
|
||||||
/// <param name="identifierPrefix">Optional: Restrict Search to Vectors whose Identifier Starts with this Prefix</param>
|
/// <param name="identifierPrefix">Optional: Restrict Search to Vectors whose Identifier Starts with this Prefix</param>
|
||||||
|
/// <param name="type">Optional: Restrict Search to Vectors of Specified Type</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IReadOnlyList<XAiVectorSearchResult>> SearchVectorsAsync(
|
Task<IReadOnlyList<XAiVectorSearchResult>> SearchVectorsAsync(
|
||||||
@@ -343,6 +352,7 @@ namespace xAiModels.Interfaces
|
|||||||
int topK = 5,
|
int topK = 5,
|
||||||
float minScore = 0f,
|
float minScore = 0f,
|
||||||
string identifierPrefix = null,
|
string identifierPrefix = null,
|
||||||
|
string type = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -351,11 +361,13 @@ namespace xAiModels.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="identifierPrefix"></param>
|
/// <param name="identifierPrefix"></param>
|
||||||
/// <param name="includeEmbedding"></param>
|
/// <param name="includeEmbedding"></param>
|
||||||
|
/// <param name="type">Optional: Restrict to Vectors of Specified Type</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IReadOnlyList<XAiVectorDto>> LoadVectorsAsync(
|
Task<IReadOnlyList<XAiVectorDto>> LoadVectorsAsync(
|
||||||
string identifierPrefix,
|
string identifierPrefix,
|
||||||
bool includeEmbedding = false,
|
bool includeEmbedding = false,
|
||||||
|
string type = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -363,10 +375,12 @@ namespace xAiModels.Interfaces
|
|||||||
/// Remove Vectors whose Identifier Starts with Specified Prefix ...
|
/// Remove Vectors whose Identifier Starts with Specified Prefix ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="identifierPrefix"></param>
|
/// <param name="identifierPrefix"></param>
|
||||||
|
/// <param name="type">Optional: Restrict to Vectors of Specified Type</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns>Count of Removed Vectors</returns>
|
/// <returns>Count of Removed Vectors</returns>
|
||||||
Task<int> RemoveVectorsAsync(
|
Task<int> RemoveVectorsAsync(
|
||||||
string identifierPrefix,
|
string identifierPrefix,
|
||||||
|
string type = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using xModels.Base;
|
||||||
|
using xModels.Dtos;
|
||||||
|
using xAiModels.Constants;
|
||||||
|
|
||||||
|
namespace xAiModels.Models.Dtos
|
||||||
|
{
|
||||||
|
public class XAiMcpServerDto : XBaseGuidIDEntityDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Owner ...
|
||||||
|
/// </summary>
|
||||||
|
public string OwnerId { get; set; }
|
||||||
|
public virtual XPersonDto Owner { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specified Which Scope can Use MCP Server ...
|
||||||
|
/// </summary>
|
||||||
|
public XAiMcpServerUsageScope Scope { get; set; } = XAiMcpServerUsageScope.Owner;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MCP Server Name ...
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Description ...
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enabled or Disabled ...
|
||||||
|
/// </summary>
|
||||||
|
public bool Enabled { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Environment Variables as JSON Object ...
|
||||||
|
/// </summary>
|
||||||
|
public string EnvironmentVariables { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Endpoint to Connect ...
|
||||||
|
/// </summary>
|
||||||
|
public string Endpoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Headers List as Json Object ...
|
||||||
|
/// </summary>
|
||||||
|
public string Headers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Timout Secconds ...
|
||||||
|
/// </summary>
|
||||||
|
public int TimeoutSeconds { get; set; } = 30;
|
||||||
|
|
||||||
|
public DateTime CreatedOn { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,11 @@ namespace xAiModels.Models.Dtos
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Identifier { get; set; }
|
public string Identifier { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Knowledge Base Type / Domain (Optional Filter on Search) ...
|
||||||
|
/// </summary>
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Embedding vector representation ...
|
/// Embedding vector representation ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace xAiModels.Models.Dtos
|
|||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
public float Score { get; set; }
|
public float Score { get; set; }
|
||||||
|
public string Type { get; set; }
|
||||||
public string Identifier { get; set; }
|
public string Identifier { get; set; }
|
||||||
public Dictionary<string, string> Metadata { get; set; } = null;
|
public Dictionary<string, string> Metadata { get; set; } = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using xModels.Base;
|
||||||
|
using xAiModels.Constants;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace xAiModels.Models.Entities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An MCP Server Descriptor for Adding Tools to XAI ...
|
||||||
|
/// </summary>
|
||||||
|
public class XAiMcpServer : XBaseGuidIDEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Owner ...
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[StringLength(255)]
|
||||||
|
public string OwnerId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specified Which Scope can Use MCP Server ...
|
||||||
|
/// </summary>
|
||||||
|
public XAiMcpServerUsageScope Scope { get; set; } = XAiMcpServerUsageScope.Owner;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MCP Server Name ...
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[StringLength(255)]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Description ...
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enabled or Disabled ...
|
||||||
|
/// </summary>
|
||||||
|
public bool Enabled { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Environment Variables as JSON Object ...
|
||||||
|
/// </summary>
|
||||||
|
public string EnvironmentVariables { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Endpoint to Connect ...
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(1000)]
|
||||||
|
public string Endpoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Headers List as Json Object ...
|
||||||
|
/// </summary>
|
||||||
|
public string Headers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Timout Secconds ...
|
||||||
|
/// </summary>
|
||||||
|
public int TimeoutSeconds { get; set; } = 30;
|
||||||
|
|
||||||
|
public DateTime CreatedOn { get; set; }
|
||||||
|
public DateTime UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using xModels.Base;
|
using xModels.Base;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace xAiModels.Models.Entities
|
namespace xAiModels.Models.Entities
|
||||||
{
|
{
|
||||||
@@ -14,6 +15,13 @@ namespace xAiModels.Models.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Identifier { get; set; }
|
public string Identifier { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Knowledge Base Type / Domain (e.g. "Legal", "Medical") ...
|
||||||
|
/// Used for Filtering on Search and Retrieve ...
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(100)]
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// a Json String which Represents IReadOnlyList of float ...
|
/// a Json String which Represents IReadOnlyList of float ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace xAiModels.Models
|
||||||
|
{
|
||||||
|
public class XAiMcpJsonRpcError
|
||||||
|
{
|
||||||
|
[JsonPropertyName("code")]
|
||||||
|
public int Code { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("message")]
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("data")]
|
||||||
|
public JsonElement? Data { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace xAiModels.Models
|
||||||
|
{
|
||||||
|
public class XAiMcpJsonRpcRequest
|
||||||
|
{
|
||||||
|
[JsonPropertyName("jsonrpc")]
|
||||||
|
public string JsonRpc { get; set; } = "2.0";
|
||||||
|
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public string Id { get; set; } = Guid.NewGuid().ToString("N");
|
||||||
|
|
||||||
|
[JsonPropertyName("method")]
|
||||||
|
public string Method { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("params")]
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public object Params { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace xAiModels.Models
|
||||||
|
{
|
||||||
|
public class XAiMcpJsonRpcResponse
|
||||||
|
{
|
||||||
|
[JsonPropertyName("jsonrpc")]
|
||||||
|
public string JsonRpc { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("result")]
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public JsonElement? Result { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("error")]
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public XAiMcpJsonRpcError Error { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IsSuccess => Error is null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace xAiModels.Models
|
||||||
|
{
|
||||||
|
public class XAiMcpToolDefinition
|
||||||
|
{
|
||||||
|
[JsonPropertyName("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("description")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("inputSchema")]
|
||||||
|
public JsonElement InputSchema { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace xAiModels.Models
|
||||||
|
{
|
||||||
|
public class XAiMcpToolDescriptor
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public JObject InputSchema { get; set; }
|
||||||
|
public string RequiredPolicy { get; set; }
|
||||||
|
public bool RequiresAuthentication { get; set; } = false;
|
||||||
|
public Func<JObject, CancellationToken, Task<string>> Execute { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using xAiModels.Constants;
|
||||||
|
|
||||||
namespace xAiModels.Models
|
namespace xAiModels.Models
|
||||||
{
|
{
|
||||||
@@ -12,14 +13,29 @@ namespace xAiModels.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Prompt { get; set; }
|
public string Prompt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Knowledge Type ...
|
||||||
|
/// </summary>
|
||||||
|
public string Type { get; set; } = XAiModelsConstants.XAiDefaultKnowledgeType;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provided TopK in Vector Searchs ...
|
||||||
|
/// </summary>
|
||||||
|
public int? TopK { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Min Score for Vector Searchs ...
|
||||||
|
/// </summary>
|
||||||
|
public float? MinScore { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specified Project Id ...
|
/// Specified Project Id ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid ProjectId { get; set; }
|
public Guid? ProjectId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specified Conversation Id ...
|
/// Specified Conversation Id ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid ConversationId { get; set; }
|
public Guid? ConversationId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 XAiMcpServerDtoHub : XBaseDtoHub<XAiMcpServer, XAiMcpServerDto, Guid>, IXAiMcpServerDtoHub
|
||||||
|
{
|
||||||
|
public XAiMcpServerDtoHub(
|
||||||
|
ILogger<XAiMcpServerDtoHub> logger
|
||||||
|
) : base(logger)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using xAiModels.Models.Dtos;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xAiModels.Configurations;
|
||||||
|
using xAiModels.Interfaces.Dtos;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
using xAiModels.Interfaces.Enrichers;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Dtos
|
||||||
|
{
|
||||||
|
public class XAiMcpServerRepositoryService : XBaseRepositoryService<XAiMcpServer, XAiMcpServerDto, Guid>, IXAiMcpServerRepositoryService
|
||||||
|
{
|
||||||
|
private readonly IXAiMcpServerEnricher enricher;
|
||||||
|
private readonly IXAiMcpServerRepository repository;
|
||||||
|
|
||||||
|
public XAiMcpServerRepositoryService(
|
||||||
|
IXAiMcpServerRepository repository,
|
||||||
|
IXAiMcpServerEnricher enricher
|
||||||
|
) : base(repository, mapperProfiles: [new XAiModelMappersProfile()])
|
||||||
|
{
|
||||||
|
this.enricher = enricher;
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using xPushService.Base;
|
||||||
|
using xAiModels.Models.Dtos;
|
||||||
|
using xAiModels.Interfaces.Dtos;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xIdentityService.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Dtos
|
||||||
|
{
|
||||||
|
public class XAiMcpServerServiceProvider : XBaseDtoProvider<XAiMcpServer, XAiMcpServerDto, Guid, XAiMcpServerDtoHub>, IXAiMcpServerServiceProvider
|
||||||
|
{
|
||||||
|
public XAiMcpServerServiceProvider(
|
||||||
|
IHubContext<XAiMcpServerDtoHub> hub,
|
||||||
|
XDataServiceConfiguration dataConfiguration,
|
||||||
|
IXAiMcpServerRepositoryService service,
|
||||||
|
IXIdentityProvider identityProvider = null
|
||||||
|
) : base(hub, dataConfiguration, service, identityProvider)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using xModels.Dtos;
|
||||||
|
using System.Threading;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using xAiModels.Models.Dtos;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using xIdentityService.Interfaces;
|
||||||
|
using xAiModels.Interfaces.Enrichers;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Enrichers
|
||||||
|
{
|
||||||
|
public class XAiMcpServerEnricher : IXAiMcpServerEnricher
|
||||||
|
{
|
||||||
|
private readonly IXPersonService personService;
|
||||||
|
|
||||||
|
public XAiMcpServerEnricher(
|
||||||
|
IXPersonService personService
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.personService = personService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async Task<XAiMcpServerDto> Enrich(
|
||||||
|
XAiMcpServer source,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = source.MapConvert<XAiMcpServerDto, XAiMcpServer>();
|
||||||
|
result = await Enrich(
|
||||||
|
source: result,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async Task<XAiMcpServerDto> Enrich(
|
||||||
|
XAiMcpServerDto source,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XPersonDto owner = null;
|
||||||
|
if (!source.OwnerId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
owner = await personService.GetPerson(source.OwnerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = source.MapConvert<XAiMcpServerDto, XAiMcpServerDto>();
|
||||||
|
result.Owner = owner;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
||||||
|
IEnumerable<XAiMcpServer> sources,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var tasks = sources.Select(x => Enrich(x, cancellationToken));
|
||||||
|
return await Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
||||||
|
IEnumerable<XAiMcpServerDto> sources,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var tasks = sources.Select(x => Enrich(x, cancellationToken));
|
||||||
|
return await Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,14 +15,17 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
{
|
{
|
||||||
public class XAiMessageEnricher : IXAiMessageEnricher
|
public class XAiMessageEnricher : IXAiMessageEnricher
|
||||||
{
|
{
|
||||||
|
private readonly IXPersonService personService;
|
||||||
private readonly IXIdentityProvider identityProvider;
|
private readonly IXIdentityProvider identityProvider;
|
||||||
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
||||||
|
|
||||||
public XAiMessageEnricher(
|
public XAiMessageEnricher(
|
||||||
|
IXPersonService personService,
|
||||||
IXIdentityProvider identityProvider,
|
IXIdentityProvider identityProvider,
|
||||||
IXAiConversationTitleResourceProvider conversationTitleResourceProvider
|
IXAiConversationTitleResourceProvider conversationTitleResourceProvider
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
this.personService = personService;
|
||||||
this.identityProvider = identityProvider;
|
this.identityProvider = identityProvider;
|
||||||
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
||||||
}
|
}
|
||||||
@@ -68,14 +71,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
XPersonDto owner = null;
|
XPersonDto owner = null;
|
||||||
if (!source.OwnerId.IsNullOrEmpty())
|
if (!source.OwnerId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
//
|
owner = await personService.GetPerson(source.OwnerId);
|
||||||
// Try to Retrieve User Info ...
|
|
||||||
var device = identityProvider.GetDevice();
|
|
||||||
var userInfo = await identityProvider.GetUserInfo(
|
|
||||||
device: device,
|
|
||||||
userSelectByParam: source.OwnerId
|
|
||||||
);
|
|
||||||
owner = userInfo.ToXPersonDto();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ using System.Threading.Tasks;
|
|||||||
using xAiModels.Models.Entities;
|
using xAiModels.Models.Entities;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using xIdentityService.Interfaces;
|
using xIdentityService.Interfaces;
|
||||||
using xIdentityService.Extensions;
|
|
||||||
using xAiModels.Interfaces.Entities;
|
using xAiModels.Interfaces.Entities;
|
||||||
using xAiModels.Interfaces.Enrichers;
|
using xAiModels.Interfaces.Enrichers;
|
||||||
|
|
||||||
@@ -16,6 +15,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
{
|
{
|
||||||
public class XAiProjectEnricher : IXAiProjectEnricher
|
public class XAiProjectEnricher : IXAiProjectEnricher
|
||||||
{
|
{
|
||||||
|
private readonly IXPersonService personService;
|
||||||
private readonly IXIdentityProvider identityProvider;
|
private readonly IXIdentityProvider identityProvider;
|
||||||
private readonly IXAiMessageRepository messageRepository;
|
private readonly IXAiMessageRepository messageRepository;
|
||||||
private readonly IXAiConversationRepository conversationRepository;
|
private readonly IXAiConversationRepository conversationRepository;
|
||||||
@@ -24,6 +24,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
||||||
|
|
||||||
public XAiProjectEnricher(
|
public XAiProjectEnricher(
|
||||||
|
IXPersonService personService,
|
||||||
IXIdentityProvider identityProvider,
|
IXIdentityProvider identityProvider,
|
||||||
IXAiMessageRepository messageRepository,
|
IXAiMessageRepository messageRepository,
|
||||||
IXAiConversationRepository conversationRepository,
|
IXAiConversationRepository conversationRepository,
|
||||||
@@ -33,6 +34,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
this.personService = personService;
|
||||||
this.identityProvider = identityProvider;
|
this.identityProvider = identityProvider;
|
||||||
this.messageRepository = messageRepository;
|
this.messageRepository = messageRepository;
|
||||||
this.conversationRepository = conversationRepository;
|
this.conversationRepository = conversationRepository;
|
||||||
@@ -92,14 +94,7 @@ namespace xAiModels.Providers.Enrichers
|
|||||||
XPersonDto owner = null;
|
XPersonDto owner = null;
|
||||||
if (!source.OwnerId.IsNullOrEmpty())
|
if (!source.OwnerId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
//
|
owner = await personService.GetPerson(source.OwnerId);
|
||||||
// Try to Retrieve User Info ...
|
|
||||||
var device = identityProvider.GetDevice();
|
|
||||||
var userInfo = await identityProvider.GetUserInfo(
|
|
||||||
device: device,
|
|
||||||
userSelectByParam: source.OwnerId
|
|
||||||
);
|
|
||||||
owner = userInfo.ToXPersonDto();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Db;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xDataService.Interfaces;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XAiMcpServerEFRepository<TContext> : XBaseEFRepository<XAiMcpServer, Guid, TContext>, IXAiMcpServerRepository
|
||||||
|
where TContext : XDbContext
|
||||||
|
{
|
||||||
|
public XAiMcpServerEFRepository(
|
||||||
|
IXUnitOfWorks<TContext> unitOfWorks,
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
IXAiMcpServerKeyGenerator keyGenerator = null,
|
||||||
|
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(unitOfWorks, configuration, keyGenerator, baseRepositoryEvents)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 XAiMcpServerEntityHub : XBaseEntityHub<XAiMcpServer, Guid>, IXAiMcpServerEntityHub
|
||||||
|
{
|
||||||
|
public XAiMcpServerEntityHub(
|
||||||
|
ILogger<XAiMcpServerEntityHub> logger
|
||||||
|
) : base(logger)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.Providers;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XAiMcpServerInMemoryRepository : XBaseInMemoryRepository<XAiMcpServer, Guid>, IXAiMcpServerRepository
|
||||||
|
{
|
||||||
|
public XAiMcpServerInMemoryRepository(
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
IXAiMcpServerKeyGenerator keyGenerator = null,
|
||||||
|
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(configuration, keyGenerator, baseRepositoryEvents)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using xDataService.Providers;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XAiMcpServerKeyGenerator : XGuidKeyGenerator<XAiMcpServer>, IXAiMcpServerKeyGenerator
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xDataService.Providers;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XAiMcpServerMongoRepository : XBaseMongoRepository<XAiMcpServer, Guid>, IXAiMcpServerRepository
|
||||||
|
{
|
||||||
|
public XAiMcpServerMongoRepository(
|
||||||
|
XDataBaseConfiguration dbConfiguration,
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
string collectionName = null,
|
||||||
|
IXAiMcpServerKeyGenerator keyGenerator = null,
|
||||||
|
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
|
||||||
|
) : base(dbConfiguration, configuration, collectionName, keyGenerator, baseRepositoryEvents)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using xDataService.Providers;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XAiMcpServerRepositoryEvents : XBaseRepositoryEvents<XAiMcpServer>, IXAiMcpServerRepositoryEvents
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using xPushService.Base;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
using xDataService.Configuration;
|
||||||
|
using xIdentityService.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using xAiModels.Interfaces.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.Entities
|
||||||
|
{
|
||||||
|
public class XAiMcpServerRepositoryProvider : XBaseEntityProvider<XAiMcpServer, Guid, XAiMcpServerEntityHub>, IXAiMcpServerRepositoryProvider
|
||||||
|
{
|
||||||
|
public XAiMcpServerRepositoryProvider(
|
||||||
|
IHubContext<XAiMcpServerEntityHub> hub,
|
||||||
|
IXAiMcpServerRepository repository,
|
||||||
|
XDataServiceConfiguration dataConfiguration,
|
||||||
|
IXIdentityProvider identityProvider = null
|
||||||
|
) : base(hub, repository, dataConfiguration, identityProvider)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 XAiMcpServerSeederBase : XBaseDbSeeder<XAiMcpServer, Guid>, IXAiMcpServerSeeder
|
||||||
|
{
|
||||||
|
protected XAiMcpServerSeederBase(
|
||||||
|
string entity,
|
||||||
|
string database,
|
||||||
|
IXAiMcpServerRepository 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 XAiMcpServerGraphQLTypeHelper : XBaseGraphQLTypeHelper<XAiMcpServer, Guid>, IXAiMcpServerGraphQLTypeHelper
|
||||||
|
{
|
||||||
|
public override string GetInQueryCollectionName()
|
||||||
|
{
|
||||||
|
return XAiModelsConstants.XAiMcpServerCollectionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetInQuerySingleName()
|
||||||
|
{
|
||||||
|
return XAiModelsConstants.XAiMcpServerSingleName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 XAiMcpServerGraphQuery : XBaseGraphQLQuery<XAiMcpServer, Guid, XAiMcpServerGraphType, GuidGraphType>
|
||||||
|
{
|
||||||
|
public XAiMcpServerGraphQuery(
|
||||||
|
XDataServiceConfiguration configuration,
|
||||||
|
IXAiMcpServerRepository repository,
|
||||||
|
IXAiMcpServerGraphQLTypeHelper helper
|
||||||
|
) : base(
|
||||||
|
configuration,
|
||||||
|
repository,
|
||||||
|
helper
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using GraphQL.Types;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.GraphQL
|
||||||
|
{
|
||||||
|
public class XAiMcpServerGraphSchema : Schema
|
||||||
|
{
|
||||||
|
public XAiMcpServerGraphSchema(IServiceProvider services) : base(services)
|
||||||
|
{
|
||||||
|
Query = (XAiMcpServerGraphQuery)services.GetService(typeof(XAiMcpServerGraphQuery));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using xDataService.GraphQL;
|
||||||
|
using xAiModels.Models.Entities;
|
||||||
|
|
||||||
|
namespace xAiModels.Providers.GraphQL
|
||||||
|
{
|
||||||
|
public class XAiMcpServerGraphType: XBaseGraphObjectType<XAiMcpServer, Guid>
|
||||||
|
{
|
||||||
|
public XAiMcpServerGraphType() : base()
|
||||||
|
{
|
||||||
|
Field(x => x.Name);
|
||||||
|
Field(x => x.Enabled);
|
||||||
|
Field(x => x.OwnerId);
|
||||||
|
Field(x => x.Headers);
|
||||||
|
Field(x => x.Endpoint);
|
||||||
|
Field(x => x.CreatedOn);
|
||||||
|
Field(x => x.UpdatedAt);
|
||||||
|
Field(x => x.Description);
|
||||||
|
Field(x => x.TimeoutSeconds);
|
||||||
|
Field(x => x.EnvironmentVariables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -100,90 +100,6 @@ namespace xAiModels.Providers.Hubs
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
|
||||||
#region XAiConversation ...
|
|
||||||
/// <summary>
|
|
||||||
/// Notify a New Item Created ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task ConversationCreated(
|
|
||||||
XAiProjectDto item,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var connectionId = Context.ConnectionId;
|
|
||||||
if (!connectionId.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
await Clients
|
|
||||||
.AllExcept(connectionId)
|
|
||||||
.SendAsync(
|
|
||||||
XAiDataProviderHubActions.ConversationCreated.GetStringValue(),
|
|
||||||
item.ToJSON(camelCase: true),
|
|
||||||
connectionId,
|
|
||||||
cancellationToken
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Notify an Item Removed ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task ConversationRemoved(
|
|
||||||
XAiProjectDto item,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var connectionId = Context.ConnectionId;
|
|
||||||
if (!connectionId.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
await Clients
|
|
||||||
.AllExcept(connectionId)
|
|
||||||
.SendAsync(
|
|
||||||
XAiDataProviderHubActions.ConversationRemoved.GetStringValue(),
|
|
||||||
item.ToJSON(camelCase: true),
|
|
||||||
connectionId,
|
|
||||||
cancellationToken
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Notify an Item Updated ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task ConversationUpdated(
|
|
||||||
XAiProjectDto item,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
var connectionId = Context.ConnectionId;
|
|
||||||
if (!connectionId.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
await Clients
|
|
||||||
.AllExcept(connectionId)
|
|
||||||
.SendAsync(
|
|
||||||
XAiDataProviderHubActions.ConversationUpdated.GetStringValue(),
|
|
||||||
item.ToJSON(camelCase: true),
|
|
||||||
connectionId,
|
|
||||||
cancellationToken
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#region XAiMessage ...
|
#region XAiMessage ...
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -267,5 +183,173 @@ namespace xAiModels.Providers.Hubs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region XAiMcpServer ...
|
||||||
|
/// <summary>
|
||||||
|
/// Notify a New Item Created ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task McpServerCreated(
|
||||||
|
XAiMcpServerDto item,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var connectionId = Context.ConnectionId;
|
||||||
|
if (!connectionId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Clients
|
||||||
|
.AllExcept(connectionId)
|
||||||
|
.SendAsync(
|
||||||
|
XAiDataProviderHubActions.McpServerCreated.GetStringValue(),
|
||||||
|
item.ToJSON(camelCase: true),
|
||||||
|
connectionId,
|
||||||
|
cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notify an Item Removed ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task McpServerRemoved(
|
||||||
|
XAiMcpServerDto item,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var connectionId = Context.ConnectionId;
|
||||||
|
if (!connectionId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Clients
|
||||||
|
.AllExcept(connectionId)
|
||||||
|
.SendAsync(
|
||||||
|
XAiDataProviderHubActions.McpServerRemoved.GetStringValue(),
|
||||||
|
item.ToJSON(camelCase: true),
|
||||||
|
connectionId,
|
||||||
|
cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notify an Item Updated ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task McpServerUpdated(
|
||||||
|
XAiMcpServerDto item,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var connectionId = Context.ConnectionId;
|
||||||
|
if (!connectionId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Clients
|
||||||
|
.AllExcept(connectionId)
|
||||||
|
.SendAsync(
|
||||||
|
XAiDataProviderHubActions.McpServerUpdated.GetStringValue(),
|
||||||
|
item.ToJSON(camelCase: true),
|
||||||
|
connectionId,
|
||||||
|
cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region XAiConversation ...
|
||||||
|
/// <summary>
|
||||||
|
/// Notify a New Item Created ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task ConversationCreated(
|
||||||
|
XAiProjectDto item,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var connectionId = Context.ConnectionId;
|
||||||
|
if (!connectionId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Clients
|
||||||
|
.AllExcept(connectionId)
|
||||||
|
.SendAsync(
|
||||||
|
XAiDataProviderHubActions.ConversationCreated.GetStringValue(),
|
||||||
|
item.ToJSON(camelCase: true),
|
||||||
|
connectionId,
|
||||||
|
cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notify an Item Removed ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task ConversationRemoved(
|
||||||
|
XAiProjectDto item,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var connectionId = Context.ConnectionId;
|
||||||
|
if (!connectionId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Clients
|
||||||
|
.AllExcept(connectionId)
|
||||||
|
.SendAsync(
|
||||||
|
XAiDataProviderHubActions.ConversationRemoved.GetStringValue(),
|
||||||
|
item.ToJSON(camelCase: true),
|
||||||
|
connectionId,
|
||||||
|
cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notify an Item Updated ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task ConversationUpdated(
|
||||||
|
XAiProjectDto item,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var connectionId = Context.ConnectionId;
|
||||||
|
if (!connectionId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Clients
|
||||||
|
.AllExcept(connectionId)
|
||||||
|
.SendAsync(
|
||||||
|
XAiDataProviderHubActions.ConversationUpdated.GetStringValue(),
|
||||||
|
item.ToJSON(camelCase: true),
|
||||||
|
connectionId,
|
||||||
|
cancellationToken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+517
-240
File diff suppressed because it is too large
Load Diff
@@ -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 XAiMcpServerEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
|
||||||
|
{
|
||||||
|
public XAiMcpServerEntityRegisterar()
|
||||||
|
: base(nameof(XAiMcpServerEntityRegisterar))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Add Entity ...
|
||||||
|
AddEntity<XAiMcpServer, Guid>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configure Entities ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelBuilder"></param>
|
||||||
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Configure Entity Using Provided ...
|
||||||
|
modelBuilder
|
||||||
|
.ApplyConfigurationsFromAssembly(typeof(XAiMcpServerEntityConfiguration).Assembly);
|
||||||
|
|
||||||
|
//
|
||||||
|
base.ConfigureEntities(modelBuilder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
<!-- Local Modules -->
|
<!-- Local Modules -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- <PackageReference Include="xDashboard.xStringService" Version="1.0.0" /> -->
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Local Dependencies -->
|
<!-- Local Dependencies -->
|
||||||
@@ -36,6 +35,7 @@
|
|||||||
<!-- Dependencies -->
|
<!-- Dependencies -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="OpenAI" Version="2.14.0" />
|
<PackageReference Include="OpenAI" Version="2.14.0" />
|
||||||
|
<PackageReference Include="TimeZoneConverter" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.AI" Version="10.4.1" />
|
<PackageReference Include="Microsoft.Extensions.AI" Version="10.4.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.10.0" />
|
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.10.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user