diff --git a/Configurations/XAiApiConfiguration.cs b/Configurations/XAiApiConfiguration.cs
deleted file mode 100644
index f62dc4d..0000000
--- a/Configurations/XAiApiConfiguration.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using xAiModels.Models;
-using xAiModels.Constants;
-
-namespace xAiModels.Configurations
-{
- public class XAiApiConfiguration
- {
- ///
- /// Model Providers ...
- ///
- public XAiModelDescriptor[] Models { get; set; } = [];
-
- ///
- /// Each User must Has a Default Project, this is Title Resource Identifier ...
- ///
- public string DefaultProjectTitleResource { get; set; } = XAiModelsConstants.DefaultXAiProjectTitleResourceID;
-
- ///
- /// Each User must Has a Default Project, this is Description Resource Identifier ...
- ///
- public string DefaultProjectDescriptionResource { get; set; } = XAiModelsConstants.DefaultXAiProjectDescriptionResourceID;
-
- ///
- /// Each User must Has a Default Conversation, this is Title Resource Identifier ... ...
- ///
- public string DefaultConversationTitleResource { get; set; } = XAiModelsConstants.DefaultXAiConversationTitleResourceID;
- }
-}
\ No newline at end of file
diff --git a/Extensions/XAiApiConfigurationExtensions.cs b/Extensions/XAiApiConfigurationExtensions.cs
deleted file mode 100644
index 9ff8218..0000000
--- a/Extensions/XAiApiConfigurationExtensions.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System.Linq;
-using xAiModels.Models;
-using xCommons.Extensions;
-using xAiModels.Configurations;
-
-namespace xAiModels.Extensions
-{
- public static class XAiApiConfigurationExtensions
- {
- ///
- /// Validate Api Configuration ...
- ///
- ///
- ///
- public static bool IsValid(this XAiApiConfiguration source)
- {
- return
- !source.IsNullOrDefault() &&
- source.Models.HasChild();
- }
-
- ///
- /// Retrieve Default Model Descriptor ...
- ///
- ///
- ///
- public static XAiModelDescriptor GetDefaultModel(this XAiApiConfiguration source)
- {
- //
- XAiModelDescriptor result = null;
-
- //
- if (source.IsValid())
- {
- result = source.Models.First();
- }
-
- //
- return result;
- }
- }
-}
\ No newline at end of file
diff --git a/Extensions/XAiModelsExtensions.cs b/Extensions/XAiModelsExtensions.cs
index 3272da1..7349f07 100644
--- a/Extensions/XAiModelsExtensions.cs
+++ b/Extensions/XAiModelsExtensions.cs
@@ -339,7 +339,7 @@ namespace xAiModels.Extensions
///
///
///
- public static Guid GetDafualtProject(
+ public static Guid GetDafaultProject(
this IEnumerable source,
string ownerId
)
diff --git a/Extensions/XEmbeddingExtensions.cs b/Extensions/XEmbeddingExtensions.cs
index e4a5802..8e88dad 100644
--- a/Extensions/XEmbeddingExtensions.cs
+++ b/Extensions/XEmbeddingExtensions.cs
@@ -1,3 +1,4 @@
+using System;
using xCommons.Extensions;
namespace xAiModels.Extensions
@@ -13,7 +14,8 @@ namespace xAiModels.Extensions
{
//
// Validate ...
- if (source.IsNullOrEmpty()) {
+ if (source.IsNullOrEmpty())
+ {
return [];
}
@@ -28,5 +30,25 @@ namespace xAiModels.Extensions
//
return result;
}
+
+ ///
+ /// Converts ReadOnly Memory to Embedding Representation ...
+ ///
+ ///
+ ///
+ public static string ToEmbedding(this ReadOnlyMemory source)
+ {
+ //
+ var result = string.Empty;
+
+ //
+ if (!source.IsNull() && !source.IsEmpty)
+ {
+ result = source.ToArray().ToJSON();
+ }
+
+ //
+ return result;
+ }
}
}
\ No newline at end of file
diff --git a/Interfaces/IXAiDataProvider.cs b/Interfaces/IXAiDataProvider.cs
index 70bd5d3..a77075c 100644
--- a/Interfaces/IXAiDataProvider.cs
+++ b/Interfaces/IXAiDataProvider.cs
@@ -197,7 +197,7 @@ namespace xAiModels.Interfaces
///
Task GetDefaultConversation(
string ownerId,
- Guid projectId,
+ Guid? projectId,
string connectionId = null,
CancellationToken cancellationToken = default
);
diff --git a/Providers/XAiDataProvider.cs b/Providers/XAiDataProvider.cs
index 0bd2438..2ec35c2 100644
--- a/Providers/XAiDataProvider.cs
+++ b/Providers/XAiDataProvider.cs
@@ -1009,7 +1009,7 @@ namespace xAiModels.Providers
///
public async Task GetDefaultConversation(
string ownerId,
- Guid projectId,
+ Guid? projectId,
string connectionId = null,
CancellationToken cancellationToken = default
)
@@ -1024,8 +1024,8 @@ namespace xAiModels.Providers
//
// Prepare Project ...
XAiProjectDto project = null;
- if (projectId.IsNull() ||
- projectId.IsDefaultGuid()
+ if (!projectId.HasValue ||
+ projectId.Value.IsDefaultGuid()
)
{
//
@@ -1039,7 +1039,7 @@ namespace xAiModels.Providers
{
//
project = await projectRepositoryService.GetAsync(
- id: projectId,
+ id: projectId.Value,
includeBuilder: null,
ignoreSoftDeleteds: true,
cancellationToken: cancellationToken
@@ -1093,7 +1093,7 @@ namespace xAiModels.Providers
var result = await conversationRepositoryService.FindOneAsync(
cancellationToken: cancellationToken,
predicate: x =>
- x.ProjectId == projectId &&
+ x.ProjectId == project.Id &&
x.Title == resource.ResourceTitle
);
@@ -1533,7 +1533,7 @@ namespace xAiModels.Providers
{
//
exists.Text = item.Text;
- exists.Embedding = item.Embedding.ToJSON();
+ exists.Embedding = item.Embedding.ToEmbedding();
exists.Type = item.Type.IsNullOrEmpty() ? exists.Type : item.Type;
exists.Metadata = item.Metadata.IsNullOrDefault() ? exists.Metadata : item.Metadata.ToJSON();
toUpdate.Add(exists);
@@ -1547,7 +1547,7 @@ namespace xAiModels.Providers
Type = item.Type,
Identifier = item.Identifier,
Metadata = item.Metadata.ToJSON(),
- Embedding = item.Embedding.ToJSON(),
+ Embedding = item.Embedding.ToEmbedding(),
Id = item.Id.IsDefaultGuid() ? Guid.NewGuid() : item.Id,
});
}
@@ -2057,7 +2057,7 @@ namespace xAiModels.Providers
///
private async Task HasDefaultConversation(
string ownerId,
- Guid projectId,
+ Guid? projectId,
string connectionId = null,
CancellationToken cancellationToken = default
)
@@ -2073,8 +2073,8 @@ namespace xAiModels.Providers
//
// Prepare Project ...
XAiProjectDto project = null;
- if (projectId.IsNull() ||
- projectId.IsDefaultGuid()
+ if (!projectId.HasValue ||
+ projectId.Value.IsDefaultGuid()
)
{
//
@@ -2088,7 +2088,7 @@ namespace xAiModels.Providers
{
//
project = await projectRepositoryService.GetAsync(
- id: projectId,
+ id: projectId.Value,
includeBuilder: null,
ignoreSoftDeleteds: true,
cancellationToken: cancellationToken
@@ -2124,7 +2124,7 @@ namespace xAiModels.Providers
var defaultConversation = await conversationRepositoryService.FindOneAsync(
cancellationToken: cancellationToken,
predicate: x =>
- x.ProjectId == projectId &&
+ x.ProjectId == project.Id &&
x.Title == resource.ResourceTitle
);
result = !defaultConversation.IsNullOrDefault();
@@ -2143,7 +2143,7 @@ namespace xAiModels.Providers
///
private async Task CreateDefaultConversation(
string ownerId,
- Guid projectId,
+ Guid? projectId,
string connectionId = null,
CancellationToken cancellationToken = default
)
@@ -2162,8 +2162,8 @@ namespace xAiModels.Providers
//
// Prepare Project ...
XAiProjectDto project = null;
- if (projectId.IsNull() ||
- projectId.IsDefaultGuid()
+ if (!projectId.HasValue ||
+ projectId.Value.IsDefaultGuid()
)
{
//
@@ -2177,7 +2177,7 @@ namespace xAiModels.Providers
{
//
project = await projectRepositoryService.GetAsync(
- id: projectId,
+ id: projectId.Value,
includeBuilder: null,
ignoreSoftDeleteds: true,
cancellationToken: cancellationToken