Add Response ctor overload, agent Ids, and metadata fields

- Added a new Response constructor overload for simpler instantiation with conversationId, streamState, and optional tokenUsageResponse.
- Updated AddAIAgent registrations for "ReformulationAgent" and "RagAgent" to set Id to the lower-cased key.
- Modified VectorSearchService to use the new Response constructor, omitting now-optional parameters.
- Enhanced ContextProvider: TextSearchResult now includes a RawRepresentation property with chunk metadata (Id, DocumentId, PageNumber, IndexOnPage, Content).
This commit is contained in:
Marco Minerva
2026-07-24 17:38:12 +02:00
parent 6c3e539272
commit f474d8fe82
3 changed files with 9 additions and 1 deletions
@@ -7,4 +7,9 @@ public record class Response(Guid ConversationId, string? OriginalQuestion, stri
: this(conversationId, null, null, token, streamState, tokenUsageResponse)
{
}
public Response(Guid conversationId, StreamState streamState, TokenUsageResponse? tokenUsageResponse = null)
: this(conversationId, null, null, null, streamState, tokenUsageResponse)
{
}
}
+2
View File
@@ -117,6 +117,7 @@ builder.Services.AddAIAgent("ReformulationAgent", (services, key) =>
return chatClient.AsAIAgent(new ChatClientAgentOptions()
{
Id = key.ToLowerInvariant(),
Name = key,
ChatOptions = new()
{
@@ -209,6 +210,7 @@ builder.Services.AddAIAgent("RagAgent", (services, key) =>
return chatClient.AsAIAgent(new ChatClientAgentOptions
{
Id = key.ToLowerInvariant(),
Name = key,
ChatOptions = new()
{
@@ -84,7 +84,7 @@ public partial class VectorSearchService([FromKeyedServices("EmbeddingWorkflow")
await sessionStore.SaveSessionAsync(ragAgent, question.ConversationId.ToString(), session, cancellationToken);
var response = updates.ToAgentResponse();
yield return new(question.ConversationId, null, null, response.Text, StreamState.End, new TokenUsageResponse(null, response.Usage));
yield return new(question.ConversationId, StreamState.End, new TokenUsageResponse(null, response.Usage));
}
}
@@ -105,6 +105,7 @@ public class ContextProvider(ApplicationDbContext dbContext, IEmbeddingGenerator
SourceLink = c.Id.ToString().ToLowerInvariant(),
SourceName = c.Document.Name,
Text = c.Content,
RawRepresentation = new { c.Id, c.DocumentId, c.PageNumber, c.IndexOnPage, c.Content }
})
.ToListAsync(cancellationToken);