368 instantiations of FunctionCallContent
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvocationContext.cs (1)
42
get => field ??=
new
(string.Empty, _nopFunction.Name, EmptyReadOnlyDictionary<string, object?>.Instance);
Microsoft.Extensions.AI.Abstractions (1)
Contents\FunctionCallContent.cs (1)
100
return new
FunctionCallContent
(callId, name, arguments)
Microsoft.Extensions.AI.Abstractions.Tests (33)
ChatCompletion\ChatMessageTests.cs (2)
148
new
FunctionCallContent
("callId1", "fc1"),
271
new
FunctionCallContent
("function-id", "plugin-name-function-name", new Dictionary<string, object?> { ["parameter"] = "argument" }),
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (1)
1127
new() { Contents = [new
FunctionCallContent
("fc1", "SearchTool", new Dictionary<string, object?> { ["q"] = "test" })] },
ChatCompletion\ChatResponseUpdateTests.cs (3)
94
new
FunctionCallContent
("callId1", "fc1"),
123
new
FunctionCallContent
("callId1", "fc1"),
186
new
FunctionCallContent
("callId1", "fc1"),
Contents\AIContentTests.cs (3)
72
new
FunctionCallContent
("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } }),
77
new ToolApprovalRequestContent("request123", new
FunctionCallContent
("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } })),
78
new ToolApprovalResponseContent("request123", approved: true, new
FunctionCallContent
("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } })),
Contents\FunctionCallContentTests.cs (7)
21
FunctionCallContent c =
new
("callId1", "name");
39
FunctionCallContent c =
new
("id", "name", args);
52
FunctionCallContent c =
new
("callId1", "name");
87
var sut = new
FunctionCallContent
("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" })
148
var original = new
FunctionCallContent
("callId1", "functionName") { InformationalOnly = informationalOnly };
164
var sut = new
FunctionCallContent
("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) { Exception = ex };
412
var content = new
FunctionCallContent
("call123", "myFunction")
Contents\InputRequestContentTests.cs (1)
40
new ToolApprovalRequestContent("request123", new
FunctionCallContent
("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } })),
Contents\InputResponseContentTests.cs (1)
39
new ToolApprovalResponseContent("request123", true, new
FunctionCallContent
("call123", "functionName")),
Contents\ToolApprovalRequestContentTests.cs (7)
16
Assert.Throws<ArgumentNullException>("requestId", () => new ToolApprovalRequestContent(null!, new
FunctionCallContent
("FCC1", "TestFunction")));
17
Assert.Throws<ArgumentException>("requestId", () => new ToolApprovalRequestContent("", new
FunctionCallContent
("FCC1", "TestFunction")));
18
Assert.Throws<ArgumentException>("requestId", () => new ToolApprovalRequestContent("\r\t\n ", new
FunctionCallContent
("FCC1", "TestFunction")));
24
new
FunctionCallContent
("FCC1", "TestFunction", new Dictionary<string, object?> { { "param1", 123 } }),
65
FunctionCallContent functionCall =
new
("FCC1", "TestFunction");
137
var content = new ToolApprovalRequestContent("req-1", new
FunctionCallContent
("call1", "Func"));
146
var content = new ToolApprovalRequestContent("req-1", new
FunctionCallContent
("call1", "Func"))
Contents\ToolApprovalResponseContentTests.cs (5)
16
Assert.Throws<ArgumentNullException>("requestId", () => new ToolApprovalResponseContent(null!, true, new
FunctionCallContent
("FCC1", "TestFunction")));
17
Assert.Throws<ArgumentException>("requestId", () => new ToolApprovalResponseContent("", true, new
FunctionCallContent
("FCC1", "TestFunction")));
18
Assert.Throws<ArgumentException>("requestId", () => new ToolApprovalResponseContent("\r\t\n ", true, new
FunctionCallContent
("FCC1", "TestFunction")));
24
new
FunctionCallContent
("FCC1", "TestFunction", new Dictionary<string, object?> { { "param1", 123 } }),
82
var content = new ToolApprovalResponseContent("request123", true, new
FunctionCallContent
("call123", "functionName"))
Contents\ToolCallContentTests.cs (1)
56
new
FunctionCallContent
("call1", "function1", new Dictionary<string, object?> { { "param1", 123 } }),
Realtime\RealtimeConversationItemTests.cs (1)
57
var functionCall = new
FunctionCallContent
("call_1", "myFunc");
SpeechToText\SpeechToTextResponseUpdateTests.cs (1)
64
new
FunctionCallContent
("callId1", "fc1"),
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (1)
ScenarioRunResultTests.cs (1)
219
var functionCall = new
FunctionCallContent
(
Microsoft.Extensions.AI.Integration.Tests (1)
PromptBasedFunctionCallingChatClient.cs (1)
118
message.Contents.Add(new
FunctionCallContent
(id, toolCallParsed.Name!, toolCallParsed.Arguments is { } args ? new ReadOnlyDictionary<string, object?>(args) : null));
Microsoft.Extensions.AI.OpenAI.Tests (12)
OpenAIChatClientTests.cs (2)
1472
new
FunctionCallContent
("12345", "SayHello"),
1473
new
FunctionCallContent
("12346", "SayHi"),
OpenAIConversionTests.cs (10)
731
new
FunctionCallContent
("callid123", "SomeFunction", new Dictionary<string, object?>
800
new
FunctionCallContent
("callid123", "SomeFunction", new Dictionary<string, object?>
1220
new
FunctionCallContent
("call123", "TestFunction", new Dictionary<string, object?> { ["param"] = "value" })
1591
new
FunctionCallContent
("process_data", "ProcessComplexData", complexArgs)
1774
var functionCallContent = new
FunctionCallContent
("call-123", "GetWeather", new Dictionary<string, object?>
1812
var functionCall1 = new
FunctionCallContent
("call-1", "Function1", new Dictionary<string, object?> { ["param1"] = "value1" });
1813
var functionCall2 = new
FunctionCallContent
("call-2", "Function2", new Dictionary<string, object?> { ["param2"] = "value2" });
1846
new
FunctionCallContent
("call-123", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" }),
2087
new
FunctionCallContent
("call-123", "TestFunction", new Dictionary<string, object?> { ["param"] = "value" })
2122
new
FunctionCallContent
("call-456", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" })
Microsoft.Extensions.AI.Tests (319)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
201
new
FunctionCallContent
("callid123", "get_data"),
ChatCompletion\DistributedCachingChatClientTest.cs (4)
52
Contents = [new
FunctionCallContent
("someCallId", "functionName", new Dictionary<string, object?>
255
new
FunctionCallContent
("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" }),
266
Contents = [new
FunctionCallContent
("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" })],
316
new() { Role = ChatRole.Assistant, Contents = [new
FunctionCallContent
("callId1", "separator")] },
ChatCompletion\FunctionInvocationContextTests.cs (1)
55
FunctionCallContent callContent =
new
(string.Empty, string.Empty, new Dictionary<string, object?>());
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (165)
41
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
48
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
49
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
77
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
84
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
85
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
124
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
133
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1"))
137
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
175
new
FunctionCallContent
("callId1", "Func1"),
176
new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })
184
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
185
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
220
new
FunctionCallContent
("callId1", "Func1"),
221
new
FunctionCallContent
("callId2", "Unknown"),
229
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
230
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Unknown"))
259
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
260
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
264
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
265
new ToolApprovalResponseContent("ficc_callId2", true, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
272
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
283
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
311
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
312
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
316
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
317
new ToolApprovalResponseContent("ficc_callId2", true, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
325
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
336
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
363
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
367
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
371
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
375
new ToolApprovalResponseContent("ficc_callId2", true, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
382
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]) { MessageId = "resp1" },
383
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]) { MessageId = "resp2" },
394
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]) { MessageId = "resp1" },
395
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]) { MessageId = "resp2" },
422
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
423
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
427
new ToolApprovalResponseContent("ficc_callId1", false, new
FunctionCallContent
("callId1", "Func1")),
428
new ToolApprovalResponseContent("ficc_callId2", false, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
435
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
450
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
481
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
482
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
486
new ToolApprovalResponseContent("ficc_callId1", false, new
FunctionCallContent
("callId1", "Func1")),
487
new ToolApprovalResponseContent("ficc_callId2", true, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
494
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
506
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
514
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
545
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
546
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
550
new ToolApprovalResponseContent("ficc_callId1", false, new
FunctionCallContent
("callId1", "Func1"))
554
new ToolApprovalResponseContent("ficc_callId2", false, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
564
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
579
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
611
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
612
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })),
613
new ToolApprovalRequestContent("ficc_callId3", new
FunctionCallContent
("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } }))
617
new ToolApprovalResponseContent("ficc_callId1", false, new
FunctionCallContent
("callId1", "Func1")) { Reason = "Custom rejection for Func1" },
618
new ToolApprovalResponseContent("ficc_callId2", false, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })),
619
new ToolApprovalResponseContent("ficc_callId3", true, new
FunctionCallContent
("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } }))
628
new
FunctionCallContent
("callId1", "Func1"),
629
new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }),
630
new
FunctionCallContent
("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } })
649
new
FunctionCallContent
("callId1", "Func1"),
650
new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }),
651
new
FunctionCallContent
("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } })
666
new
FunctionCallContent
("callId1", "Func1"),
667
new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }),
668
new
FunctionCallContent
("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } })
703
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
707
new ToolApprovalResponseContent("ficc_callId1", false, new
FunctionCallContent
("callId1", "Func1"))
717
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
731
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
761
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
762
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
766
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
767
new ToolApprovalResponseContent("ficc_callId2", true, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
774
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
780
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 3 } })]),
785
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
789
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 3 } }))
815
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
816
new ToolApprovalRequestContent("ficc_callId2", new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
820
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
821
new ToolApprovalResponseContent("ficc_callId2", true, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
823
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
827
new ToolApprovalRequestContent("ficc_callId3", new
FunctionCallContent
("callId3", "Func1")),
831
new ToolApprovalResponseContent("ficc_callId3", true, new
FunctionCallContent
("callId3", "Func1")),
838
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
840
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId3", "Func1")]),
851
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId3", "Func1")]),
875
var requestFcc = new
FunctionCallContent
("callId1", "Func1");
876
var responseFcc = new
FunctionCallContent
("callId1", "Func1");
945
var request1Fcc = new
FunctionCallContent
("callId1", "Func1");
946
var response1Fcc = new
FunctionCallContent
("callId1", "Func1") { InformationalOnly = true };
948
var request2Fcc = new
FunctionCallContent
("callId2", "Func1");
1040
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1049
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1059
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1086
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
1116
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
1117
new ToolApprovalResponseContent("ficc_callId2", true, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
1124
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1135
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1162
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
1163
new ToolApprovalResponseContent("ficc_callId2", true, new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
1179
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
1206
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
1228
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1256
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
1276
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1302
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
1306
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
1318
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1330
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1357
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
1361
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
1369
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1381
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1415
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1")),
1419
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1")),
1425
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1482
yield return new ChatResponseUpdate(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]) { MessageId = messageId };
1488
new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })
1562
yield return new ChatResponseUpdate(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]) { MessageId = messageId };
1567
new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })
1571
yield return new ChatResponseUpdate(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func3")]) { MessageId = messageId };
1644
var alreadyProcessedFunctionCall = new
FunctionCallContent
("callId1", "Func1") { InformationalOnly = true };
1688
new ToolApprovalRequestContent("approval-request-id", new
FunctionCallContent
("function-call-id", "Func1"))
1692
new ToolApprovalResponseContent("approval-request-id", true, new
FunctionCallContent
("function-call-id", "Func1"))
1704
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("function-call-id", "Func1")]) { MessageId = OriginalMessageId },
1743
new
FunctionCallContent
("callId1", "Func"),
1752
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func")),
1782
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func")),
1787
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func")),
1801
new
FunctionCallContent
("callId1", "Func")
1825
new
FunctionCallContent
("callId1", "Func")
1866
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func")),
1871
new ToolApprovalResponseContent("ficc_callId1", approveFuncCall, new
FunctionCallContent
("callId1", "Func")),
1884
new
FunctionCallContent
("callId1", "Func")
1911
new
FunctionCallContent
("callId1", "Func"),
2098
FunctionCallContent fcc => new
FunctionCallContent
(fcc.CallId, fcc.Name, fcc.Arguments)
ChatCompletion\FunctionInvokingChatClientTests.cs (126)
94
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
96
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
98
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]),
128
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
130
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
132
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]),
161
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
163
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
165
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]),
194
new
FunctionCallContent
("callId1", "Func1"),
195
new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 34 } }),
196
new
FunctionCallContent
("callId3", "Func2", arguments: new Dictionary<string, object?> { { "i", 56 } }),
206
new
FunctionCallContent
("callId4", "Func2", arguments: new Dictionary<string, object?> { { "i", 78 } }),
207
new
FunctionCallContent
("callId5", "Func1")
254
new
FunctionCallContent
("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }),
255
new
FunctionCallContent
("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }),
298
new
FunctionCallContent
("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }),
299
new
FunctionCallContent
("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }),
330
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
332
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
334
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]),
380
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")])));
393
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")])).ToChatResponseUpdates());
461
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")])));
474
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")])).ToChatResponseUpdates());
542
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")])));
555
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")])).ToChatResponseUpdates());
637
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
($"callId0", "VoidReturn")]),
645
plan.Add(new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
($"callId{(i + 1)}", "VoidReturn")]));
668
var message = new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
($"callId{capturedOptions.Count}", "Func1")]);
712
var message = new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
($"callId{capturedOptions.Count}", "Func1")]);
759
var message = new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]);
804
var message = new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]);
960
assistantMessage.Contents.Add(new
FunctionCallContent
(callId, "Func",
984
new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new
FunctionCallContent
("callId1", "Func1"), new TextContent("stuff")]),
986
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
988
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]),
1021
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1043
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
1100
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
1192
new() { Contents = [new
FunctionCallContent
("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] },
1193
new() { Contents = [new
FunctionCallContent
("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] }
1245
new(ChatRole.Assistant, [new
FunctionCallContent
($"callId{chatContents.Count()}", "Func1")]) :
1294
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1", new Dictionary<string, object?> { ["i"] = 41 })]),
1296
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId2", "Func1", new Dictionary<string, object?> { ["i"] = 42 })]),
1304
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId3", "Func1", new Dictionary<string, object?> { ["i"] = 43 })]),
1364
new
FunctionCallContent
("callId1", "Search"),
1365
new
FunctionCallContent
("callId2", "Search", new Dictionary<string, object?> { { "result", "birds" } }),
1366
new
FunctionCallContent
("callId3", "Search"),
1412
return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId-abc", "Func1")]))
1450
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
1480
new
FunctionCallContent
("callId1", "Func1", new Dictionary<string, object?> { ["arg"] = "value1" }),
1481
new
FunctionCallContent
("callId2", "Func1", new Dictionary<string, object?> { ["arg"] = "value2" }),
1533
new
FunctionCallContent
("callId1", "UnknownFunc", new Dictionary<string, object?> { ["i"] = 1 }),
1534
new
FunctionCallContent
("callId2", "KnownFunc", new Dictionary<string, object?> { ["i"] = 2 })
1552
new
FunctionCallContent
("callId1", "UnknownFunc", new Dictionary<string, object?> { ["i"] = 1 }),
1553
new
FunctionCallContent
("callId2", "KnownFunc", new Dictionary<string, object?> { ["i"] = 2 })
1580
new(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "DefOnly")]),
1610
new
FunctionCallContent
("callId1", "Known"),
1611
new
FunctionCallContent
("callId2", "DefOnly")
1645
messages.Add(new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]));
1682
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1741
? new(ChatRole.Assistant, [new
FunctionCallContent
("call1", "Func1")])
1793
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1835
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
1885
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "secret" })]),
1957
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
2006
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
2033
var alreadyProcessedFunctionCall = new
FunctionCallContent
("callId1", "Func1") { InformationalOnly = true };
2085
var needsProcessing = new
FunctionCallContent
("callId1", "Func1") { InformationalOnly = false };
2086
var alreadyProcessed = new
FunctionCallContent
("callId2", "Func2") { InformationalOnly = true };
2161
return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]));
2329
cloned.Add(new
FunctionCallContent
(fcc.CallId, fcc.Name, fcc.Arguments)
2389
[new
FunctionCallContent
("callId1", "FunctionA")])]);
2396
[new
FunctionCallContent
("callId2", "FunctionB")])]);
2412
[new
FunctionCallContent
("callId1", "FunctionA")]);
2418
[new
FunctionCallContent
("callId2", "FunctionB")]);
2483
[new
FunctionCallContent
("callId1", "FunctionA")])]);
2490
[new
FunctionCallContent
("callId2", "FunctionB")])]);
2506
[new
FunctionCallContent
("callId1", "FunctionA")]);
2512
[new
FunctionCallContent
("callId2", "FunctionB")]);
2590
[new
FunctionCallContent
("callId1", "FunctionA")])]);
2596
[new
FunctionCallContent
("callId2", "FunctionB")])]);
2611
[new
FunctionCallContent
("callId1", "FunctionA")]);
2617
[new
FunctionCallContent
("callId2", "FunctionB")]);
2688
[new
FunctionCallContent
("callId1", "FunctionA")])]);
2696
[new
FunctionCallContent
("callId2", "FunctionB"),
2697
new
FunctionCallContent
("callId3", "AdditionalTool")])]);
2712
[new
FunctionCallContent
("callId1", "FunctionA")]);
2718
[new
FunctionCallContent
("callId2", "FunctionB"),
2719
new
FunctionCallContent
("callId3", "AdditionalTool")]);
2792
[new
FunctionCallContent
("callId1", "FunctionA")])]);
2798
[new
FunctionCallContent
("callId2", "SharedName")])]);
2813
[new
FunctionCallContent
("callId1", "FunctionA")]);
2819
[new
FunctionCallContent
("callId2", "SharedName")]);
2890
[new
FunctionCallContent
($"callId{callCount}", "FunctionA")])]);
2905
[new
FunctionCallContent
($"callId{callCount}", "FunctionA")]);
2968
[new
FunctionCallContent
("callId1", "FunctionA")])]);
2976
[new
FunctionCallContent
("callId2", "FunctionB")])]);
2991
[new
FunctionCallContent
("callId1", "FunctionA")]);
2997
[new
FunctionCallContent
("callId2", "FunctionB")]);
3069
[new
FunctionCallContent
("callId1", "FunctionA")])]);
3077
[new
FunctionCallContent
("callId2", "FunctionB")])]);
3092
[new
FunctionCallContent
("callId1", "FunctionA")]);
3098
[new
FunctionCallContent
("callId2", "FunctionB")]);
3175
[new
FunctionCallContent
("callId1", "FunctionA")])]);
3183
[new
FunctionCallContent
("callId2", "FunctionB")])]);
3198
[new
FunctionCallContent
("callId1", "FunctionA")]);
3204
[new
FunctionCallContent
("callId2", "FunctionB")]);
3258
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "UnknownFunc")]),
3288
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
3324
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "TerminatingFunc")]),
3353
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
3362
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1"))
3398
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1"))
3402
new ToolApprovalResponseContent("ficc_callId1", true, new
FunctionCallContent
("callId1", "Func1"))
3435
new ToolApprovalRequestContent("ficc_callId1", new
FunctionCallContent
("callId1", "Func1"))
3439
new ToolApprovalResponseContent("ficc_callId1", false, new
FunctionCallContent
("callId1", "Func1")) { Reason = "User denied" }
3474
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
3482
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]),
3538
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2")]),
3553
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1"), new
FunctionCallContent
("callId2", "Func2")]),
3607
return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]));
3618
var response = new ChatResponse(new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("callId1", "Func1")]));
ChatCompletion\ImageGeneratingChatClientTests.cs (8)
317
[new
FunctionCallContent
(callId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" })]);
360
[new
FunctionCallContent
(callId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" })]);
405
"at-start" => [new
FunctionCallContent
(imageCallId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" }),
408
new
FunctionCallContent
(imageCallId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" })],
410
new
FunctionCallContent
(imageCallId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" }),
480
"at-start" => [new
FunctionCallContent
(imageCallId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" }),
483
new
FunctionCallContent
(imageCallId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" })],
485
new
FunctionCallContent
(imageCallId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" }),
ChatCompletion\OpenTelemetryChatClientTests.cs (4)
116
new(ChatRole.Assistant, [new
FunctionCallContent
("12345", "GetPersonName")]),
408
new
FunctionCallContent
("call-123", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" }),
424
yield return new() { Contents = [new
FunctionCallContent
("call-123", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" })] };
450
new(ChatRole.Assistant, [new
FunctionCallContent
("call-456", "SearchFiles")]),
ChatReduction\MessageCountingChatReducerTests.cs (3)
128
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("call1", "get_weather", new Dictionary<string, object?> { ["location"] = "Seattle" })]),
223
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("call1", "func", null)]),
225
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("call2", "func", null)]),
ChatReduction\SummarizingChatReducerTests.cs (3)
99
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("call1", "get_weather"), new TestInputRequestContent("uir1")]),
188
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("call1", "get_weather", new Dictionary<string, object?> { ["location"] = "Seattle" }), new TestInputRequestContent("uir2")]),
193
new ChatMessage(ChatRole.Assistant, [new
FunctionCallContent
("call2", "get_weather", new Dictionary<string, object?> { ["location"] = "New York" })]),
Realtime\FunctionInvokingRealtimeClientTests.cs (3)
481
new
FunctionCallContent
("call_a", "slow_func"),
482
new
FunctionCallContent
("call_b", "slow_func"),
641
var functionCallContent = new
FunctionCallContent
(callId, functionName, arguments);
Realtime\OpenTelemetryRealtimeClientTests.cs (1)
602
[new
FunctionCallContent
("call_123", "search", new Dictionary<string, object?> { ["query"] = "test" })],
269 references to FunctionCallContent
Microsoft.AspNetCore.Components.AI (9)
Blocks\FunctionApprovalBlock.cs (1)
42
public
FunctionCallContent
? Call => InnerBlock switch
Blocks\FunctionInvocationContentBlock.cs (2)
26
private
FunctionCallContent
? _call;
31
public
FunctionCallContent
? Call
Blocks\UIActionBlock.cs (2)
31
internal UIActionBlock(AIFunction function,
FunctionCallContent
call)
40
public
FunctionCallContent
Call { get; }
Pipeline\FunctionApprovalHandler.cs (2)
34
Id = approvalRequest.ToolCall is
FunctionCallContent
functionCall
48
if (toolCall is
FunctionCallContent
functionCall)
Pipeline\FunctionInvocationHandler.cs (1)
24
if (content is
FunctionCallContent
call)
Pipeline\UIActionHandler.cs (1)
26
if (content is
FunctionCallContent
call &&
Microsoft.Extensions.AI (76)
ChatCompletion\FunctionInvocationContext.cs (1)
40
public
FunctionCallContent
CallContent
ChatCompletion\FunctionInvokingChatClient.cs (56)
30
/// When this client receives a <see cref="
FunctionCallContent
"/> in a chat response from its inner
38
/// <see cref="FunctionInvokingChatClient"/> will not attempt to invoke it, and instead allow that <see cref="
FunctionCallContent
"/>
44
/// attempt to invoke it directly. Instead, it will replace that <see cref="
FunctionCallContent
"/> with a <see cref="ToolApprovalRequestContent"/>
45
/// that wraps the <see cref="
FunctionCallContent
"/> and indicates that the function requires approval before it can be invoked. The caller is then
50
/// Due to the nature of interactions with an underlying <see cref="IChatClient"/>, if any <see cref="
FunctionCallContent
"/> is received
51
/// for a function that requires approval, all received <see cref="
FunctionCallContent
"/> in that same response will also require approval,
296
List<
FunctionCallContent
>? functionCallContents = null; // function call contents that need responding to in the current turn
454
List<
FunctionCallContent
>? functionCallContents = null; // function call contents that need responding to in the current turn
863
/// instances with a <see cref="
FunctionCallContent
"/> tool call that the FICC needs to process.
870
c is ToolApprovalRequestContent { ToolCall:
FunctionCallContent
{ InformationalOnly: false } }
871
or ToolApprovalResponseContent { ToolCall:
FunctionCallContent
{ InformationalOnly: false } });
876
/// non-informational <see cref="
FunctionCallContent
"/>). When this returns <see langword="false"/>, the anchor
884
c is ToolApprovalRequestContent { ToolCall:
FunctionCallContent
{ InformationalOnly: false } }
885
or ToolApprovalResponseContent { ToolCall:
FunctionCallContent
{ InformationalOnly: false } });
887
/// <summary>Copies any <see cref="
FunctionCallContent
"/> from <paramref name="messages"/> to <paramref name="functionCalls"/>.</summary>
889
IList<ChatMessage> messages, [NotNullWhen(true)] ref List<
FunctionCallContent
>? functionCalls)
901
/// <summary>Copies any <see cref="
FunctionCallContent
"/> from <paramref name="content"/> to <paramref name="functionCalls"/>.</summary>
903
IList<AIContent> content, [NotNullWhen(true)] ref List<
FunctionCallContent
>? functionCalls)
909
if (content[i] is
FunctionCallContent
functionCall && !functionCall.InformationalOnly)
920
/// Marks any <see cref="
FunctionCallContent
"/> in <paramref name="messages"/> as <see cref="
FunctionCallContent
.InformationalOnly"/>
954
if (contents[j] is
FunctionCallContent
fcc && !fcc.InformationalOnly && resultCallIds.Contains(fcc.CallId))
963
/// Marks any <see cref="
FunctionCallContent
"/> in the streaming <paramref name="updates"/> as <see cref="
FunctionCallContent
.InformationalOnly"/>
968
private static void MarkServerHandledFunctionCalls(List<ChatResponseUpdate> updates, List<
FunctionCallContent
>? functionCallContents)
1091
private bool ShouldTerminateLoopBasedOnHandleableFunctions(List<
FunctionCallContent
>? functionCalls, ChatOptions? options)
1107
foreach (
var
fcc in functionCalls)
1118
foreach (
var
fcc in functionCalls)
1164
List<
FunctionCallContent
> functionCallContents, int iteration, int consecutiveErrorCount,
1330
/// 2. Recreate <see cref="
FunctionCallContent
"/> for any <see cref="ToolApprovalResponseContent"/> that haven't been executed yet.
1452
case ToolApprovalRequestContent tarc when tarc.ToolCall is
FunctionCallContent
{ InformationalOnly: false }:
1458
case ToolApprovalResponseContent tarc when tarc.ToolCall is
FunctionCallContent
{ InformationalOnly: false }:
1519
if (approvalResponse.ToolCall is not
FunctionCallContent
fcc || functionResultCallIds?.Contains(fcc.CallId) is true)
1572
/// Extracts the <see cref="
FunctionCallContent
"/> from the provided <see cref="ToolApprovalResponseContent"/> to recreate the original function call messages.
1573
/// The output messages tries to mimic the original messages that contained the <see cref="
FunctionCallContent
"/>, e.g. if the <see cref="
FunctionCallContent
"/>
1574
/// had been split into separate messages, this method will recreate similarly split messages, each with their own <see cref="
FunctionCallContent
"/>.
1645
/// Takes the <see cref="
FunctionCallContent
"/> from the <paramref name="resultWithRequestMessage"/> and wraps it in a <see cref="ChatMessage"/>
1646
/// using the same message id that the <see cref="
FunctionCallContent
"/> was originally returned with from the downstream <see cref="IChatClient"/>.
1662
List<
FunctionCallContent
>? functionCallContents,
1678
var
fcc = functionCallContents![lastApprovalCheckedFCCIndex];
1694
/// Replaces all <see cref="
FunctionCallContent
"/> with <see cref="ToolApprovalRequestContent"/> and ouputs a new list if any of them were replaced.
1696
/// <returns>true if any <see cref="
FunctionCallContent
"/> was replaced, false otherwise.</returns>
1708
if (content[i] is
FunctionCallContent
fcc && !fcc.InformationalOnly)
1734
/// Replaces all <see cref="
FunctionCallContent
"/> from <paramref name="messages"/> with <see cref="ToolApprovalRequestContent"/>
1753
if (content[j] is
FunctionCallContent
functionCall && !functionCall.InformationalOnly)
1788
var
functionCall = (
FunctionCallContent
)message.Contents[contentIndex];
1807
/// Execute the provided <see cref="ToolApprovalResponseContent"/> and return the resulting <see cref="
FunctionCallContent
"/>
1827
originalMessages, options, notInvokedApprovals.Select(x => x.Response.ToolCall).OfType<
FunctionCallContent
>().ToList(), 0, consecutiveErrorCount, isStreaming, cancellationToken, insertIndex);
1876
internal FunctionInvocationResult(bool terminate, FunctionInvocationStatus status,
FunctionCallContent
callContent, object? result, Exception? exception)
1889
public
FunctionCallContent
CallContent { get; }
1919
public
FunctionCallContent
ResponseFunctionCallContent => (
FunctionCallContent
)Response.ToolCall;
1920
public
FunctionCallContent
? RequestFunctionCallContent => Request?.ToolCall as
FunctionCallContent
;
ChatCompletion\ImageGeneratingChatClient.cs (1)
328
if (content is
FunctionCallContent
functionCall &&
ChatReduction\MessageCountingChatReducer.cs (1)
57
else if (!message.Contents.Any(m => m is
FunctionCallContent
or FunctionResultContent))
ChatReduction\SummarizingChatReducer.cs (1)
209
is
FunctionCallContent
Common\FunctionInvocationProcessor.cs (4)
63
List<
FunctionCallContent
> functionCallContents,
66
Func<
FunctionCallContent
, AIFunction, int, FunctionInvocationContext> createContext,
107
FunctionCallContent
callContent,
110
Func<
FunctionCallContent
, AIFunction, int, FunctionInvocationContext> createContext,
Common\OtelMessageSerializer.cs (1)
77
case
FunctionCallContent
fcc:
Realtime\FunctionInvokingRealtimeClient.cs (1)
21
/// When sessions created by this client receive a <see cref="
FunctionCallContent
"/> in a realtime server message from the inner
Realtime\FunctionInvokingRealtimeClientSession.cs (9)
29
/// When this session receives a <see cref="
FunctionCallContent
"/> in a realtime server message from its inner
37
/// <see cref="FunctionInvokingRealtimeClientSession"/> will not attempt to invoke it, and instead allow that <see cref="
FunctionCallContent
"/>
155
List<
FunctionCallContent
>? functionCallContents = null;
211
private static bool ExtractFunctionCalls(ResponseOutputItemRealtimeServerMessage message, List<
FunctionCallContent
> functionCallContents)
222
if (content is
FunctionCallContent
functionCallContent)
276
private bool ShouldTerminateBasedOnFunctionCalls(List<
FunctionCallContent
> functionCallContents)
283
foreach (
var
fcc in functionCallContents)
294
foreach (
var
fcc in functionCallContents)
320
List<
FunctionCallContent
> functionCallContents,
Realtime\OpenTelemetryRealtimeClientSession.cs (1)
539
case
FunctionCallContent
fcc:
Microsoft.Extensions.AI.Abstractions (6)
Contents\AIContent.cs (1)
13
[JsonDerivedType(typeof(
FunctionCallContent
), typeDiscriminator: "functionCall")]
Contents\FunctionCallContent.cs (4)
20
/// Initializes a new instance of the <see cref="
FunctionCallContent
"/> class.
65
/// Creates a new instance of <see cref="
FunctionCallContent
"/> parsing arguments using a specified encoding and parser.
72
/// <returns>A new instance of <see cref="
FunctionCallContent
"/> containing the parse result.</returns>
77
public static
FunctionCallContent
CreateFromParsedArguments<TEncoding>(
Contents\ToolCallContent.cs (1)
13
[JsonDerivedType(typeof(
FunctionCallContent
), "functionCall")]
Microsoft.Extensions.AI.Abstractions.Tests (57)
AssertExtensions.cs (5)
38
if (expectedItem is
FunctionCallContent
expectedFunctionCall)
40
var
chatFunctionCall = (
FunctionCallContent
)chatItem;
79
FunctionCallContent
fcc => (fcc.Name, fcc.Arguments),
86
FunctionCallContent
fcc => (fcc.Name, fcc.Arguments),
ChatCompletion\ChatMessageTests.cs (4)
326
var
functionCallContent = deserializedMessage.Contents[4] as
FunctionCallContent
;
387
var
funcCall = Assert.IsType<
FunctionCallContent
>(result.Contents[1]);
ChatCompletion\ChatResponseUpdateTests.cs (4)
150
Assert.IsType<
FunctionCallContent
>(result.Contents[2]);
151
Assert.Equal("fc1", ((
FunctionCallContent
)result.Contents[2]).Name);
214
Assert.IsType<
FunctionCallContent
>(result.Contents[2]);
215
Assert.Equal("fc1", ((
FunctionCallContent
)result.Contents[2]).Name);
Contents\FunctionCallContentTests.cs (29)
21
FunctionCallContent
c = new("callId1", "name");
39
FunctionCallContent
c = new("id", "name", args);
52
FunctionCallContent
c = new("callId1", "name");
87
var
sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" })
121
var
deserialized = JsonSerializer.Deserialize<
FunctionCallContent
>(json, TestJsonSerializerContext.Default.Options);
134
var
deserialized = JsonSerializer.Deserialize<
FunctionCallContent
>(json, TestJsonSerializerContext.Default.Options);
148
var
original = new FunctionCallContent("callId1", "functionName") { InformationalOnly = informationalOnly };
150
var
deserialized = JsonSerializer.Deserialize<
FunctionCallContent
>(json, TestJsonSerializerContext.Default.Options);
164
var
sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) { Exception = ex };
168
var
deserializedSut = JsonSerializer.Deserialize<
FunctionCallContent
>(json, TestJsonSerializerContext.Default.Options);
344
var
content =
FunctionCallContent
.CreateFromParsedArguments(
389
var
content =
FunctionCallContent
.CreateFromParsedArguments(exc, "callId", "functionName", ThrowingParser);
403
Assert.Throws<ArgumentNullException>("encodedArguments", () =>
FunctionCallContent
.CreateFromParsedArguments((string)null!, "callId", "functionName", _ => null));
404
Assert.Throws<ArgumentNullException>("callId", () =>
FunctionCallContent
.CreateFromParsedArguments("{}", null!, "functionName", _ => null));
405
Assert.Throws<ArgumentNullException>("name", () =>
FunctionCallContent
.CreateFromParsedArguments("{}", "callId", null!, _ => null));
406
Assert.Throws<ArgumentNullException>("argumentParser", () =>
FunctionCallContent
.CreateFromParsedArguments("{}", "callId", "functionName", null!));
412
var
content = new FunctionCallContent("call123", "myFunction")
417
AssertSerializationRoundtrips<
FunctionCallContent
>(content);
421
static void AssertSerializationRoundtrips<T>(
FunctionCallContent
content)
428
var
deserializedContent = Assert.IsType<
FunctionCallContent
>(deserialized);
458
var
funcCall = Assert.IsType<
FunctionCallContent
>(result);
Contents\InputRequestContentTests.cs (2)
89
var
funcCall = Assert.IsType<
FunctionCallContent
>(approvalRequest.ToolCall);
Contents\InputResponseContentTests.cs (2)
91
var
funcCall = Assert.IsType<
FunctionCallContent
>(approvalResponse.ToolCall);
Contents\ToolApprovalRequestContentTests.cs (3)
65
FunctionCallContent
functionCall = new("FCC1", "TestFunction");
127
var
funcCall = Assert.IsType<
FunctionCallContent
>(approvalRequest.ToolCall);
Contents\ToolApprovalResponseContentTests.cs (5)
95
var
functionCall = Assert.IsType<
FunctionCallContent
>(deserializedContent.ToolCall);
97
Assert.Equal(((
FunctionCallContent
)content.ToolCall).Name, functionCall.Name);
127
var
funcCall = Assert.IsType<
FunctionCallContent
>(approvalResponse.ToolCall);
Realtime\RealtimeConversationItemTests.cs (2)
57
var
functionCall = new FunctionCallContent("call_1", "myFunc");
64
Assert.IsType<
FunctionCallContent
>(item.Contents[0]);
TestJsonSerializerContext.cs (1)
48
[JsonSerializable(typeof(
FunctionCallContent
[]))]
Microsoft.Extensions.AI.Evaluation.Quality (13)
ChatResponseExtensions.cs (3)
31
if (content is
FunctionCallContent
or FunctionResultContent)
34
content is
FunctionCallContent
? typeof(
FunctionCallContent
) : typeof(FunctionResultContent);
IntentResolutionEvaluator.cs (2)
120
IEnumerable<
FunctionCallContent
> toolCalls =
121
modelResponse.Messages.SelectMany(m => m.Contents).OfType<
FunctionCallContent
>();
TaskAdherenceEvaluator.cs (2)
119
IEnumerable<
FunctionCallContent
> toolCalls =
120
modelResponse.Messages.SelectMany(m => m.Contents).OfType<
FunctionCallContent
>();
ToolCallAccuracyEvaluator.cs (4)
21
/// (i.e., <see cref="
FunctionCallContent
"/>s) present in the supplied response to assess the relevance of these tool
99
IEnumerable<
FunctionCallContent
> toolCalls =
100
modelResponse.Messages.SelectMany(m => m.Contents).OfType<
FunctionCallContent
>();
105
EvaluationDiagnostic.Error($"The {nameof(modelResponse)} supplied for evaluation did not contain any tool calls (i.e., {nameof(
FunctionCallContent
)}s)."));
ToolCallAccuracyEvaluatorContext.cs (2)
17
/// (i.e., <see cref="
FunctionCallContent
"/>s) present in the supplied response to assess the relevance of these tool
81
/// (i.e., <see cref="
FunctionCallContent
"/>s) present in the supplied response to assess the relevance of these
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (1)
ScenarioRunResultTests.cs (1)
219
var
functionCall = new FunctionCallContent(
Microsoft.Extensions.AI.Integration.Tests (1)
PromptBasedFunctionCallingChatClient.cs (1)
74
else if (message.Contents[itemIndex] is
FunctionCallContent
fcc)
Microsoft.Extensions.AI.OpenAI (17)
MicrosoftExtensionsAIChatExtensions.cs (3)
74
.OfType<
FunctionCallContent
>().Select(c => ChatToolCall.CreateFunctionToolCall(c.CallId, c.Name,
155
var toolCallUpdates = update.Contents.OfType<
FunctionCallContent
>().Select((fcc, index) =>
198
var
fcc = OpenAIClientExtensions.ParseCallContent(toolCall.FunctionArguments, toolCall.Id, toolCall.FunctionName);
OpenAIChatClient.cs (3)
217
case
FunctionCallContent
fc:
468
var
callContent = OpenAIClientExtensions.ParseCallContent(
543
var
callContent = OpenAIClientExtensions.ParseCallContent(toolCall.FunctionArguments, toolCall.Id, toolCall.FunctionName);
OpenAIClientExtensions.cs (8)
225
/// <summary>Creates a new instance of <see cref="
FunctionCallContent
"/> parsing arguments using a specified encoding and parser.</summary>
229
/// <returns>A new instance of <see cref="
FunctionCallContent
"/> containing the parse result.</returns>
233
internal static
FunctionCallContent
ParseCallContent(string json, string callId, string name) =>
234
FunctionCallContent
.CreateFromParsedArguments(json, callId, name,
238
/// <summary>Creates a new instance of <see cref="
FunctionCallContent
"/> parsing arguments using a specified encoding and parser.</summary>
242
/// <returns>A new instance of <see cref="
FunctionCallContent
"/> containing the parse result.</returns>
246
internal static
FunctionCallContent
ParseCallContent(BinaryData utf8json, string callId, string name) =>
247
FunctionCallContent
.CreateFromParsedArguments(utf8json, callId, name,
OpenAIRealtimeClientSession.cs (1)
646
if (firstContent is
FunctionCallContent
functionCall)
OpenAIResponsesChatClient.cs (2)
211
var
fcc = OpenAIClientExtensions.ParseCallContent(functionCall.FunctionArguments, functionCall.CallId, functionCall.FunctionName);
1581
case
FunctionCallContent
callContent:
Microsoft.Extensions.AI.OpenAI.Tests (31)
OpenAIChatClientTests.cs (4)
1168
FunctionCallContent
fcc = Assert.IsType<
FunctionCallContent
>(response.Messages.Single().Contents[0]);
1348
FunctionCallContent
fcc = Assert.IsType<
FunctionCallContent
>(Assert.Single(updates[updates.Count - 1].Contents));
OpenAIConversionTests.cs (11)
910
Assert.Equal("functionName", Assert.IsType<
FunctionCallContent
>(message.Contents[2], exactMatch: false).Name);
941
Assert.Equal("functionName", Assert.IsType<
FunctionCallContent
>(message.Contents[2], exactMatch: false).Name);
1019
FunctionCallContent
? fcc = updates[0].Contents.OfType<
FunctionCallContent
>().FirstOrDefault();
1233
var
functionCall = message.Contents.OfType<
FunctionCallContent
>().FirstOrDefault();
1318
FunctionCallContent
? functionCallContent = message.Contents.OfType<
FunctionCallContent
>().FirstOrDefault();
1774
var
functionCallContent = new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?>
1812
var
functionCall1 = new FunctionCallContent("call-1", "Function1", new Dictionary<string, object?> { ["param1"] = "value1" });
1813
var
functionCall2 = new FunctionCallContent("call-2", "Function2", new Dictionary<string, object?> { ["param2"] = "value2" });
OpenAIResponseClientTests.cs (11)
6214
var functionCallUpdate = updates.FirstOrDefault(u => u.Contents.OfType<
FunctionCallContent
>().Any());
6217
var
fcc = functionCallUpdate.Contents.OfType<
FunctionCallContent
>().Single();
6242
Assert.Single(message.Contents.OfType<
FunctionCallContent
>());
8992
var
call = Assert.IsType<
FunctionCallContent
>(Assert.Single(response.Messages[0].Contents));
9088
var functionCallUpdate = updates.FirstOrDefault(u => u.Contents.OfType<
FunctionCallContent
>().Any());
9090
var
call = functionCallUpdate.Contents.OfType<
FunctionCallContent
>().Single();
9099
var
coalesced = response.Messages[0].Contents.OfType<
FunctionCallContent
>().Single();
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (5)
38
if (expectedItem is
FunctionCallContent
expectedFunctionCall)
40
var
chatFunctionCall = (
FunctionCallContent
)chatItem;
79
FunctionCallContent
fcc => (fcc.Name, fcc.Arguments),
86
FunctionCallContent
fcc => (fcc.Name, fcc.Arguments),
Microsoft.Extensions.AI.Tests (58)
ChatCompletion\DistributedCachingChatClientTest.cs (8)
348
c => Assert.IsType<
FunctionCallContent
>(c),
356
c => Assert.IsType<
FunctionCallContent
>(Assert.Single(c.Contents)),
816
if (expectedItem is
FunctionCallContent
expectedFcc)
818
var
actualFcc = (
FunctionCallContent
)actualItem;
850
if (expectedItemItem is
FunctionCallContent
expectedFcc)
852
var
actualFcc = (
FunctionCallContent
)actualItemItem;
ChatCompletion\FunctionInvocationContextTests.cs (1)
55
FunctionCallContent
callContent = new(string.Empty, string.Empty, new Dictionary<string, object?>());
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (15)
875
var
requestFcc = new FunctionCallContent("callId1", "Func1");
876
var
responseFcc = new FunctionCallContent("callId1", "Func1");
945
var
request1Fcc = new FunctionCallContent("callId1", "Func1");
946
var
response1Fcc = new FunctionCallContent("callId1", "Func1") { InformationalOnly = true };
948
var
request2Fcc = new FunctionCallContent("callId2", "Func1");
1503
var
functionCall = update.Contents.OfType<
FunctionCallContent
>().First();
1599
Assert.Equal("Func1", ((
FunctionCallContent
)approvalRequest1.ToolCall).Name);
1607
Assert.Equal("Func2", ((
FunctionCallContent
)approvalRequest2.ToolCall).Name);
1615
Assert.Equal("Func3", ((
FunctionCallContent
)approvalRequest3.ToolCall).Name);
1644
var
alreadyProcessedFunctionCall = new FunctionCallContent("callId1", "Func1") { InformationalOnly = true };
2098
FunctionCallContent
fcc => new FunctionCallContent(fcc.CallId, fcc.Name, fcc.Arguments)
2145
.Where(t => t.ToolCall is
FunctionCallContent
{ InformationalOnly: true })
2153
foreach (
var
fcc in allContents
2156
.OfType<
FunctionCallContent
>()
ChatCompletion\FunctionInvokingChatClientTests.cs (21)
1001
Assert.Contains(content, c => c is
FunctionCallContent
or FunctionResultContent);
1217
c => Assert.Equal("Input 1", Assert.IsType<
FunctionCallContent
>(c).Arguments!["text"]),
1218
c => Assert.Equal("Input 2", Assert.IsType<
FunctionCallContent
>(c).Arguments!["text"])),
1258
Assert.IsType<
FunctionCallContent
>(Assert.Single(response.Messages[0].Contents));
1260
Assert.IsType<
FunctionCallContent
>(Assert.Single(response.Messages[2].Contents));
1643
if (!chatContents.Any(m => m.Contents.OfType<
FunctionCallContent
>().Any()))
2014
var functionCallMessage = chat.First(m => m.Contents.Any(c => c is
FunctionCallContent
));
2015
var
functionCallContent = functionCallMessage.Contents.OfType<
FunctionCallContent
>().First();
2033
var
alreadyProcessedFunctionCall = new FunctionCallContent("callId1", "Func1") { InformationalOnly = true };
2063
Assert.Contains(response.Messages, m => m.Contents.Any(c => c is
FunctionCallContent
fcc && fcc.InformationalOnly));
2085
var
needsProcessing = new FunctionCallContent("callId1", "Func1") { InformationalOnly = false };
2086
var
alreadyProcessed = new FunctionCallContent("callId2", "Func2") { InformationalOnly = true };
2180
Assert.Contains(response.Messages, m => m.Contents.Any(c => c is
FunctionCallContent
fcc && fcc.CallId == "callId1" && fcc.InformationalOnly));
2327
if (content is
FunctionCallContent
fcc)
3116
Assert.Contains(result.Messages, m => m.Contents.OfType<ToolApprovalRequestContent>().Any(frc => ((
FunctionCallContent
)frc.ToolCall).Name == "FunctionB"));
3126
Assert.Contains(result.Messages, m => m.Contents.OfType<ToolApprovalRequestContent>().Any(frc => ((
FunctionCallContent
)frc.ToolCall).Name == "FunctionB"));
3222
Assert.Contains(result.Messages, m => m.Contents.OfType<ToolApprovalRequestContent>().Any(frc => ((
FunctionCallContent
)frc.ToolCall).Name == "FunctionB"));
3233
Assert.Contains(result.Messages, m => m.Contents.OfType<ToolApprovalRequestContent>().Any(frc => ((
FunctionCallContent
)frc.ToolCall).Name == "FunctionB"));
3500
m.Contents.Any(c => c is
FunctionCallContent
fcc2 && fcc2.CallId == "callId1" && fcc2.InformationalOnly));
3578
m.Contents.Any(c => c is
FunctionCallContent
fcc2 && fcc2.CallId == "callId1" && fcc2.InformationalOnly));
ChatReduction\MessageCountingChatReducerTests.cs (2)
143
Assert.DoesNotContain(m.Contents, c => c is
FunctionCallContent
);
150
Assert.DoesNotContain(m.Contents, c => c is
FunctionCallContent
);
ChatReduction\SummarizingChatReducerTests.cs (5)
107
Assert.DoesNotContain(msgs, m => m.Contents.Any(c => c is
FunctionCallContent
or FunctionResultContent or TestInputRequestContent or TestInputResponseContent));
122
Assert.Contains(m.Contents, c => c is
FunctionCallContent
);
203
Assert.DoesNotContain(msgList, m => m.Contents.Any(c => c is
FunctionCallContent
or FunctionResultContent or TestInputRequestContent or TestInputResponseContent));
219
Assert.Contains(resultList, m => m.Contents.Any(c => c is
FunctionCallContent
fc && fc.CallId == "call2"));
221
Assert.DoesNotContain(resultList, m => m.Contents.Any(c => c is
FunctionCallContent
fc && fc.CallId == "call1"));
Realtime\FunctionInvokingRealtimeClientTests.cs (1)
641
var
functionCallContent = new FunctionCallContent(callId, functionName, arguments);
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (5)
38
if (expectedItem is
FunctionCallContent
expectedFunctionCall)
40
var
chatFunctionCall = (
FunctionCallContent
)chatItem;
79
FunctionCallContent
fcc => (fcc.Name, fcc.Arguments),
86
FunctionCallContent
fcc => (fcc.Name, fcc.Arguments),