last ...
This commit is contained in:
+229
-142
@@ -38,10 +38,13 @@ namespace xAiModels.Providers
|
||||
private readonly IXAiMessageEnricher messageEnricher;
|
||||
private readonly IXAiProjectEnricher projectEnricher;
|
||||
private readonly IXAiVectorRepository vectorRepository;
|
||||
private readonly IXAiMcpServerEnricher mcpServerEnricher;
|
||||
private readonly IXAiMcpServerRepository mcpServerRepository;
|
||||
private readonly IXAiConversationEnricher conversationEnricher;
|
||||
private readonly IXAiVectorRepositoryService vectorRepositoryService;
|
||||
private readonly IXAiMessageRepositoryService messageRepositoryService;
|
||||
private readonly IXAiProjectRepositoryService projectRepositoryService;
|
||||
private readonly IXAiMcpServerRepositoryService mcpServerRepositoryService;
|
||||
private readonly IXAiProjectTitleResourceProvider projectTitleResourceProvider;
|
||||
private readonly IXAiConversationRepositoryService conversationRepositoryService;
|
||||
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
||||
@@ -56,10 +59,13 @@ namespace xAiModels.Providers
|
||||
IXAiProjectEnricher projectEnricher,
|
||||
IXAiMessageEnricher messageEnricher,
|
||||
IXAiVectorRepository vectorRepository,
|
||||
IXAiMcpServerEnricher mcpServerEnricher,
|
||||
IXAiMcpServerRepository mcpServerRepository,
|
||||
IXAiConversationEnricher conversationEnricher,
|
||||
IXAiVectorRepositoryService vectorRepositoryService,
|
||||
IXAiMessageRepositoryService messageRepositoryService,
|
||||
IXAiProjectRepositoryService projectRepositoryService,
|
||||
IXAiMcpServerRepositoryService mcpServerRepositoryService,
|
||||
IXAiProjectTitleResourceProvider projectTitleResourceProvider,
|
||||
IXAiConversationRepositoryService conversationRepositoryService,
|
||||
IXAiConversationTitleResourceProvider conversationTitleResourceProvider,
|
||||
@@ -73,10 +79,13 @@ namespace xAiModels.Providers
|
||||
this.messageEnricher = messageEnricher;
|
||||
this.appConfiguration = appConfiguration;
|
||||
this.vectorRepository = vectorRepository;
|
||||
this.mcpServerEnricher = mcpServerEnricher;
|
||||
this.mcpServerRepository = mcpServerRepository;
|
||||
this.conversationEnricher = conversationEnricher;
|
||||
this.vectorRepositoryService = vectorRepositoryService;
|
||||
this.messageRepositoryService = messageRepositoryService;
|
||||
this.projectRepositoryService = projectRepositoryService;
|
||||
this.mcpServerRepositoryService = mcpServerRepositoryService;
|
||||
this.projectTitleResourceProvider = projectTitleResourceProvider;
|
||||
this.conversationRepositoryService = conversationRepositoryService;
|
||||
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
||||
@@ -1149,6 +1158,111 @@ namespace xAiModels.Providers
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Messages ...
|
||||
/// </summary>
|
||||
/// <param name="ownerId"></param>
|
||||
/// <param name="conversationId"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<XAiMessageDto>> QueryMessages(
|
||||
string ownerId,
|
||||
Guid conversationId,
|
||||
XQuery query,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (conversationId.IsDefaultGuid())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Conversation ...
|
||||
var conversation = await conversationRepositoryService.GetAsync(
|
||||
id: conversationId,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (conversation.IsNullOrDefault())
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
Expression<Func<XAiMessage, bool>> predicate = x =>
|
||||
x.ConversationId == conversationId;
|
||||
if (!ownerId.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
predicate = x =>
|
||||
x.OwnerId == ownerId &&
|
||||
x.ConversationId == conversationId;
|
||||
}
|
||||
|
||||
//
|
||||
var result = await messageRepositoryService.QueryAsync(
|
||||
query: query,
|
||||
predicate: predicate,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken,
|
||||
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
||||
);
|
||||
if (!result.IsNullOrDefault() &&
|
||||
result.Items.HasChild())
|
||||
{
|
||||
//
|
||||
result.Items = [..await EnrichRange(
|
||||
sources: result.Items,
|
||||
cancellationToken: cancellationToken
|
||||
)];
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query McpServers ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<XAiMcpServerDto>> QueryMcpServers(
|
||||
XQuery query,
|
||||
Expression<Func<XAiMcpServer, bool>> predicate = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await mcpServerRepositoryService.QueryAsync(
|
||||
query: query,
|
||||
predicate: predicate,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken,
|
||||
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
||||
);
|
||||
if (!result.IsNullOrDefault() &&
|
||||
result.Items.HasChild())
|
||||
{
|
||||
//
|
||||
result.Items = [..await EnrichRange(
|
||||
sources: result.Items,
|
||||
cancellationToken: cancellationToken
|
||||
)];
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Conversations ...
|
||||
/// </summary>
|
||||
@@ -1218,75 +1332,6 @@ namespace xAiModels.Providers
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Messages ...
|
||||
/// </summary>
|
||||
/// <param name="ownerId"></param>
|
||||
/// <param name="conversationId"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<XAiMessageDto>> QueryMessages(
|
||||
string ownerId,
|
||||
Guid conversationId,
|
||||
XQuery query,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (conversationId.IsDefaultGuid())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Conversation ...
|
||||
var conversation = await conversationRepositoryService.GetAsync(
|
||||
id: conversationId,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
if (conversation.IsNullOrDefault())
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
Expression<Func<XAiMessage, bool>> predicate = x =>
|
||||
x.ConversationId == conversationId;
|
||||
if (!ownerId.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
predicate = x =>
|
||||
x.OwnerId == ownerId &&
|
||||
x.ConversationId == conversationId;
|
||||
}
|
||||
|
||||
//
|
||||
var result = await messageRepositoryService.QueryAsync(
|
||||
query: query,
|
||||
predicate: predicate,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken,
|
||||
orderBuilder: x => x.OrderBy(y => y.CreatedOn)
|
||||
);
|
||||
if (!result.IsNullOrDefault() &&
|
||||
result.Items.HasChild())
|
||||
{
|
||||
//
|
||||
result.Items = [..await EnrichRange(
|
||||
sources: result.Items,
|
||||
cancellationToken: cancellationToken
|
||||
)];
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
@@ -1674,48 +1719,6 @@ namespace xAiModels.Providers
|
||||
|
||||
//
|
||||
#region Enrichers ...
|
||||
/// <summary>
|
||||
/// Enrich Specified Item ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XAiVectorDto> Enrich(
|
||||
XAiVector source,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await vectorEnricher.Enrich(
|
||||
source: source,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Items ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
||||
IEnumerable<XAiVector> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await vectorEnricher.EnrichRange(
|
||||
sources: sources,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Item ...
|
||||
/// </summary>
|
||||
@@ -1738,19 +1741,40 @@ namespace xAiModels.Providers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Items ...
|
||||
/// Enrich Specified Item ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
||||
IEnumerable<XAiVectorDto> sources,
|
||||
public async Task<XAiVectorDto> Enrich(
|
||||
XAiVector source,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await vectorEnricher.EnrichRange(
|
||||
sources: sources,
|
||||
var result = await vectorEnricher.Enrich(
|
||||
source: source,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Item ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XAiMessageDto> Enrich(
|
||||
XAiMessageDto source,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await messageEnricher.Enrich(
|
||||
source: source,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
@@ -1786,26 +1810,20 @@ namespace xAiModels.Providers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Items ...
|
||||
/// Enrich Specified Item ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="fillConversations"></param>
|
||||
/// <param name="fillConversationMessages"></param>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
||||
IEnumerable<XAiProjectDto> sources,
|
||||
bool fillConversations = false,
|
||||
bool fillConversationMessages = false,
|
||||
public async Task<XAiMcpServerDto> Enrich(
|
||||
XAiMcpServerDto source,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await projectEnricher.EnrichRange(
|
||||
sources: sources,
|
||||
fillConversations: fillConversations,
|
||||
cancellationToken: cancellationToken,
|
||||
fillConversationMessages: fillConversationMessages
|
||||
var result = await mcpServerEnricher.Enrich(
|
||||
source: source,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
@@ -1840,19 +1858,16 @@ namespace xAiModels.Providers
|
||||
/// Enrich Specified Items ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="fillMessages"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
||||
IEnumerable<XAiConversationDto> sources,
|
||||
bool fillMessages = false,
|
||||
public async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
||||
IEnumerable<XAiVector> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await conversationEnricher.EnrichRange(
|
||||
var result = await vectorEnricher.EnrichRange(
|
||||
sources: sources,
|
||||
fillMessages: fillMessages,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
@@ -1861,19 +1876,19 @@ namespace xAiModels.Providers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Item ...
|
||||
/// Enrich Specified Items ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XAiMessageDto> Enrich(
|
||||
XAiMessageDto source,
|
||||
public async Task<IEnumerable<XAiVectorDto>> EnrichRange(
|
||||
IEnumerable<XAiVectorDto> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await messageEnricher.Enrich(
|
||||
source: source,
|
||||
var result = await vectorEnricher.EnrichRange(
|
||||
sources: sources,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
@@ -1881,6 +1896,33 @@ namespace xAiModels.Providers
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Items ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="fillConversations"></param>
|
||||
/// <param name="fillConversationMessages"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XAiProjectDto>> EnrichRange(
|
||||
IEnumerable<XAiProjectDto> sources,
|
||||
bool fillConversations = false,
|
||||
bool fillConversationMessages = false,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await projectEnricher.EnrichRange(
|
||||
sources: sources,
|
||||
fillConversations: fillConversations,
|
||||
cancellationToken: cancellationToken,
|
||||
fillConversationMessages: fillConversationMessages
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Items ...
|
||||
/// </summary>
|
||||
@@ -1901,6 +1943,51 @@ namespace xAiModels.Providers
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Items ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
|
||||
IEnumerable<XAiMcpServerDto> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await mcpServerEnricher.EnrichRange(
|
||||
sources: sources,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Specified Items ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="fillMessages"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XAiConversationDto>> EnrichRange(
|
||||
IEnumerable<XAiConversationDto> sources,
|
||||
bool fillMessages = false,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await conversationEnricher.EnrichRange(
|
||||
sources: sources,
|
||||
fillMessages: fillMessages,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user