last ...
This commit is contained in:
@@ -28,7 +28,6 @@ namespace xAiModels.Extensions
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.OwnerId.IsNullOrEmpty() &&
|
||||
!source.Title.IsNullOrEmpty() &&
|
||||
!source.Prompt.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
@@ -40,7 +39,6 @@ namespace xAiModels.Extensions
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.OwnerId.IsNullOrEmpty() &&
|
||||
!source.Title.IsNullOrEmpty() &&
|
||||
!source.Prompt.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
@@ -58,7 +56,6 @@ namespace xAiModels.Extensions
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.OwnerId.IsNullOrEmpty() &&
|
||||
!source.Title.IsNullOrEmpty() &&
|
||||
!source.ProjectId.IsNull() &&
|
||||
!source.ProjectId.IsDefaultGuid();
|
||||
|
||||
@@ -71,7 +68,6 @@ namespace xAiModels.Extensions
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.OwnerId.IsNullOrEmpty() &&
|
||||
!source.Title.IsNullOrEmpty() &&
|
||||
!source.ProjectId.IsNull() &&
|
||||
!source.ProjectId.IsDefaultGuid();
|
||||
|
||||
@@ -222,7 +218,7 @@ namespace xAiModels.Extensions
|
||||
.Contains(ownerId.ToNormalString()) &&
|
||||
x.Title
|
||||
.ToNormalString()
|
||||
.Contains(XAiModelsConstants.DefaultXAiProjectDescriptionResourceID)
|
||||
.Contains(XAiModelsConstants.DefaultXAiProjectDescriptionResourceID.ToNormalString())
|
||||
);
|
||||
|
||||
//
|
||||
@@ -287,7 +283,7 @@ namespace xAiModels.Extensions
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
if (source.HasChild() ||
|
||||
if (!source.HasChild() ||
|
||||
ownerId.IsNullOrEmpty())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
@@ -301,7 +297,7 @@ namespace xAiModels.Extensions
|
||||
.Contains(ownerId.ToNormalString()) &&
|
||||
x.Title
|
||||
.ToNormalString()
|
||||
.Contains(XAiModelsConstants.DefaultXAiProjectDescriptionResourceID)
|
||||
.Contains(XAiModelsConstants.XAiProjectTitleIdentifier.ToNormalString())
|
||||
);
|
||||
if (item.IsNullOrDefault())
|
||||
{
|
||||
@@ -327,7 +323,8 @@ namespace xAiModels.Extensions
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
if (source.HasChild() ||
|
||||
if (!source.HasChild() ||
|
||||
ownerId.IsNullOrEmpty() ||
|
||||
projectId.IsDefaultGuid())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
@@ -341,11 +338,12 @@ namespace xAiModels.Extensions
|
||||
.Contains(ownerId.ToNormalString()) &&
|
||||
x.Title
|
||||
.ToNormalString()
|
||||
.Contains(projectId.ToString().ToNormalString()) &&
|
||||
x.Title
|
||||
.ToNormalString()
|
||||
.Contains(XAiModelsConstants.DefaultXAiConversationTitleResourceID)
|
||||
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier.ToNormalString())
|
||||
);
|
||||
if (item.IsNullOrDefault())
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var result = item.Id;
|
||||
|
||||
@@ -222,12 +222,14 @@ namespace xAiModels.Interfaces
|
||||
/// <summary>
|
||||
/// Create Conversation ...
|
||||
/// </summary>
|
||||
/// <param name="ownerId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XAiConversationDto> CreateConversation(
|
||||
string ownerId,
|
||||
Guid projectId,
|
||||
XAiConversationDto item = null,
|
||||
string connectionId = null,
|
||||
|
||||
+252
-16
@@ -397,6 +397,14 @@ namespace xAiModels.Providers
|
||||
|
||||
//
|
||||
#region Creator/Adders ...
|
||||
/// <summary>
|
||||
/// Create Project ...
|
||||
/// </summary>
|
||||
/// <param name="ownerId"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XAiProjectDto> CreateProject(
|
||||
string ownerId,
|
||||
XAiProjectDto item = null,
|
||||
@@ -420,6 +428,7 @@ namespace xAiModels.Providers
|
||||
if (hasProject)
|
||||
{
|
||||
//
|
||||
item.OwnerId = ownerId;
|
||||
item.CreatedOn = DateTime.UtcNow;
|
||||
|
||||
//
|
||||
@@ -432,18 +441,132 @@ namespace xAiModels.Providers
|
||||
|
||||
//
|
||||
XAiProjectDto result = null;
|
||||
var defaultLanguage = appConfiguration.DefaultLanguage;
|
||||
|
||||
//
|
||||
// Create Provided Project ...
|
||||
if (hasProject)
|
||||
{
|
||||
//
|
||||
// Add Item for ID Gneneration ...
|
||||
result = await projectRepositoryService.AddAsync(
|
||||
item: item,
|
||||
saveChanges: true,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
// Checking Resources ...
|
||||
|
||||
//
|
||||
// Titles ...
|
||||
var titleResource = string.Empty;
|
||||
if (!item.TitleResource.IsNullOrDefault() &&
|
||||
item.TitleResource.Locales.HasChild())
|
||||
{
|
||||
//
|
||||
// Adding Title Resource Locales ...
|
||||
var isDefaultLanguageHandled = false;
|
||||
foreach (var trl in item.TitleResource.Locales)
|
||||
{
|
||||
//
|
||||
// Attaching Default Language ...
|
||||
if (!isDefaultLanguageHandled &&
|
||||
trl.Language.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
trl.Language = defaultLanguage;
|
||||
isDefaultLanguageHandled = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Value Exists ...
|
||||
if (trl.Value.IsNullOrEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
var resource = await projectTitleResourceProvider.AddOrUpdateLocale(
|
||||
locale: trl,
|
||||
owner: ownerId,
|
||||
identifier: result.Id,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (!resource.IsNullOrDefault() &&
|
||||
titleResource.IsNullOrEmpty())
|
||||
{
|
||||
titleResource = resource.Resource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Descriptions ...
|
||||
var descriptionResource = string.Empty;
|
||||
if (!item.DescriptionResource.IsNullOrDefault() &&
|
||||
item.DescriptionResource.Locales.HasChild())
|
||||
{
|
||||
//
|
||||
// Adding Description Resource Locales ....
|
||||
var isDefaultLanguageHandled = false;
|
||||
foreach (var trl in item.DescriptionResource.Locales)
|
||||
{
|
||||
//
|
||||
// Attaching Default Language ...
|
||||
if (!isDefaultLanguageHandled &&
|
||||
trl.Language.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
trl.Language = defaultLanguage;
|
||||
isDefaultLanguageHandled = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Value Exists ...
|
||||
if (trl.Value.IsNullOrEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
var resource = await projectDescriptionResourceProvider.AddOrUpdateLocale(
|
||||
locale: trl,
|
||||
owner: ownerId,
|
||||
identifier: result.Id,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (!resource.IsNullOrDefault() &&
|
||||
descriptionResource.IsNullOrEmpty())
|
||||
{
|
||||
descriptionResource = resource.Resource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Data ...
|
||||
result.Title = titleResource;
|
||||
result.Description = descriptionResource;
|
||||
result = await projectRepositoryService.UpdateAsync(
|
||||
item: result,
|
||||
id: result.Id,
|
||||
saveChanges: true,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (!result.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
result = await projectEnricher.Enrich(
|
||||
source: result,
|
||||
fillConversations: false,
|
||||
fillConversationMessages: false,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Handling Send Push Notification ...
|
||||
if (!result.IsNullOrDefault() &&
|
||||
@@ -493,11 +616,30 @@ namespace xAiModels.Providers
|
||||
XException.ActionFailed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Enrichment ...
|
||||
result = await Enrich(
|
||||
source: result,
|
||||
fillConversations: false,
|
||||
fillConversationMessages: false,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an AI Conversation ...
|
||||
/// </summary>
|
||||
/// <param name="ownerId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XAiConversationDto> CreateConversation(
|
||||
string ownerId,
|
||||
Guid projectId,
|
||||
XAiConversationDto item = null,
|
||||
string connectionId = null,
|
||||
@@ -536,6 +678,7 @@ namespace xAiModels.Providers
|
||||
if (hasConversation)
|
||||
{
|
||||
//
|
||||
item.OwnerId = ownerId;
|
||||
item.ProjectId = project.Id;
|
||||
item.CreatedOn = DateTime.UtcNow;
|
||||
|
||||
@@ -549,12 +692,14 @@ namespace xAiModels.Providers
|
||||
|
||||
//
|
||||
XAiConversationDto result = null;
|
||||
var defaultLanguage = appConfiguration.DefaultLanguage;
|
||||
|
||||
//
|
||||
// Create Provided Conversation ...
|
||||
if (hasConversation)
|
||||
{
|
||||
//
|
||||
// Add Item for ID Gneneration ...
|
||||
result = await conversationRepositoryService.AddAsync(
|
||||
item: item,
|
||||
saveChanges: true,
|
||||
@@ -562,6 +707,72 @@ namespace xAiModels.Providers
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
// Checking Resources ...
|
||||
|
||||
//
|
||||
// Titles ...
|
||||
var titleResource = string.Empty;
|
||||
if (!item.TitleResource.IsNullOrDefault() &&
|
||||
item.TitleResource.Locales.HasChild())
|
||||
{
|
||||
//
|
||||
// Adding Title Resource Locales ...
|
||||
var isDefaultLanguageHandled = false;
|
||||
foreach (var trl in item.TitleResource.Locales)
|
||||
{
|
||||
//
|
||||
// Attaching Default Language ...
|
||||
if (!isDefaultLanguageHandled &&
|
||||
trl.Language.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
trl.Language = defaultLanguage;
|
||||
isDefaultLanguageHandled = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Value Exists ...
|
||||
if (trl.Value.IsNullOrEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
var resource = await conversationTitleResourceProvider.AddOrUpdateLocale(
|
||||
locale: trl,
|
||||
owner: ownerId,
|
||||
identifier: result.Id,
|
||||
connectionId: connectionId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (!resource.IsNullOrDefault() &&
|
||||
titleResource.IsNullOrEmpty())
|
||||
{
|
||||
titleResource = resource.Resource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Data ...
|
||||
result.Title = titleResource;
|
||||
result = await conversationRepositoryService.UpdateAsync(
|
||||
item: result,
|
||||
id: result.Id,
|
||||
saveChanges: true,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (!result.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
result = await conversationEnricher.Enrich(
|
||||
source: result,
|
||||
fillMessages: false,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Handling Send Push Notification ...
|
||||
if (!result.IsNullOrDefault() &&
|
||||
@@ -613,10 +824,26 @@ namespace xAiModels.Providers
|
||||
XException.ActionFailed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Enrichment ...
|
||||
result = await Enrich(
|
||||
source: result,
|
||||
fillMessages: false,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Message ...
|
||||
/// </summary>
|
||||
/// <param name="conversationId"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XAiMessageDto> AddMessage(
|
||||
Guid conversationId,
|
||||
XAiMessageDto item,
|
||||
@@ -653,6 +880,17 @@ namespace xAiModels.Providers
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
// Handle Enrichment ...
|
||||
if (!result.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
result = await Enrich(
|
||||
source: result,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Handling Send Push Notification ...
|
||||
if (!result.IsNullOrDefault() &&
|
||||
@@ -714,15 +952,14 @@ namespace xAiModels.Providers
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x =>
|
||||
x.ResourceTitle
|
||||
// .ToNormalString()
|
||||
.ToNormalString()
|
||||
.Contains(ownerId.ToNormalString()) &&
|
||||
x.ResourceTitle
|
||||
// .ToNormalString()
|
||||
// .ToNormalString()
|
||||
.Contains(XAiModelsConstants.XAiProjectTitleIdentifier) &&
|
||||
.ToNormalString()
|
||||
.Contains(XAiModelsConstants.XAiProjectTitleIdentifier.ToNormalString()) &&
|
||||
x.TranslatedValue
|
||||
// .ToNormalString()
|
||||
.Contains(XAiDataProviderConstants.XDefaultAiProjectSuffix)
|
||||
.ToNormalString()
|
||||
.Contains(XAiDataProviderConstants.XDefaultAiProjectSuffix.ToNormalString())
|
||||
);
|
||||
if (resource.IsNullOrDefault())
|
||||
{
|
||||
@@ -1101,7 +1338,7 @@ namespace xAiModels.Providers
|
||||
// Prepare Tile and Description Resource Ids ...
|
||||
var titleResource = await projectTitleResourceProvider.AddOrUpdateLocale(
|
||||
owner: ownerId,
|
||||
identifier: item.Id, // $"{XAiDataProviderConstants.XDefaultAiProjectSuffix}_{item.Id}",
|
||||
identifier: item.Id,
|
||||
locale: new XLocaleResourceDto
|
||||
{
|
||||
Language = defaultLang,
|
||||
@@ -1111,7 +1348,7 @@ namespace xAiModels.Providers
|
||||
);
|
||||
var descriptionResource = await projectDescriptionResourceProvider.AddOrUpdateLocale(
|
||||
owner: ownerId,
|
||||
identifier: item.Id, // $"{XAiDataProviderConstants.XDefaultAiProjectSuffix}_{item.Id}",
|
||||
identifier: item.Id,
|
||||
new XLocaleResourceDto
|
||||
{
|
||||
Language = defaultLang,
|
||||
@@ -1209,15 +1446,14 @@ namespace xAiModels.Providers
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x =>
|
||||
x.ResourceTitle
|
||||
// .ToNormalString()
|
||||
// .ToNormalString()
|
||||
.Contains(projectId.ToString()) &&
|
||||
.ToNormalString()
|
||||
.Contains(ownerId.ToString().ToNormalString()) &&
|
||||
x.ResourceTitle
|
||||
// .ToNormalString()
|
||||
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier) &&
|
||||
.ToNormalString()
|
||||
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier.ToNormalString()) &&
|
||||
x.TranslatedValue
|
||||
// .ToNormalString()
|
||||
.Contains(XAiDataProviderConstants.XDefaultAiConversationSuffix)
|
||||
.ToNormalString()
|
||||
.Contains(XAiDataProviderConstants.XDefaultAiConversationSuffix.ToNormalString())
|
||||
);
|
||||
result = !resource.IsNullOrDefault();
|
||||
if (!result)
|
||||
@@ -1324,7 +1560,7 @@ namespace xAiModels.Providers
|
||||
// Prepare Title Resource Ids ...
|
||||
var titleResource = await conversationTitleResourceProvider.AddOrUpdateLocale(
|
||||
owner: ownerId,
|
||||
identifier: item.Id, // $"{XAiDataProviderConstants.XDefaultAiConversationSuffix}_{item.Id}",
|
||||
identifier: item.Id,
|
||||
locale: new XLocaleResourceDto
|
||||
{
|
||||
Language = defaultLang,
|
||||
|
||||
Reference in New Issue
Block a user