This commit is contained in:
2026-10-27 05:56:08 +03:30
parent 9e82e05bfe
commit 058d8da780
4 changed files with 172 additions and 1 deletions
+122 -1
View File
@@ -1,13 +1,75 @@
using xAiApi.Constants;
using xAiApi.Constants;
using System;
using xAiApi.Constants;
using System.Collections.Generic;
namespace xAiApi.Models
{
/// <summary>
/// Describes Target Knowledge Base Scope of an Operation ...
/// </summary>
public class XAiKnowledgeScopeDescriptor
{
/// <summary>
/// Scope Kind ...
/// </summary>
public XAiKnowledgeScope Scope { get; set; }
/// <summary>
/// Scope Identifier (ProjectId / ConversationId) - Null for Global ...
/// </summary>
public Guid? ScopeId { get; set; }
/// <summary>
/// Optional Knowledge Type / Domain Filter ...
/// </summary>
public string Type { get; set; }
//
public static XAiKnowledgeScopeDescriptor Global(string type = null) => new()
{
Type = type,
ScopeId = null,
Scope = XAiKnowledgeScope.Global,
};
public static XAiKnowledgeScopeDescriptor Project(Guid projectId, string type = null) => new()
{
Type = type,
ScopeId = projectId,
Scope = XAiKnowledgeScope.Project,
};
public static XAiKnowledgeScopeDescriptor Conversation(Guid conversationId, string type = null) => new()
{
Type = type,
ScopeId = conversationId,
Scope = XAiKnowledgeScope.Conversation,
};
}
/// <summary>
/// Result of Ingesting Files into Persistent Knowledge Base (XAiVector Table) ...
/// </summary>
public class XAiKnowledgeIngestResult
{
/// <summary>
/// Target Scope ...
/// </summary>
public XAiKnowledgeScope Scope { get; set; }
/// <summary>
/// Target Scope Identifier (Null for Global) ...
/// </summary>
public Guid? ScopeId { get; set; }
/// <summary>
/// Knowledge Type of Ingested Vectors ...
/// </summary>
public string Type { get; set; }
/// <summary>
/// Count of Successfully Ingested Files ...
/// </summary>
@@ -36,6 +98,7 @@ namespace xAiApi.Models
/// <summary>
/// Ask Request over Persistent Knowledge Base ...
/// Retrieval is Tiered: Conversation -> Project -> Global (Each Tier Fills Remaining TopK) ...
/// </summary>
public class XAiKnowledgeAskRequest
{
@@ -45,7 +108,23 @@ namespace xAiApi.Models
public string Prompt { get; set; }
/// <summary>
/// Optional: Restrict Retrieval to a Specific File ...
/// Optional: Conversation Scope (Caller must be Conversation Owner) ...
/// When Provided, Conversation's Project is used for Second Tier Automatically ...
/// </summary>
public Guid? ConversationId { get; set; }
/// <summary>
/// Optional: Project Scope (Caller must be Project Owner) ...
/// </summary>
public Guid? ProjectId { get; set; }
/// <summary>
/// Optional: Restrict Retrieval to a Knowledge Type / Domain ...
/// </summary>
public string Type { get; set; }
/// <summary>
/// Optional: Restrict Retrieval to a Specific File Name ...
/// </summary>
public string FileName { get; set; }
@@ -65,6 +144,21 @@ namespace xAiApi.Models
/// </summary>
public class XAiKnowledgeDocumentInfo
{
/// <summary>
/// Scope ...
/// </summary>
public XAiKnowledgeScope Scope { get; set; }
/// <summary>
/// Scope Identifier (Null for Global) ...
/// </summary>
public Guid? ScopeId { get; set; }
/// <summary>
/// Knowledge Type ...
/// </summary>
public string Type { get; set; }
/// <summary>
/// File Name ...
/// </summary>
@@ -75,6 +169,11 @@ namespace xAiApi.Models
/// </summary>
public string MimeType { get; set; }
/// <summary>
/// Ingesting User Identifier ...
/// </summary>
public string OwnerId { get; set; }
/// <summary>
/// Count of Stored Chunks ...
/// </summary>
@@ -85,4 +184,26 @@ namespace xAiApi.Models
/// </summary>
public DateTime? IngestedAtUtc { get; set; }
}
/// <summary>
/// Public Vector Info (Export) ...
/// </summary>
public class XAiKnowledgeVectorInfo
{
public Guid Id { get; set; }
public string Text { get; set; }
public string Type { get; set; }
public Guid? ScopeId { get; set; }
public string FileName { get; set; }
public int? ChunkIndex { get; set; }
public string Identifier { get; set; }
public XAiKnowledgeScope Scope { get; set; }
public Dictionary<string, string> Metadata { get; set; }
/// <summary>
/// Embedding (Only Filled when Requested) ...
/// </summary>
public float[] Embedding { get; set; }
}
}