Add Persistent Knowledge RAG Service and API
- Add IXAiRAGService and XAiRAGService for Extract -> Chunk -> Embed -> Store;
- Add synchronous and streaming RAG answers with sources;
- Add Knowledge models and KnowledgeController endpoints;
- Register IXAiRAGService as scoped;
- Keep current identifier: {ownerId}/{fileName}#{chunkIndex}.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace xAiApi.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Result of Ingesting Files into Persistent Knowledge Base (XAiVector Table) ...
|
||||
/// </summary>
|
||||
public class XAiKnowledgeIngestResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Count of Successfully Ingested Files ...
|
||||
/// </summary>
|
||||
public int FilesCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Count of Stored Chunks (Vectors) in this Request ...
|
||||
/// </summary>
|
||||
public int ChunksCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Count of Removed Stale Vectors (Re-Ingest) ...
|
||||
/// </summary>
|
||||
public int ReplacedCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Skipped Files (Empty, Unsupported or Extraction Failed) ...
|
||||
/// </summary>
|
||||
public IList<string> SkippedFiles { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Ingested Documents Info ...
|
||||
/// </summary>
|
||||
public IList<XAiKnowledgeDocumentInfo> Documents { get; set; } = new List<XAiKnowledgeDocumentInfo>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ask Request over Persistent Knowledge Base ...
|
||||
/// </summary>
|
||||
public class XAiKnowledgeAskRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Question ...
|
||||
/// </summary>
|
||||
public string Prompt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional: Restrict Retrieval to a Specific File ...
|
||||
/// </summary>
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional: Max Retrieved Chunks ...
|
||||
/// </summary>
|
||||
public int? TopK { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional: Minimum Cosine Similarity Score ...
|
||||
/// </summary>
|
||||
public float? MinScore { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ingested Document Info ...
|
||||
/// </summary>
|
||||
public class XAiKnowledgeDocumentInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// File Name ...
|
||||
/// </summary>
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mime Type ...
|
||||
/// </summary>
|
||||
public string MimeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Count of Stored Chunks ...
|
||||
/// </summary>
|
||||
public int ChunksCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ingestion Time (UTC) ...
|
||||
/// </summary>
|
||||
public DateTime? IngestedAtUtc { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user