diff --git a/Constants/XAiApiConstants.cs b/Constants/XAiApiConstants.cs
index e34afd5..db96048 100644
--- a/Constants/XAiApiConstants.cs
+++ b/Constants/XAiApiConstants.cs
@@ -26,7 +26,18 @@ namespace xAiApi.Constants
//
// Knowledge (Persistent RAG) ...
+ public const string XAiKnowledgeSeparator = "/";
public const string XAiKnowledgeOwnerSeparator = "/";
+ public const string XAiKnowledgeChunkSeparator = "#";
+ public const string XAiKnowledgeGlobalPrefix = "global";
+ public const string XAiKnowledgeProjectPrefix = "project";
+ public const string XAiKnowledgeConversationPrefix = "conversation";
+
+ //
+ // Knowledge Metadata Keys ...
+ public const string XAiKnowledgeMetadataType = "type";
+ public const string XAiKnowledgeMetadataScope = "scope";
+ public const string XAiKnowledgeMetadataScopeId = "scopeId";
public const string XAiKnowledgeMetadataOwnerId = "ownerId";
public const string XAiKnowledgeMetadataIngestedAtUtc = "ingestedAtUtc";
}
diff --git a/Constants/XAiKnowledgeScope.cs b/Constants/XAiKnowledgeScope.cs
new file mode 100644
index 0000000..ff584d0
--- /dev/null
+++ b/Constants/XAiKnowledgeScope.cs
@@ -0,0 +1,12 @@
+namespace xAiApi.Constants
+{
+ ///
+ /// Knowledge Base Scope (Where Ingested Vectors are Visible) ...
+ ///
+ public enum XAiKnowledgeScope
+ {
+ Conversation = 0,
+ Project = 1,
+ Global = 2,
+ }
+}
diff --git a/Models/XAiDocumentModels.cs b/Models/XAiDocumentModels.cs
index e15c752..c199984 100644
--- a/Models/XAiDocumentModels.cs
+++ b/Models/XAiDocumentModels.cs
@@ -94,6 +94,16 @@ namespace xAiApi.Models
/// Short Snippet of Chunk Text ...
///
public string Snippet { get; set; }
+
+ ///
+ /// Knowledge Scope the Chunk Retrieved from (Null for Session Based Documents) ...
+ ///
+ public string Scope { get; set; }
+
+ ///
+ /// Knowledge Type of the Chunk ...
+ ///
+ public string Type { get; set; }
}
///
@@ -177,5 +187,22 @@ namespace xAiApi.Models
public string MetadataMimeType { get; set; } = "mimeType";
public string PromptName { get; set; } = "ChatWithDocuments";
public string MetadataChunkIndex { get; set; } = "chunkIndex";
+
+ //
+ // Knowledge (Persistent RAG) Limits ...
+ ///
+ /// Max Files Accepted in a Single Ingest Request (0 = Unlimited) ...
+ ///
+ public int MaxFilesPerIngest { get; set; } = 20;
+
+ ///
+ /// Max Size of a Single File in Bytes (0 = Unlimited) ...
+ ///
+ public long MaxFileSizeBytes { get; set; } = 25 * 1024 * 1024;
+
+ ///
+ /// Max Distinct Documents Allowed in a Non-Global Scope (0 = Unlimited) ...
+ ///
+ public int MaxDocumentsPerScope { get; set; } = 50;
}
}
diff --git a/Models/XAiKnowledgeModels.cs b/Models/XAiKnowledgeModels.cs
index c524b77..c7ace2f 100644
--- a/Models/XAiKnowledgeModels.cs
+++ b/Models/XAiKnowledgeModels.cs
@@ -1,13 +1,75 @@
+using xAiApi.Constants;
+
+using xAiApi.Constants;
+
+
using System;
+using xAiApi.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; }
+
+ ///
+ /// Scope Identifier (ProjectId / ConversationId) - Null for Global ...
+ ///
+ public Guid? ScopeId { get; set; }
+
+ ///
+ /// Optional Knowledge Type / Domain Filter ...
+ ///
+ 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,
+ };
+ }
+
///
/// 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 ...
///
@@ -36,6 +98,7 @@ namespace xAiApi.Models
///
/// Ask Request over Persistent Knowledge Base ...
+ /// Retrieval is Tiered: Conversation -> Project -> Global (Each Tier Fills Remaining TopK) ...
///
public class XAiKnowledgeAskRequest
{
@@ -45,7 +108,23 @@ namespace xAiApi.Models
public string Prompt { get; set; }
///
- /// 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 ...
+ ///
+ public Guid? ConversationId { get; set; }
+
+ ///
+ /// Optional: Project Scope (Caller must be Project Owner) ...
+ ///
+ public Guid? ProjectId { get; set; }
+
+ ///
+ /// 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; }
@@ -65,6 +144,21 @@ namespace xAiApi.Models
///
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 ...
///
@@ -75,6 +169,11 @@ namespace xAiApi.Models
///
public string MimeType { get; set; }
+ ///
+ /// Ingesting User Identifier ...
+ ///
+ public string OwnerId { get; set; }
+
///
/// Count of Stored Chunks ...
///
@@ -85,4 +184,26 @@ namespace xAiApi.Models
///
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; }
+ }
}
+