102 lines
3.9 KiB
C#
102 lines
3.9 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Persistent RAG Service over XAiVector Table:
|
|
/// Ingest (Extract -> Chunk -> Embed -> Store) and Ask (Embed -> Search -> Generate) ...
|
|
/// Isolation is Scope Based (Conversation / Project / User / Global) ...
|
|
/// </summary>
|
|
public interface IXAiRAGService
|
|
{
|
|
/// <summary>
|
|
/// Ingest Files into Specified Knowledge Scope:
|
|
/// Extract -> Chunk -> Embed -> Store (XAiVector) ...
|
|
/// </summary>
|
|
/// <param name="files"></param>
|
|
/// <param name="scope">Target Scope (Null = User Scope)</param>
|
|
/// <param name="userInfo"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="replaceExisting"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<XAiKnowledgeIngestResult> IngestAsync(
|
|
IFormFileCollection files,
|
|
XAiKnowledgeScopeDescriptor scope = null,
|
|
XUserClaimsInfoDto userInfo = null,
|
|
string connectionId = null,
|
|
bool replaceExisting = true,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Embed Prompt and Retrieve Relevant Chunks (Tiered: Conversation -> Project -> User -> Global) ...
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="userInfo"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IList<XAiVectorSearchResult>> RetrieveAsync(
|
|
XAiKnowledgeAskRequest request,
|
|
XUserClaimsInfoDto userInfo = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// List Ingested Documents of Specified Scope ...
|
|
/// </summary>
|
|
/// <param name="scope">Target Scope (Null = User Scope)</param>
|
|
/// <param name="userInfo"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<IList<XAiKnowledgeDocumentInfo>> LoadDocumentsAsync(
|
|
XAiKnowledgeScopeDescriptor scope = null,
|
|
XUserClaimsInfoDto userInfo = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Remove All Vectors of a Document in Specified Scope ...
|
|
/// </summary>
|
|
/// <param name="fileName"></param>
|
|
/// <param name="scope">Target Scope (Null = User Scope)</param>
|
|
/// <param name="userInfo"></param>
|
|
/// <param name="connectionId"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>Count of Removed Vectors</returns>
|
|
Task<int> RemoveDocumentAsync(
|
|
string fileName,
|
|
XAiKnowledgeScopeDescriptor scope = null,
|
|
XUserClaimsInfoDto userInfo = null,
|
|
string connectionId = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Migrate Legacy Vectors of Owner ("{ownerId}/{fileName}#i") into User Scope ("user/{ownerId}/{fileName}#i") ...
|
|
/// Idempotent: Returns 0 when Nothing Left to Migrate ...
|
|
/// </summary>
|
|
/// <param name="userInfo"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>Count of Migrated Vectors</returns>
|
|
Task<int> MigrateLegacyVectorsAsync(
|
|
XUserClaimsInfoDto userInfo = null,
|
|
CancellationToken cancellationToken = default
|
|
);
|
|
|
|
/// <summary>
|
|
/// Map Search Results to Public Sources ...
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
IList<XAiDocumentSource> ToSources(
|
|
IEnumerable<XAiVectorSearchResult> context
|
|
);
|
|
}
|
|
} |