last ...
This commit is contained in:
@@ -29,8 +29,7 @@ namespace xAiModels.Extensions
|
|||||||
//
|
//
|
||||||
var result =
|
var result =
|
||||||
!source.IsNullOrDefault() &&
|
!source.IsNullOrDefault() &&
|
||||||
!source.OwnerId.IsNullOrEmpty() &&
|
!source.OwnerId.IsNullOrEmpty();
|
||||||
!source.Prompt.IsNullOrEmpty();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -40,8 +39,7 @@ namespace xAiModels.Extensions
|
|||||||
//
|
//
|
||||||
var result =
|
var result =
|
||||||
!source.IsNullOrDefault() &&
|
!source.IsNullOrDefault() &&
|
||||||
!source.OwnerId.IsNullOrEmpty() &&
|
!source.OwnerId.IsNullOrEmpty();
|
||||||
!source.Prompt.IsNullOrEmpty();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -66,12 +66,14 @@ namespace xAiModels.Interfaces
|
|||||||
/// Load List of Conversations for Specified Project ...
|
/// Load List of Conversations for Specified Project ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="projectId"></param>
|
/// <param name="projectId"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
/// <param name="fillMessages"></param>
|
/// <param name="fillMessages"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="connectionId"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
||||||
Guid projectId,
|
Guid? projectId,
|
||||||
|
string ownerId = null,
|
||||||
bool fillMessages = false,
|
bool fillMessages = false,
|
||||||
string connectionId = null,
|
string connectionId = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
@@ -81,10 +83,14 @@ namespace xAiModels.Interfaces
|
|||||||
/// Load Messages of Specified Conversation ...
|
/// Load Messages of Specified Conversation ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="conversationId"></param>
|
/// <param name="conversationId"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<XAiMessageDto>> LoadMessages(
|
Task<IEnumerable<XAiMessageDto>> LoadMessages(
|
||||||
Guid conversationId,
|
Guid? conversationId,
|
||||||
|
string ownerId = null,
|
||||||
|
string connectionId = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
+161
-16
@@ -190,30 +190,51 @@ namespace xAiModels.Providers
|
|||||||
/// Load List of Conversations for Specified Project ...
|
/// Load List of Conversations for Specified Project ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="projectId"></param>
|
/// <param name="projectId"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="ownerId"></param>
|
||||||
/// <param name="fillMessages"></param>
|
/// <param name="fillMessages"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
public async Task<IEnumerable<XAiConversationDto>> LoadConversations(
|
||||||
Guid projectId,
|
Guid? projectId,
|
||||||
|
string ownerId = null,
|
||||||
bool fillMessages = false,
|
bool fillMessages = false,
|
||||||
string connectionId = null,
|
string connectionId = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate Args ...
|
// Validate ...
|
||||||
if (projectId.IsNull() ||
|
if (ownerId.IsNullOrEmpty())
|
||||||
projectId.IsDefaultGuid()
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
if (projectId.IsNull() ||
|
||||||
|
!projectId.HasValue
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var defaultProject = await GetDefaultProject(
|
||||||
|
ownerId: ownerId,
|
||||||
|
connectionId: null,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
if (defaultProject.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
XException.InvalidData.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
projectId = defaultProject.Id;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retrieve Project ...
|
// Retrieve Project ...
|
||||||
var project = await projectRepositoryService.GetAsync(
|
var project = await projectRepositoryService.GetAsync(
|
||||||
id: projectId,
|
id: projectId.Value,
|
||||||
includeBuilder: null,
|
includeBuilder: null,
|
||||||
ignoreSoftDeleteds: true,
|
ignoreSoftDeleteds: true,
|
||||||
cancellationToken: cancellationToken
|
cancellationToken: cancellationToken
|
||||||
@@ -271,26 +292,60 @@ namespace xAiModels.Providers
|
|||||||
/// Load Messages of Specified Conversation ...
|
/// Load Messages of Specified Conversation ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="conversationId"></param>
|
/// <param name="conversationId"></param>
|
||||||
|
/// <param name="ownerId"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IEnumerable<XAiMessageDto>> LoadMessages(
|
public async Task<IEnumerable<XAiMessageDto>> LoadMessages(
|
||||||
Guid conversationId,
|
Guid? conversationId,
|
||||||
|
string ownerId = null,
|
||||||
|
string connectionId = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Validate Args ...
|
// Validate Args ...
|
||||||
if (conversationId.IsNull() ||
|
if (ownerId.IsNullOrEmpty())
|
||||||
conversationId.IsDefaultGuid()
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize Conversation id ...
|
||||||
|
if (conversationId.IsNull() ||
|
||||||
|
!conversationId.HasValue)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var defaultProject = await GetDefaultProject(
|
||||||
|
ownerId: ownerId,
|
||||||
|
connectionId: connectionId,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
if (defaultProject.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
XException.InvalidData.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var defaultConversation = await GetDefaultConversation(
|
||||||
|
ownerId: ownerId,
|
||||||
|
connectionId: connectionId,
|
||||||
|
projectId: defaultProject.Id,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
if (defaultConversation.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
XException.InvalidData.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
conversationId = defaultConversation.Id;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
var conversation = await conversationRepositoryService.GetAsync(
|
var conversation = await conversationRepositoryService.GetAsync(
|
||||||
id: conversationId,
|
|
||||||
includeBuilder: null,
|
includeBuilder: null,
|
||||||
|
id: conversationId.Value,
|
||||||
ignoreSoftDeleteds: true,
|
ignoreSoftDeleteds: true,
|
||||||
cancellationToken: cancellationToken
|
cancellationToken: cancellationToken
|
||||||
);
|
);
|
||||||
@@ -482,8 +537,12 @@ namespace xAiModels.Providers
|
|||||||
// Checking Resources ...
|
// Checking Resources ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Titles ...
|
#region Titles ...
|
||||||
|
//
|
||||||
var titleResource = string.Empty;
|
var titleResource = string.Empty;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Provided in Locales ...
|
||||||
if (!item.TitleResource.IsNullOrDefault() &&
|
if (!item.TitleResource.IsNullOrDefault() &&
|
||||||
item.TitleResource.Locales.HasChild())
|
item.TitleResource.Locales.HasChild())
|
||||||
{
|
{
|
||||||
@@ -526,8 +585,38 @@ namespace xAiModels.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Descriptions ...
|
// Provided in Title (defaultLanguage) ...
|
||||||
|
if (!item.Title.IsNullOrEmpty() &&
|
||||||
|
titleResource.IsNullOrEmpty() &&
|
||||||
|
item.TitleResource.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var resource = await projectTitleResourceProvider.AddOrUpdateLocale(
|
||||||
|
locale: new XLocaleResourceDto
|
||||||
|
{
|
||||||
|
Value = item.Title,
|
||||||
|
Language = defaultLanguage,
|
||||||
|
},
|
||||||
|
owner: ownerId,
|
||||||
|
identifier: result.Id,
|
||||||
|
connectionId: connectionId,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
if (!resource.IsNullOrDefault() &&
|
||||||
|
titleResource.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
titleResource = resource.Resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Descriptions ...
|
||||||
|
//
|
||||||
var descriptionResource = string.Empty;
|
var descriptionResource = string.Empty;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Provided in Locales ...
|
||||||
if (!item.DescriptionResource.IsNullOrDefault() &&
|
if (!item.DescriptionResource.IsNullOrDefault() &&
|
||||||
item.DescriptionResource.Locales.HasChild())
|
item.DescriptionResource.Locales.HasChild())
|
||||||
{
|
{
|
||||||
@@ -569,6 +658,32 @@ namespace xAiModels.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Provided in Description (defaultLanguage) ...
|
||||||
|
if (!item.Description.IsNullOrEmpty() &&
|
||||||
|
descriptionResource.IsNullOrEmpty() &&
|
||||||
|
item.DescriptionResource.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var resource = await projectDescriptionResourceProvider.AddOrUpdateLocale(
|
||||||
|
locale: new XLocaleResourceDto
|
||||||
|
{
|
||||||
|
Value = item.Description,
|
||||||
|
Language = defaultLanguage,
|
||||||
|
},
|
||||||
|
owner: ownerId,
|
||||||
|
identifier: result.Id,
|
||||||
|
connectionId: connectionId,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
if (!resource.IsNullOrDefault() &&
|
||||||
|
descriptionResource.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
descriptionResource = resource.Resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update Data ...
|
// Update Data ...
|
||||||
result.Title = titleResource;
|
result.Title = titleResource;
|
||||||
@@ -734,8 +849,12 @@ namespace xAiModels.Providers
|
|||||||
// Checking Resources ...
|
// Checking Resources ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Titles ...
|
#region Titles ...
|
||||||
|
//
|
||||||
var titleResource = string.Empty;
|
var titleResource = string.Empty;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Locales ...
|
||||||
if (!item.TitleResource.IsNullOrDefault() &&
|
if (!item.TitleResource.IsNullOrDefault() &&
|
||||||
item.TitleResource.Locales.HasChild())
|
item.TitleResource.Locales.HasChild())
|
||||||
{
|
{
|
||||||
@@ -777,6 +896,32 @@ namespace xAiModels.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Title ...
|
||||||
|
if (!item.Title.IsNullOrEmpty() &&
|
||||||
|
titleResource.IsNullOrEmpty() &&
|
||||||
|
item.TitleResource.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var resource = await conversationTitleResourceProvider.AddOrUpdateLocale(
|
||||||
|
locale: new XLocaleResourceDto
|
||||||
|
{
|
||||||
|
Value = item.Title,
|
||||||
|
Language = defaultLanguage,
|
||||||
|
},
|
||||||
|
owner: ownerId,
|
||||||
|
identifier: result.Id,
|
||||||
|
connectionId: connectionId,
|
||||||
|
cancellationToken: cancellationToken
|
||||||
|
);
|
||||||
|
if (!resource.IsNullOrDefault() &&
|
||||||
|
titleResource.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
titleResource = resource.Resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update Data ...
|
// Update Data ...
|
||||||
result.Title = titleResource;
|
result.Title = titleResource;
|
||||||
@@ -811,7 +956,7 @@ namespace xAiModels.Providers
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//`
|
||||||
// Check Default Conversation ...
|
// Check Default Conversation ...
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user