Skip to content

Commit 70477fd

Browse files
author
Jicheng Lu
committed
patch annotations
1 parent 349e58e commit 70477fd

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public async Task<RoleDialogModel> GetChatCompletions(Agent agent, List<RoleDial
6666
{
6767
CurrentAgentId = agent.Id,
6868
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
69+
ToolCallId = toolCall?.Id,
6970
FunctionName = toolCall?.FunctionName,
7071
FunctionArgs = toolCall?.FunctionArguments?.ToString(),
7172
RenderedInstruction = string.Join("\r\n", renderedInstructions)
@@ -83,7 +84,14 @@ public async Task<RoleDialogModel> GetChatCompletions(Agent agent, List<RoleDial
8384
{
8485
CurrentAgentId = agent.Id,
8586
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
86-
RenderedInstruction = string.Join("\r\n", renderedInstructions)
87+
RenderedInstruction = string.Join("\r\n", renderedInstructions),
88+
Annotations = value.Annotations?.Select(x => new ChatAnnotation
89+
{
90+
Title = x.WebResourceTitle,
91+
Url = x.WebResourceUri.AbsoluteUri,
92+
StartIndex = x.StartIndex,
93+
EndIndex = x.EndIndex
94+
})?.ToList()
8795
};
8896
}
8997
}
@@ -201,6 +209,19 @@ public async Task<bool> GetChatCompletionsAsync(Agent agent,
201209
else
202210
{
203211
// Text response received
212+
msg = new RoleDialogModel(AgentRole.Assistant, text)
213+
{
214+
CurrentAgentId = agent.Id,
215+
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
216+
RenderedInstruction = string.Join("\r\n", renderedInstructions),
217+
Annotations = value.Annotations?.Select(x => new ChatAnnotation
218+
{
219+
Title = x.WebResourceTitle,
220+
Url = x.WebResourceUri.AbsoluteUri,
221+
StartIndex = x.StartIndex,
222+
EndIndex = x.EndIndex
223+
})?.ToList()
224+
};
204225
await onMessageReceived(msg);
205226
}
206227

src/Plugins/BotSharp.Plugin.DeepSeekAI/Providers/Chat/ChatCompletionProvider.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ public async Task<RoleDialogModel> GetChatCompletions(Agent agent, List<RoleDial
7777
{
7878
CurrentAgentId = agent.Id,
7979
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
80-
RenderedInstruction = string.Join("\r\n", renderedInstructions)
80+
RenderedInstruction = string.Join("\r\n", renderedInstructions),
81+
Annotations = value.Annotations?.Select(x => new ChatAnnotation
82+
{
83+
Title = x.WebResourceTitle,
84+
Url = x.WebResourceUri.AbsoluteUri,
85+
StartIndex = x.StartIndex,
86+
EndIndex = x.EndIndex
87+
})?.ToList()
8188
};
8289
}
8390

@@ -171,6 +178,19 @@ public async Task<bool> GetChatCompletionsAsync(Agent agent, List<RoleDialogMode
171178
else
172179
{
173180
// Text response received
181+
msg = new RoleDialogModel(AgentRole.Assistant, text)
182+
{
183+
CurrentAgentId = agent.Id,
184+
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
185+
RenderedInstruction = string.Join("\r\n", renderedInstructions),
186+
Annotations = value.Annotations?.Select(x => new ChatAnnotation
187+
{
188+
Title = x.WebResourceTitle,
189+
Url = x.WebResourceUri.AbsoluteUri,
190+
StartIndex = x.StartIndex,
191+
EndIndex = x.EndIndex
192+
})?.ToList()
193+
};
174194
await onMessageReceived(msg);
175195
}
176196

src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ public async Task<bool> GetChatCompletionsAsync(Agent agent,
179179
else
180180
{
181181
// Text response received
182+
msg = new RoleDialogModel(AgentRole.Assistant, text)
183+
{
184+
CurrentAgentId = agent.Id,
185+
MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty,
186+
RenderedInstruction = string.Join("\r\n", renderedInstructions),
187+
Annotations = value.Annotations?.Select(x => new ChatAnnotation
188+
{
189+
Title = x.WebResourceTitle,
190+
Url = x.WebResourceUri.AbsoluteUri,
191+
StartIndex = x.StartIndex,
192+
EndIndex = x.EndIndex
193+
})?.ToList()
194+
};
182195
await onMessageReceived(msg);
183196
}
184197

0 commit comments

Comments
 (0)