Implement Chat With Documents (In-Memory RAG) ...
- Add XAiDocumentModels (IngestResult, AskRequest, Answer, AnswerChunk, Source, SessionInfo, RAGDescriptor DTOs); - Add AskWithContextAsync and AskWithContextAsEnumerable (Context Actions) to IXAiServiceBase and XAIServiceBase; - Add GetContextHistory and BuildContextBlock Helpers for Building RAG Chat History without Persisting; - Rewrite ChatWithDocumentsController with Ingest, Ask, AskStream (SSE), Get Session and Delete Session Endpoints; - Add XInMemoryVectorStoreCleanupService (BackgroundService) for Removing Expired Sessions Periodically; - Add AddXAiChatWithDocuments DI Extension, Register Cleanup HostedService and use it in Startup; - Add RAGDescriptor Property to XAiApiConfiguration and its Section to appsettings.Development.json; - Add ChatWithDocuments System Prompt to Prompts in appsettings.Development.json; - Add IsValid Extension Method for XAiDocumentAskRequest; - Optimize XInMemoryVectorStore.Search (Query Embedding Converted once) and Refactor Formatting; - Remove Unused Usings in XAIServiceBase and IXAiServiceBase; - ...
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using xModels.Dtos;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using xAiModels.Models;
|
||||
using xAiModels.Models.Dtos;
|
||||
@@ -74,6 +73,35 @@ namespace xAiApi.Interfaces
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Context Actions ...
|
||||
/// <summary>
|
||||
/// Ask a Question using Provided Context Chunks (RAG) without Persisting ...
|
||||
/// </summary>
|
||||
/// <param name="prompt"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AskWithContextAsync(
|
||||
string prompt,
|
||||
IEnumerable<XAiVectorSearchResult> context,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Ask a Question using Provided Context Chunks (RAG) and Stream Response ...
|
||||
/// </summary>
|
||||
/// <param name="prompt"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
IAsyncEnumerable<string> AskWithContextAsEnumerable(
|
||||
string prompt,
|
||||
IEnumerable<XAiVectorSearchResult> context,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Loaders ...
|
||||
/// <summary>
|
||||
@@ -196,7 +224,7 @@ namespace xAiApi.Interfaces
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
|
||||
//
|
||||
#region Content Extraction ...
|
||||
/// <summary>
|
||||
@@ -209,7 +237,7 @@ namespace xAiApi.Interfaces
|
||||
Task<string> ExtractContent(
|
||||
IFormFileCollection files,
|
||||
string[] extractors = null,
|
||||
CancellationToken cancellationToken = default
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user