diff --git a/Constants/XAiKnowledgeScope.cs b/Constants/XAiKnowledgeScope.cs new file mode 100644 index 0000000..1c53787 --- /dev/null +++ b/Constants/XAiKnowledgeScope.cs @@ -0,0 +1,35 @@ +using xExceptions.Attributes; + +namespace xAiModels.Constants +{ + /// + /// Knowledge Base Scope (Where Ingested Vectors are Visible) ... + /// Identifier Layout: "{scopePrefix}/{scopeKey}/{fileName}#{chunkIndex}" (Global has no scopeKey) ... + /// + public enum XAiKnowledgeScope + { + /// + /// Visible only Inside a Conversation (Key = ConversationId) ... + /// + [StringValue(XAiModelsConstants.XAiKnowledgeConversationPrefix)] + Conversation = 0, + + /// + /// Visible to all Conversations of a Project (Key = ProjectId) ... + /// + [StringValue(XAiModelsConstants.XAiKnowledgeProjectPrefix)] + Project = 1, + + /// + /// Visible to Everyone (Write Requires Admin Role) ... + /// + [StringValue(XAiModelsConstants.XAiKnowledgeGlobalPrefix)] + Global = 2, + + /// + /// Personal Knowledge Base of Owner (Key = UserId) ... + /// + [StringValue(XAiModelsConstants.XAiKnowledgeUserPrefix)] + User = 3, + } +} \ No newline at end of file diff --git a/Constants/XAiModelsConstants.cs b/Constants/XAiModelsConstants.cs index e2217d3..0087de7 100644 --- a/Constants/XAiModelsConstants.cs +++ b/Constants/XAiModelsConstants.cs @@ -60,5 +60,28 @@ namespace xAiModels.Constants // public const string XOpenAINoKey = "no-key-required"; + + // + // Knowledge (Persistent RAG) ... + public const string XAiDefaultKnowledgeType = "XAiKnowledge"; + public const string XAiKnowledgeSeparator = "/"; + public const string XAiKnowledgeOwnerSeparator = "/"; + public const string XAiKnowledgeChunkSeparator = "#"; + public const string XAiKnowledgeUserPrefix = "user"; + public const string XAiKnowledgeGlobalPrefix = "global"; + public const string XAiKnowledgeProjectPrefix = "project"; + public const string XAiKnowledgeConversationPrefix = "conversation"; + + // + // Error Handler Route (Production) ... + public const string XAiErrorRoute = "/error"; + + // + // 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"; } } \ No newline at end of file diff --git a/Extensions/XAiModelsExtensions.cs b/Extensions/XAiModelsExtensions.cs index 8219893..de703cf 100644 --- a/Extensions/XAiModelsExtensions.cs +++ b/Extensions/XAiModelsExtensions.cs @@ -267,7 +267,7 @@ namespace xAiModels.Extensions { // // Validate Args ... - if (source.HasChild() || + if (!source.HasChild() || ownerId.IsNullOrEmpty()) { XException.InvalidArgs.Throw(); @@ -306,7 +306,7 @@ namespace xAiModels.Extensions { // // Validate Args ... - if (source.HasChild() || + if (!source.HasChild() || projectId.IsDefaultGuid()) { XException.InvalidArgs.Throw(); diff --git a/Providers/XAiDataProvider.cs b/Providers/XAiDataProvider.cs index 97327e7..78ec13c 100644 --- a/Providers/XAiDataProvider.cs +++ b/Providers/XAiDataProvider.cs @@ -237,7 +237,7 @@ namespace xAiModels.Providers // Retrieve Conversation's List ... var result = await conversationRepositoryService.FindManyAsync( includeBuilder: null, - ignoreSoftDeleteds: false, + ignoreSoftDeleteds: true, cancellationToken: cancellationToken, predicate: x => x.ProjectId == projectId, orderBuilder: x => x.OrderBy(y => y.CreatedOn) @@ -490,7 +490,7 @@ namespace xAiModels.Providers { // trl.Language = defaultLanguage; - isDefaultLanguageHandled = false; + isDefaultLanguageHandled = true; } // @@ -534,7 +534,7 @@ namespace xAiModels.Providers { // trl.Language = defaultLanguage; - isDefaultLanguageHandled = false; + isDefaultLanguageHandled = true; } // @@ -742,7 +742,7 @@ namespace xAiModels.Providers { // trl.Language = defaultLanguage; - isDefaultLanguageHandled = false; + isDefaultLanguageHandled = true; } // @@ -1039,7 +1039,7 @@ namespace xAiModels.Providers { // project = await projectRepositoryService.GetAsync( - id: project.Id, + id: projectId, includeBuilder: null, ignoreSoftDeleteds: true, cancellationToken: cancellationToken @@ -1128,7 +1128,7 @@ namespace xAiModels.Providers { // Expression> predicate = null; - if (ownerId.IsNullOrEmpty()) + if (!ownerId.IsNullOrEmpty()) { predicate = x => x.OwnerId == ownerId; } @@ -1196,7 +1196,7 @@ namespace xAiModels.Providers // Expression> predicate = x => x.ProjectId == projectId; - if (ownerId.IsNullOrEmpty()) + if (!ownerId.IsNullOrEmpty()) { // predicate = x => @@ -1266,7 +1266,7 @@ namespace xAiModels.Providers // Expression> predicate = x => x.ConversationId == conversationId; - if (ownerId.IsNullOrEmpty()) + if (!ownerId.IsNullOrEmpty()) { // predicate = x =>