Fix ToJsonObject serialization failure with anonymous types and add support for custom JsonSerializerOptions (#1113)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
0585c27d53
commit
46d30444a8
1 changed files with 366 additions and 42 deletions
|
|
@ -139,10 +139,10 @@ public sealed class McpClientTool : AIFunction
|
|||
{
|
||||
switch (result.Content.Count)
|
||||
{
|
||||
case 1 when result.Content[0].ToAIContent() is { } aiContent:
|
||||
case 1 when result.Content[0].ToAIContent(JsonSerializerOptions) is { } aiContent:
|
||||
return aiContent;
|
||||
|
||||
case > 1 when result.Content.Select(c => c.ToAIContent()).ToArray() is { } aiContents && aiContents.All(static c => c is not null):
|
||||
case > 1 when result.Content.Select(c => c.ToAIContent(JsonSerializerOptions)).ToArray() is { } aiContents && aiContents.All(static c => c is not null):
|
||||
return aiContents;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue