patch annotations

This commit is contained in:
Jicheng Lu 2025-09-15 14:02:51 -05:00
parent 349e58eee8
commit 70477fdcd9
3 changed files with 56 additions and 2 deletions

View file

@ -66,6 +66,7 @@ public class ChatCompletionProvider : IChatCompletion
{ {
CurrentAgentId = agent.Id, CurrentAgentId = agent.Id,
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty, MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
ToolCallId = toolCall?.Id,
FunctionName = toolCall?.FunctionName, FunctionName = toolCall?.FunctionName,
FunctionArgs = toolCall?.FunctionArguments?.ToString(), FunctionArgs = toolCall?.FunctionArguments?.ToString(),
RenderedInstruction = string.Join("\r\n", renderedInstructions) RenderedInstruction = string.Join("\r\n", renderedInstructions)
@ -83,7 +84,14 @@ public class ChatCompletionProvider : IChatCompletion
{ {
CurrentAgentId = agent.Id, CurrentAgentId = agent.Id,
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty, MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
RenderedInstruction = string.Join("\r\n", renderedInstructions) RenderedInstruction = string.Join("\r\n", renderedInstructions),
Annotations = value.Annotations?.Select(x => new ChatAnnotation
{
Title = x.WebResourceTitle,
Url = x.WebResourceUri.AbsoluteUri,
StartIndex = x.StartIndex,
EndIndex = x.EndIndex
})?.ToList()
}; };
} }
} }
@ -201,6 +209,19 @@ public class ChatCompletionProvider : IChatCompletion
else else
{ {
// Text response received // Text response received
msg = new RoleDialogModel(AgentRole.Assistant, text)
{
CurrentAgentId = agent.Id,
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
RenderedInstruction = string.Join("\r\n", renderedInstructions),
Annotations = value.Annotations?.Select(x => new ChatAnnotation
{
Title = x.WebResourceTitle,
Url = x.WebResourceUri.AbsoluteUri,
StartIndex = x.StartIndex,
EndIndex = x.EndIndex
})?.ToList()
};
await onMessageReceived(msg); await onMessageReceived(msg);
} }

View file

@ -77,7 +77,14 @@ public class ChatCompletionProvider : IChatCompletion
{ {
CurrentAgentId = agent.Id, CurrentAgentId = agent.Id,
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty, MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
RenderedInstruction = string.Join("\r\n", renderedInstructions) RenderedInstruction = string.Join("\r\n", renderedInstructions),
Annotations = value.Annotations?.Select(x => new ChatAnnotation
{
Title = x.WebResourceTitle,
Url = x.WebResourceUri.AbsoluteUri,
StartIndex = x.StartIndex,
EndIndex = x.EndIndex
})?.ToList()
}; };
} }
@ -171,6 +178,19 @@ public class ChatCompletionProvider : IChatCompletion
else else
{ {
// Text response received // Text response received
msg = new RoleDialogModel(AgentRole.Assistant, text)
{
CurrentAgentId = agent.Id,
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
RenderedInstruction = string.Join("\r\n", renderedInstructions),
Annotations = value.Annotations?.Select(x => new ChatAnnotation
{
Title = x.WebResourceTitle,
Url = x.WebResourceUri.AbsoluteUri,
StartIndex = x.StartIndex,
EndIndex = x.EndIndex
})?.ToList()
};
await onMessageReceived(msg); await onMessageReceived(msg);
} }

View file

@ -179,6 +179,19 @@ public class ChatCompletionProvider : IChatCompletion
else else
{ {
// Text response received // Text response received
msg = new RoleDialogModel(AgentRole.Assistant, text)
{
CurrentAgentId = agent.Id,
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
RenderedInstruction = string.Join("\r\n", renderedInstructions),
Annotations = value.Annotations?.Select(x => new ChatAnnotation
{
Title = x.WebResourceTitle,
Url = x.WebResourceUri.AbsoluteUri,
StartIndex = x.StartIndex,
EndIndex = x.EndIndex
})?.ToList()
};
await onMessageReceived(msg); await onMessageReceived(msg);
} }