using System;
using xAiModels.Constants;
using System.Collections.Generic;
namespace xAiApi.Models
{
///
/// Describes Target Knowledge Base Scope of an Operation ...
///
public class XAiKnowledgeScopeDescriptor
{
///
/// Scope Kind ...
///
public XAiKnowledgeScope Scope { get; set; } = XAiKnowledgeScope.User;
///
/// Scope Identifier (ProjectId / ConversationId) - Null for Global and User ...
///
public Guid? ScopeId { get; set; }
///
/// Optional Knowledge Type / Domain Filter ...
///
public string Type { get; set; }
///
/// Create User Scope Knowledge Descriptor ...
///
///
///
public static XAiKnowledgeScopeDescriptor User(
string type = null
) => new()
{
//
Type = type ?? XAiModelsConstants.XAiDefaultKnowledgeType,
ScopeId = null,
Scope = XAiKnowledgeScope.User,
};
///
/// Create Global Scope Knowledge Descriptor ...
///
///
///
public static XAiKnowledgeScopeDescriptor Global(
string type = null
) => new()
{
Type = type ?? XAiModelsConstants.XAiDefaultKnowledgeType,
ScopeId = null,
Scope = XAiKnowledgeScope.Global,
};
///
/// Create Project Scope Knowledge Descriptor ...
///
///
///
///
public static XAiKnowledgeScopeDescriptor Project(
Guid projectId,
string type = null
) => new()
{
Type = type ?? XAiModelsConstants.XAiDefaultKnowledgeType,
ScopeId = projectId,
Scope = XAiKnowledgeScope.Project,
};
///
/// Create Conversational Scope Knowledge Descriptor ...
///
///
///
///
public static XAiKnowledgeScopeDescriptor Conversation(
Guid conversationId,
string type = null
) => new()
{
Type = type ?? XAiModelsConstants.XAiDefaultKnowledgeType,
ScopeId = conversationId,
Scope = XAiKnowledgeScope.Conversation,
};
}
///
/// Result of Ingesting Files into Persistent Knowledge Base (XAiVector Table) ...
///
public class XAiKnowledgeIngestResult
{
///
/// Target Scope ...
///
public XAiKnowledgeScope Scope { get; set; }
///
/// Target Scope Identifier (Null for Global) ...
///
public Guid? ScopeId { get; set; }
///
/// Knowledge Type of Ingested Vectors ...
///
public string Type { get; set; }
///
/// Count of Successfully Ingested Files ...
///
public int FilesCount { get; set; }
///
/// Count of Stored Chunks (Vectors) in this Request ...
///
public int ChunksCount { get; set; }
///
/// Count of Removed Stale Vectors (Re-Ingest) ...
///
public int ReplacedCount { get; set; }
///
/// Skipped Files (Empty, Unsupported or Extraction Failed) ...
///
public IList SkippedFiles { get; set; } = new List();
///
/// Ingested Documents Info ...
///
public IList Documents { get; set; } = new List();
}
///
/// Ask Request over Persistent Knowledge Base ...
/// Retrieval is Tiered: Conversation -> Project -> User -> Global (Each Tier Fills Remaining TopK) ...
///
public class XAiKnowledgeAskRequest
{
///
/// Question ...
///
public string Prompt { get; set; }
///
/// Optional: Conversation Scope (Caller must be Conversation Owner) ...
/// When Provided, Conversation's Project is used for Second Tier Automatically ...
///
public Guid? ConversationId { get; set; }
///
/// Optional: Project Scope (Caller must be Project Owner) ...
///
public Guid? ProjectId { get; set; }
///
/// Include Personal (User) Knowledge Tier (default true) ...
///
public bool IncludeUser { get; set; } = true;
///
/// Include Global Knowledge Tier (default true) ...
///
public bool IncludeGlobal { get; set; } = true;
///
/// Optional: Restrict Retrieval to a Knowledge Type / Domain ...
///
public string Type { get; set; }
///
/// Optional: Restrict Retrieval to a Specific File Name ...
///
public string FileName { get; set; }
///
/// Optional: Max Retrieved Chunks ...
///
public int? TopK { get; set; }
///
/// Optional: Minimum Cosine Similarity Score ...
///
public float? MinScore { get; set; }
}
///
/// Ingested Document Info ...
///
public class XAiKnowledgeDocumentInfo
{
///
/// Scope ...
///
public XAiKnowledgeScope Scope { get; set; }
///
/// Scope Identifier (Null for Global) ...
///
public Guid? ScopeId { get; set; }
///
/// Knowledge Type ...
///
public string Type { get; set; }
///
/// File Name ...
///
public string FileName { get; set; }
///
/// Mime Type ...
///
public string MimeType { get; set; }
///
/// Ingesting User Identifier ...
///
public string OwnerId { get; set; }
///
/// Count of Stored Chunks ...
///
public int ChunksCount { get; set; }
///
/// Ingestion Time (UTC) ...
///
public DateTime? IngestedAtUtc { get; set; }
}
///
/// Public Vector Info (Export) ...
///
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 Metadata { get; set; }
///
/// Embedding (Only Filled when Requested) ...
///
public float[] Embedding { get; set; }
}
}