Integrate RAG into Chat Pipeline and Decouple Embedding Service

- AskAsync: accept Guid? projectId / conversationId; resolve defaults;
- AskAsync: ingest attached files into Conversation scope (replaceExisting)
  via IXAiRAGService instead of Upload + Extract + raw content attachment;
- AskAsync: retrieve context (Conversation -> Project -> User -> Global)
  and build a single System message: Introduction + ChatWithDocuments prompt
  + Context block (+ Project prompt);
- XAIServiceBase / XDefaultAiService / XDefaultThinkingAiService:
  inject IXAiRAGService instead of IXFileProvider;
- Add IXAiEmbeddingService + XAiEmbeddingService; remove
  IXDefaultEmbeddingService + XDefaultEmbeddingService;
- XAiEmbeddingServiceBase no longer inherits XAIServiceBase;
  IXAiEmbeddingServiceBase / IXAiEmbeddingServiceControllerBase no longer
  extend chat interfaces; XAiEmbeddingServiceControllerBase derives from
  XBaseIdentityApiV1Controller;
- XAiRAGService: drop IXDefaultAiService dependency (removes circular
  dependency); remove AskWithRAGAsync / AskWithRAGAsEnumerable; add file
  reference (AddReference) for scoped ingests;
- KnowledgeController: remove POST Ask and POST AskStream;
- DI: add AddXRagService() and call it from Startup before AddXAiServices();
- Add XAiApiRagPromptName = "ChatWithDocuments";
- Knowledge scope factories default Type to XAiDefaultKnowledgeType;
- ChatWithDocuments ask request: TopK and MinScore are now required.
BREAKING: /Knowledge/Ask and /Knowledge/AskStream removed;
          IXDefaultEmbeddingService replaced by IXAiEmbeddingService.
This commit is contained in:
2026-10-30 19:46:20 +03:30
parent 37d4e622e9
commit ad8ea9c1dd
22 changed files with 343 additions and 655 deletions
+5 -4
View File
@@ -33,7 +33,8 @@ namespace xAiApi.Models
string type = null
) => new()
{
Type = type,
//
Type = type ?? XAiModelsConstants.XAiDefaultKnowledgeType,
ScopeId = null,
Scope = XAiKnowledgeScope.User,
};
@@ -47,7 +48,7 @@ namespace xAiApi.Models
string type = null
) => new()
{
Type = type,
Type = type ?? XAiModelsConstants.XAiDefaultKnowledgeType,
ScopeId = null,
Scope = XAiKnowledgeScope.Global,
};
@@ -63,7 +64,7 @@ namespace xAiApi.Models
string type = null
) => new()
{
Type = type,
Type = type ?? XAiModelsConstants.XAiDefaultKnowledgeType,
ScopeId = projectId,
Scope = XAiKnowledgeScope.Project,
};
@@ -79,7 +80,7 @@ namespace xAiApi.Models
string type = null
) => new()
{
Type = type,
Type = type ?? XAiModelsConstants.XAiDefaultKnowledgeType,
ScopeId = conversationId,
Scope = XAiKnowledgeScope.Conversation,
};