last works on Models ...
This commit is contained in:
@@ -147,6 +147,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
|
||||
//
|
||||
result = await conversationTitleResourceProvider.GetResource(
|
||||
owner: null,
|
||||
identifier: title,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
// Run independent async operations concurrently
|
||||
var ownerTask = ResolveOwnerAsync(source.OwnerId, cancellationToken);
|
||||
var conversationTask = ResolveConversationAsync(source.ConversationId, cancellationToken);
|
||||
|
||||
//
|
||||
// wait until All Tasks Resolved ...
|
||||
await Task.WhenAll(ownerTask, conversationTask);
|
||||
|
||||
@@ -34,22 +34,90 @@ namespace xAiModels.Providers.Enrichers
|
||||
this.projectDescriptionResourceProvider = projectDescriptionResourceProvider;
|
||||
}
|
||||
|
||||
public Task EnrichAsync(
|
||||
public async Task EnrichAsync(
|
||||
XAiProjectDto source,
|
||||
XAiProjectDto destination,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
await EnrichAsync(
|
||||
source: source,
|
||||
destination: destination,
|
||||
fillConversations: false,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
public Task EnrichRangeAsync(
|
||||
public async Task EnrichAsync(
|
||||
XAiProjectDto source,
|
||||
XAiProjectDto destination,
|
||||
bool fillConversations = true,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Run independent async operations concurrently
|
||||
var titleTask = ResolveTitleAsync(source.Title, cancellationToken);
|
||||
var ownerTask = ResolveOwnerAsync(source.OwnerId, cancellationToken);
|
||||
var conversationsTask = ResolveConversationsAsync(source.Id, cancellationToken);
|
||||
var descriptionTask = ResolveDescriptionAsync(source.Description, cancellationToken);
|
||||
|
||||
//
|
||||
// wait until All Tasks Resolved ...
|
||||
Task[] tasks =
|
||||
{
|
||||
titleTask,
|
||||
ownerTask,
|
||||
descriptionTask
|
||||
};
|
||||
if (fillConversations)
|
||||
{
|
||||
tasks = [.. tasks, conversationsTask];
|
||||
}
|
||||
await Task.WhenAll(tasks);
|
||||
|
||||
//
|
||||
// Attached Resolved Info to Destination ...
|
||||
destination.Owner = ownerTask.Result;
|
||||
destination.TitleResource = titleTask.Result;
|
||||
destination.DescriptionResource = descriptionTask.Result;
|
||||
if (!conversationsTask.Result.IsNull())
|
||||
{
|
||||
destination.Conversations = [.. conversationsTask.Result];
|
||||
}
|
||||
}
|
||||
|
||||
public async Task EnrichRangeAsync(
|
||||
IEnumerable<XAiProjectDto> sources,
|
||||
IEnumerable<XAiProjectDto> destinations,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//
|
||||
// Make Tasks Ready ...
|
||||
var tasks = sources.Zip(destinations, (src, dst) =>
|
||||
EnrichAsync(src, dst, cancellationToken)
|
||||
);
|
||||
|
||||
//
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
public async Task EnrichRangeAsync(
|
||||
IEnumerable<XAiProjectDto> sources,
|
||||
IEnumerable<XAiProjectDto> destinations,
|
||||
bool fillConversations = true,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Make Tasks Ready ...
|
||||
var tasks = sources.Zip(destinations, (src, dst) =>
|
||||
EnrichAsync(src, dst, fillConversations, cancellationToken)
|
||||
);
|
||||
|
||||
//
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -111,6 +179,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
|
||||
//
|
||||
result = await projectTitleResourceProvider.GetResource(
|
||||
owner: null,
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
@@ -142,6 +211,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
|
||||
//
|
||||
result = await projectDescriptionResourceProvider.GetResource(
|
||||
owner: null,
|
||||
identifier: identifier,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user