using xAiApi.Models;
using System.Threading;
using xAiModels.Models.Dtos;
using System.Threading.Tasks;
using xIdentityModels.Models;
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) ...
/// Isolation is Scope Based (Conversation / Project / User / Global) ...
///
public interface IXAiRAGService
{
///
/// Ingest Files into Specified Knowledge Scope:
/// Extract -> Chunk -> Embed -> Store (XAiVector) ...
///
///
/// Target Scope (Null = User Scope)
///
///
///
///
///
Task IngestAsync(
IFormFileCollection files,
XAiKnowledgeScopeDescriptor scope = null,
XUserClaimsInfoDto userInfo = null,
string connectionId = null,
bool replaceExisting = true,
CancellationToken cancellationToken = default
);
///
/// Embed Prompt and Retrieve Relevant Chunks (Tiered: Conversation -> Project -> User -> Global) ...
///
///
///
///
///
Task> RetrieveAsync(
XAiKnowledgeAskRequest request,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// List Ingested Documents of Specified Scope ...
///
/// Target Scope (Null = User Scope)
///
///
///
Task> LoadDocumentsAsync(
XAiKnowledgeScopeDescriptor scope = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Remove All Vectors of a Document in Specified Scope ...
///
///
/// Target Scope (Null = User Scope)
///
///
/// Count of Removed Vectors
Task RemoveDocumentAsync(
string fileName,
XAiKnowledgeScopeDescriptor scope = null,
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Migrate Legacy Vectors of Owner ("{ownerId}/{fileName}#i") into User Scope ("user/{ownerId}/{fileName}#i") ...
/// Idempotent: Returns 0 when Nothing Left to Migrate ...
///
///
///
/// Count of Migrated Vectors
Task MigrateLegacyVectorsAsync(
XUserClaimsInfoDto userInfo = null,
CancellationToken cancellationToken = default
);
///
/// Map Search Results to Public Sources ...
///
///
///
IList ToSources(
IEnumerable context
);
}
}