Make projectId Nullable in Data Provider and Remove Api Configuration

- IXAiDataProvider.GetDefaultConversation: projectId changed from Guid to Guid?;
- XAiDataProvider.GetDefaultConversation / HasDefaultConversation /
  CreateDefaultConversation: adapt to Guid? (use !projectId.HasValue instead of
  projectId.IsNull(); resolve project via projectId.Value);
- XAiDataProvider: conversation lookup predicate fixed to
  x.ProjectId == project.Id (was x.ProjectId == projectId);
- XEmbeddingExtensions: add ToEmbedding(this ReadOnlyMemory<float>) to persist
  embeddings as JSON;
- XAiDataProvider: use item.Embedding.ToEmbedding() instead of ToJSON() when
  upserting vectors;
- XAiModelsExtensions: rename GetDafualtProject -> GetDafaultProject (typo fix);
- Remove Configurations/XAiApiConfiguration.cs and
  Extensions/XAiApiConfigurationExtensions.cs (Api configuration does not belong
  to the models module).
BREAKING: XAiApiConfiguration / XAiApiConfigurationExtensions removed from
          xAiModels; GetDafualtProject renamed to GetDafaultProject.
This commit is contained in:
2026-11-02 16:37:27 +03:30
parent c4b7e86174
commit 9e7710e345
6 changed files with 41 additions and 89 deletions
+16 -16
View File
@@ -1009,7 +1009,7 @@ namespace xAiModels.Providers
/// <returns></returns>
public async Task<XAiConversationDto> 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
/// <returns></returns>
private async Task<bool> 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
/// <returns></returns>
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