using Rag.Models.Requests; using Rag.Models.Responses; namespace Api.Services.Contracts; /// /// Core RAG (Retrieval-Augmented Generation) operations: document indexing, vector search, and retrieval. /// public interface IRagService { /// /// Indexes a plain-text document by classifying it, chunking the text, generating embeddings, /// and persisting the document and its chunks. Returns cached metadata when the text hash already exists. /// /// Indexing request with text, optional document type, title, and source URL. /// Cancellation token. /// Response with document ID, hash, type, and chunk/character counts. Task IndexTextAsync(IndexDocumentRequest request, CancellationToken ct); /// /// Extracts text from a PDF file, then indexes it the same way as . /// Returns cached metadata when the extracted text hash already exists. /// /// Uploaded PDF file (must be ≤ configured max size). /// Optional document type hint; if omitted the classifier is used. /// Optional title override; if omitted the title is extracted from the text. /// Optional source URL to associate with the document. /// Cancellation token. /// Response with document ID, hash, type, and chunk/character counts. Task IndexPdfAsync(IFormFile file, string? documentType, string? title, string? sourceUrl, CancellationToken ct); /// /// Performs a vector similarity search over indexed document chunks, groups results by document, /// and returns the top-K documents with their best-matching chunks. /// /// Search request with query text, optional document type filter, and top-K limit. /// Cancellation token. /// Ranked list of matching documents with scored chunk excerpts. Task SearchAsync(SearchRequest request, CancellationToken ct); /// /// Retrieves full document details — including the original text — by document ID. /// /// The document's unique identifier. /// Cancellation token. /// Document details, or null if no document with that ID exists. Task GetDocumentAsync(string documentId, CancellationToken ct); }