using xAiApi.Models; using System.Threading; using xAiModels.Models.Dtos; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using System.Collections.Generic; namespace xAiApi.Interfaces { /// /// Persistent RAG Service over XAiVector Table: /// Ingest (Extract -> Chunk -> Embed -> Store) and Ask (Embed -> Search -> Generate) ... /// public interface IXAiRAGService { /// /// Ingest Files into Owner's Knowledge Base ... /// /// /// /// Remove Previously Stored Vectors of Same File before Store /// /// Task IngestAsync( IFormFileCollection files, string ownerId, bool replaceExisting = true, CancellationToken cancellationToken = default ); /// /// Embed Prompt and Retrieve Relevant Chunks from Owner's Knowledge Base ... /// /// /// /// /// /// Optional: Restrict to a Specific File /// /// Task> RetrieveAsync( string prompt, string ownerId, int? topK = null, float? minScore = null, string fileName = null, CancellationToken cancellationToken = default ); /// /// Ask a Question with RAG (Retrieve from DB then Generate) ... /// /// /// /// /// Task AskWithRAGAsync( XAiKnowledgeAskRequest request, string ownerId, CancellationToken cancellationToken = default ); /// /// Ask a Question with RAG and Stream Response ... /// First Item Carries Sources, Next Items Carry Text Deltas, Last Item has IsFinal = true ... /// /// /// /// /// IAsyncEnumerable AskWithRAGAsEnumerable( XAiKnowledgeAskRequest request, string ownerId, CancellationToken cancellationToken = default ); /// /// List Ingested Documents of Owner ... /// /// /// /// Task> LoadDocumentsAsync( string ownerId, CancellationToken cancellationToken = default ); /// /// Remove All Vectors of a Document ... /// /// /// /// /// Count of Removed Vectors Task RemoveDocumentAsync( string ownerId, string fileName, CancellationToken cancellationToken = default ); /// /// Map Search Results to Public Sources ... /// /// /// IList ToSources( IEnumerable context ); } }