310 instantiations of FunctionCallContent
Microsoft.Extensions.AI.Abstractions (1)
Contents\FunctionCallContent.cs (1)
105return new FunctionCallContent(callId, name, arguments)
Microsoft.Extensions.AI.Abstractions.Tests (26)
ChatCompletion\ChatMessageTests.cs (2)
148new FunctionCallContent("callId1", "fc1"), 271new FunctionCallContent("function-id", "plugin-name-function-name", new Dictionary<string, object?> { ["parameter"] = "argument" }),
ChatCompletion\ChatResponseUpdateTests.cs (2)
94new FunctionCallContent("callId1", "fc1"), 123new FunctionCallContent("callId1", "fc1"),
Contents\AIContentTests.cs (3)
68new FunctionCallContent("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } }), 73new FunctionApprovalRequestContent("request123", new FunctionCallContent("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } })), 74new FunctionApprovalResponseContent("request123", approved: true, new FunctionCallContent("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } })),
Contents\FunctionApprovalRequestContentTests.cs (5)
16FunctionCallContent functionCall = new("FCC1", "TestFunction"); 31FunctionCallContent functionCall = new("FCC1", "TestFunction"); 45FunctionCallContent functionCall = new("FCC1", "TestFunction"); 66FunctionCallContent functionCall = new("FCC1", "TestFunction"); 82var content = new FunctionApprovalRequestContent("request123", new FunctionCallContent("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } }));
Contents\FunctionApprovalResponseContentTests.cs (3)
15FunctionCallContent functionCall = new("FCC1", "TestFunction"); 30FunctionCallContent functionCall = new("FCC1", "TestFunction"); 43var content = new FunctionApprovalResponseContent("request123", true, new FunctionCallContent("call123", "functionName"))
Contents\FunctionCallContentTests.cs (6)
21FunctionCallContent c = new("callId1", "name"); 39FunctionCallContent c = new("id", "name", args); 52FunctionCallContent c = new("callId1", "name"); 87var sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) 148var original = new FunctionCallContent("callId1", "functionName") { InformationalOnly = informationalOnly }; 164var sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) { Exception = ex };
Contents\UserInputRequestContentTests.cs (2)
36UserInputRequestContent content = new FunctionApprovalRequestContent("request123", new FunctionCallContent("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } })); 44new FunctionApprovalRequestContent("request123", new FunctionCallContent("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } })),
Contents\UserInputResponseContentTests.cs (2)
34UserInputResponseContent content = new FunctionApprovalResponseContent("request123", true, new FunctionCallContent("call123", "functionName")); 42new FunctionApprovalResponseContent("request123", true, new FunctionCallContent("call123", "functionName")),
SpeechToText\SpeechToTextResponseUpdateTests.cs (1)
64new FunctionCallContent("callId1", "fc1"),
Microsoft.Extensions.AI.Integration.Tests (1)
PromptBasedFunctionCallingChatClient.cs (1)
118message.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)
1471new FunctionCallContent("12345", "SayHello"), 1472new FunctionCallContent("12346", "SayHi"),
OpenAIConversionTests.cs (10)
646new FunctionCallContent("callid123", "SomeFunction", new Dictionary<string, object?> 715new FunctionCallContent("callid123", "SomeFunction", new Dictionary<string, object?> 955new FunctionCallContent("call123", "TestFunction", new Dictionary<string, object?> { ["param"] = "value" }) 1060new FunctionCallContent("process_data", "ProcessComplexData", complexArgs) 1243var functionCallContent = new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?> 1281var functionCall1 = new FunctionCallContent("call-1", "Function1", new Dictionary<string, object?> { ["param1"] = "value1" }); 1282var functionCall2 = new FunctionCallContent("call-2", "Function2", new Dictionary<string, object?> { ["param2"] = "value2" }); 1315new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" }), 1557new FunctionCallContent("call-123", "TestFunction", new Dictionary<string, object?> { ["param"] = "value" }) 1592new FunctionCallContent("call-456", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" })
Microsoft.Extensions.AI.Tests (270)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
201new FunctionCallContent("callid123", "get_data"),
ChatCompletion\DistributedCachingChatClientTest.cs (4)
52Contents = [new FunctionCallContent("someCallId", "functionName", new Dictionary<string, object?> 255new FunctionCallContent("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" }), 266Contents = [new FunctionCallContent("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" })], 316new() { Role = ChatRole.Assistant, Contents = [new FunctionCallContent("callId1", "separator")] },
ChatCompletion\FunctionInvocationContextTests.cs (1)
55FunctionCallContent callContent = new(string.Empty, string.Empty, new Dictionary<string, object?>());
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (126)
41new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 48new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 49new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 77new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 84new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 85new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 121new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 128new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 129new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 155new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 156new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 160new FunctionApprovalResponseContent("callId1", true, new FunctionCallContent("callId1", "Func1")), 161new FunctionApprovalResponseContent("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 168new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 179new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 207new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 208new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 212new FunctionApprovalResponseContent("callId1", true, new FunctionCallContent("callId1", "Func1")), 213new FunctionApprovalResponseContent("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 221new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 232new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 259new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 263new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 267new FunctionApprovalResponseContent("callId1", true, new FunctionCallContent("callId1", "Func1")), 271new FunctionApprovalResponseContent("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 278new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]) { MessageId = "resp1" }, 279new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]) { MessageId = "resp2" }, 290new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]) { MessageId = "resp1" }, 291new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]) { MessageId = "resp2" }, 318new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 319new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 323new FunctionApprovalResponseContent("callId1", false, new FunctionCallContent("callId1", "Func1")), 324new FunctionApprovalResponseContent("callId2", false, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 331new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 346new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 377new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 378new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 382new FunctionApprovalResponseContent("callId1", false, new FunctionCallContent("callId1", "Func1")), 383new FunctionApprovalResponseContent("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 390new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 402new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 410new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 441new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 442new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 446new FunctionApprovalResponseContent("callId1", false, new FunctionCallContent("callId1", "Func1")) 450new FunctionApprovalResponseContent("callId2", false, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 460new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 475new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 507new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 508new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })), 509new FunctionApprovalRequestContent("callId3", new FunctionCallContent("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } })) 513new FunctionApprovalResponseContent("callId1", false, new FunctionCallContent("callId1", "Func1")) { Reason = "Custom rejection for Func1" }, 514new FunctionApprovalResponseContent("callId2", false, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })), 515new FunctionApprovalResponseContent("callId3", true, new FunctionCallContent("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } })) 524new FunctionCallContent("callId1", "Func1"), 525new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }), 526new FunctionCallContent("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } }) 545new FunctionCallContent("callId1", "Func1"), 546new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }), 547new FunctionCallContent("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } }) 562new FunctionCallContent("callId1", "Func1"), 563new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }), 564new FunctionCallContent("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } }) 599new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 603new FunctionApprovalResponseContent("callId1", false, new FunctionCallContent("callId1", "Func1")) 613new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 627new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 657new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 658new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 662new FunctionApprovalResponseContent("callId1", true, new FunctionCallContent("callId1", "Func1")), 663new FunctionApprovalResponseContent("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 670new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 676new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 3 } })]), 681new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 685new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 3 } })) 711new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 712new FunctionApprovalRequestContent("callId2", new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 716new FunctionApprovalResponseContent("callId1", true, new FunctionCallContent("callId1", "Func1")), 717new FunctionApprovalResponseContent("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 719new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 723new FunctionApprovalRequestContent("callId3", new FunctionCallContent("callId3", "Func1")), 727new FunctionApprovalResponseContent("callId3", true, new FunctionCallContent("callId3", "Func1")), 734new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 736new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1")]), 747new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1")]), 791new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 800new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 810new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 837new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")), 867new FunctionApprovalResponseContent("callId1", true, new FunctionCallContent("callId1", "Func1")), 868new FunctionApprovalResponseContent("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 875new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 886new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 913new FunctionApprovalResponseContent("callId1", true, new FunctionCallContent("callId1", "Func1")), 914new FunctionApprovalResponseContent("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })) 930new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 972yield return new ChatResponseUpdate(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]) { MessageId = messageId }; 978new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }) 1052yield return new ChatResponseUpdate(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]) { MessageId = messageId }; 1057new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }) 1061yield return new ChatResponseUpdate(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func3")]) { MessageId = messageId }; 1134var alreadyProcessedFunctionCall = new FunctionCallContent("callId1", "Func1") { InformationalOnly = true }; 1178new FunctionApprovalRequestContent("approval-request-id", new FunctionCallContent("function-call-id", "Func1")) 1182new FunctionApprovalResponseContent("approval-request-id", true, new FunctionCallContent("function-call-id", "Func1")) 1194new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("function-call-id", "Func1")]) { MessageId = OriginalMessageId },
ChatCompletion\FunctionInvokingChatClientTests.cs (126)
94new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 96new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 98new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 128new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 130new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 132new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 161new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 163new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 165new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 194new FunctionCallContent("callId1", "Func1"), 195new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 34 } }), 196new FunctionCallContent("callId3", "Func2", arguments: new Dictionary<string, object?> { { "i", 56 } }), 206new FunctionCallContent("callId4", "Func2", arguments: new Dictionary<string, object?> { { "i", 78 } }), 207new FunctionCallContent("callId5", "Func1") 254new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 255new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 298new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 299new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 330new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 332new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 334new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 380new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]))); 393new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])).ToChatResponseUpdates()); 461new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]))); 474new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])).ToChatResponseUpdates()); 542new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]))); 555new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])).ToChatResponseUpdates()); 637new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId0", "VoidReturn")]), 645plan.Add(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{(i + 1)}", "VoidReturn")])); 668var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{capturedOptions.Count}", "Func1")]); 712var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{capturedOptions.Count}", "Func1")]); 759var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]); 804var message = new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]); 960assistantMessage.Contents.Add(new FunctionCallContent(callId, "Func", 984new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 986new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 988new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 1021new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 1043new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 1100new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 1192new() { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] }, 1193new() { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] } 1245new(ChatRole.Assistant, [new FunctionCallContent($"callId{chatContents.Count()}", "Func1")]) : 1294new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["i"] = 41 })]), 1296new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["i"] = 42 })]), 1304new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1", new Dictionary<string, object?> { ["i"] = 43 })]), 1364new FunctionCallContent("callId1", "Search"), 1365new FunctionCallContent("callId2", "Search", new Dictionary<string, object?> { { "result", "birds" } }), 1366new FunctionCallContent("callId3", "Search"), 1412return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId-abc", "Func1")])) 1450new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 1480new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg"] = "value1" }), 1481new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["arg"] = "value2" }), 1533new FunctionCallContent("callId1", "UnknownFunc", new Dictionary<string, object?> { ["i"] = 1 }), 1534new FunctionCallContent("callId2", "KnownFunc", new Dictionary<string, object?> { ["i"] = 2 }) 1552new FunctionCallContent("callId1", "UnknownFunc", new Dictionary<string, object?> { ["i"] = 1 }), 1553new FunctionCallContent("callId2", "KnownFunc", new Dictionary<string, object?> { ["i"] = 2 }) 1580new(ChatRole.Assistant, [new FunctionCallContent("callId1", "DefOnly")]), 1610new FunctionCallContent("callId1", "Known"), 1611new FunctionCallContent("callId2", "DefOnly") 1645messages.Add(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])); 1679new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 1736? new(ChatRole.Assistant, [new FunctionCallContent("call1", "Func1")]) 1785new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 1825new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 1874new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "secret" })]), 1946new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 1995new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 2022var alreadyProcessedFunctionCall = new FunctionCallContent("callId1", "Func1") { InformationalOnly = true }; 2074var needsProcessing = new FunctionCallContent("callId1", "Func1") { InformationalOnly = false }; 2075var alreadyProcessed = new FunctionCallContent("callId2", "Func2") { InformationalOnly = true }; 2150return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])); 2318cloned.Add(new FunctionCallContent(fcc.CallId, fcc.Name, fcc.Arguments) 2378[new FunctionCallContent("callId1", "FunctionA")])]); 2385[new FunctionCallContent("callId2", "FunctionB")])]); 2401[new FunctionCallContent("callId1", "FunctionA")]); 2407[new FunctionCallContent("callId2", "FunctionB")]); 2472[new FunctionCallContent("callId1", "FunctionA")])]); 2479[new FunctionCallContent("callId2", "FunctionB")])]); 2495[new FunctionCallContent("callId1", "FunctionA")]); 2501[new FunctionCallContent("callId2", "FunctionB")]); 2579[new FunctionCallContent("callId1", "FunctionA")])]); 2585[new FunctionCallContent("callId2", "FunctionB")])]); 2600[new FunctionCallContent("callId1", "FunctionA")]); 2606[new FunctionCallContent("callId2", "FunctionB")]); 2677[new FunctionCallContent("callId1", "FunctionA")])]); 2685[new FunctionCallContent("callId2", "FunctionB"), 2686new FunctionCallContent("callId3", "AdditionalTool")])]); 2701[new FunctionCallContent("callId1", "FunctionA")]); 2707[new FunctionCallContent("callId2", "FunctionB"), 2708new FunctionCallContent("callId3", "AdditionalTool")]); 2781[new FunctionCallContent("callId1", "FunctionA")])]); 2787[new FunctionCallContent("callId2", "SharedName")])]); 2802[new FunctionCallContent("callId1", "FunctionA")]); 2808[new FunctionCallContent("callId2", "SharedName")]); 2879[new FunctionCallContent($"callId{callCount}", "FunctionA")])]); 2894[new FunctionCallContent($"callId{callCount}", "FunctionA")]); 2957[new FunctionCallContent("callId1", "FunctionA")])]); 2965[new FunctionCallContent("callId2", "FunctionB")])]); 2980[new FunctionCallContent("callId1", "FunctionA")]); 2986[new FunctionCallContent("callId2", "FunctionB")]); 3058[new FunctionCallContent("callId1", "FunctionA")])]); 3066[new FunctionCallContent("callId2", "FunctionB")])]); 3081[new FunctionCallContent("callId1", "FunctionA")]); 3087[new FunctionCallContent("callId2", "FunctionB")]); 3164[new FunctionCallContent("callId1", "FunctionA")])]); 3172[new FunctionCallContent("callId2", "FunctionB")])]); 3187[new FunctionCallContent("callId1", "FunctionA")]); 3193[new FunctionCallContent("callId2", "FunctionB")]); 3247new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "UnknownFunc")]), 3277new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 3313new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "TerminatingFunc")]), 3342new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 3351new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")) 3387new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")) 3391new FunctionApprovalResponseContent("callId1", true, new FunctionCallContent("callId1", "Func1")) 3424new FunctionApprovalRequestContent("callId1", new FunctionCallContent("callId1", "Func1")) 3428new FunctionApprovalResponseContent("callId1", false, new FunctionCallContent("callId1", "Func1")) { Reason = "User denied" } 3463new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 3471new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 3527new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2")]), 3542new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1"), new FunctionCallContent("callId2", "Func2")]), 3596return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")])); 3607var response = new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]));
ChatCompletion\ImageGeneratingChatClientTests.cs (2)
317[new FunctionCallContent(callId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" })]); 360[new FunctionCallContent(callId, "GenerateImage", new Dictionary<string, object?> { ["prompt"] = "a cat" })]);
ChatCompletion\OpenTelemetryChatClientTests.cs (4)
112new(ChatRole.Assistant, [new FunctionCallContent("12345", "GetPersonName")]), 408new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" }), 424yield return new() { Contents = [new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" })] }; 450new(ChatRole.Assistant, [new FunctionCallContent("call-456", "SearchFiles")]),
ChatReduction\MessageCountingChatReducerTests.cs (3)
128new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call1", "get_weather", new Dictionary<string, object?> { ["location"] = "Seattle" })]), 223new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call1", "func", null)]), 225new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call2", "func", null)]),
ChatReduction\SummarizingChatReducerTests.cs (3)
99new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call1", "get_weather"), new TestUserInputRequestContent("uir1")]), 188new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call1", "get_weather", new Dictionary<string, object?> { ["location"] = "Seattle" }), new TestUserInputRequestContent("uir2")]), 193new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("call2", "get_weather", new Dictionary<string, object?> { ["location"] = "New York" })]),
185 references to FunctionCallContent
Microsoft.Extensions.AI (51)
ChatCompletion\FunctionInvocationContext.cs (1)
40public FunctionCallContent CallContent
ChatCompletion\FunctionInvokingChatClient.cs (46)
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="FunctionApprovalRequestContent"/> 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, 286List<FunctionCallContent>? functionCallContents = null; // function call contents that need responding to in the current turn 436List<FunctionCallContent>? functionCallContents = null; // function call contents that need responding to in the current turn 847/// <summary>Copies any <see cref="FunctionCallContent"/> from <paramref name="messages"/> to <paramref name="functionCalls"/>.</summary> 849IList<ChatMessage> messages, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls) 861/// <summary>Copies any <see cref="FunctionCallContent"/> from <paramref name="content"/> to <paramref name="functionCalls"/>.</summary> 863IList<AIContent> content, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls) 869if (content[i] is FunctionCallContent functionCall && !functionCall.InformationalOnly) 880/// Marks any <see cref="FunctionCallContent"/> in <paramref name="messages"/> as <see cref="FunctionCallContent.InformationalOnly"/> 881/// if there is a matching <see cref="FunctionResultContent"/> with the same <see cref="FunctionCallContent.CallId"/> in the same set of messages, 914if (contents[j] is FunctionCallContent fcc && !fcc.InformationalOnly && resultCallIds.Contains(fcc.CallId)) 923/// Marks any <see cref="FunctionCallContent"/> in the streaming <paramref name="updates"/> as <see cref="FunctionCallContent.InformationalOnly"/> 924/// if there is a matching <see cref="FunctionResultContent"/> with the same <see cref="FunctionCallContent.CallId"/>, regardless of order. 928private static void MarkServerHandledFunctionCalls(List<ChatResponseUpdate> updates, List<FunctionCallContent>? functionCallContents) 1051private bool ShouldTerminateLoopBasedOnHandleableFunctions(List<FunctionCallContent>? functionCalls, ChatOptions? options) 1067foreach (var fcc in functionCalls) 1078foreach (var fcc in functionCalls) 1120List<FunctionCallContent> functionCallContents, int iteration, int consecutiveErrorCount, 1249List<FunctionCallContent> callContents, 1252var callContent = callContents[functionCallIndex]; 1511/// 2. Recreate <see cref="FunctionCallContent"/> for any <see cref="FunctionApprovalResponseContent"/> that haven't been executed yet. 1704/// Extracts the <see cref="FunctionCallContent"/> from the provided <see cref="FunctionApprovalResponseContent"/> to recreate the original function call messages. 1705/// The output messages tries to mimic the original messages that contained the <see cref="FunctionCallContent"/>, e.g. if the <see cref="FunctionCallContent"/> 1706/// had been split into separate messages, this method will recreate similarly split messages, each with their own <see cref="FunctionCallContent"/>. 1777/// Takes the <see cref="FunctionCallContent"/> from the <paramref name="resultWithRequestMessage"/> and wraps it in a <see cref="ChatMessage"/> 1778/// using the same message id that the <see cref="FunctionCallContent"/> was originally returned with from the downstream <see cref="IChatClient"/>. 1794List<FunctionCallContent>? functionCallContents, 1810var fcc = functionCallContents![lastApprovalCheckedFCCIndex]; 1826/// Replaces all <see cref="FunctionCallContent"/> with <see cref="FunctionApprovalRequestContent"/> and ouputs a new list if any of them were replaced. 1828/// <returns>true if any <see cref="FunctionCallContent"/> was replaced, false otherwise.</returns> 1837if (content[i] is FunctionCallContent fcc && !fcc.InformationalOnly) 1849/// Replaces all <see cref="FunctionCallContent"/> from <paramref name="messages"/> with <see cref="FunctionApprovalRequestContent"/> 1868if (content[j] is FunctionCallContent functionCall && !functionCall.InformationalOnly) 1893var functionCall = (FunctionCallContent)message.Contents[contentIndex]; 1913/// Execute the provided <see cref="FunctionApprovalResponseContent"/> and return the resulting <see cref="FunctionCallContent"/> 1991internal FunctionInvocationResult(bool terminate, FunctionInvocationStatus status, FunctionCallContent callContent, object? result, Exception? exception) 2004public FunctionCallContent CallContent { get; }
ChatCompletion\ImageGeneratingChatClient.cs (1)
328if (content is FunctionCallContent functionCall &&
ChatCompletion\OpenTelemetryChatClient.cs (1)
315case FunctionCallContent fcc:
ChatReduction\MessageCountingChatReducer.cs (1)
57else if (!message.Contents.Any(m => m is FunctionCallContent or FunctionResultContent))
ChatReduction\SummarizingChatReducer.cs (1)
209is FunctionCallContent
Microsoft.Extensions.AI.Abstractions (11)
Contents\AIContent.cs (1)
13[JsonDerivedType(typeof(FunctionCallContent), typeDiscriminator: "functionCall")]
Contents\FunctionApprovalRequestContent.cs (2)
25public FunctionApprovalRequestContent(string id, FunctionCallContent functionCall) 34public FunctionCallContent FunctionCall { get; }
Contents\FunctionApprovalResponseContent.cs (2)
26public FunctionApprovalResponseContent(string id, bool approved, FunctionCallContent functionCall) 41public FunctionCallContent FunctionCall { get; }
Contents\FunctionCallContent.cs (4)
20/// Initializes a new instance of the <see cref="FunctionCallContent"/> class. 70/// Creates a new instance of <see cref="FunctionCallContent"/> parsing arguments using a specified encoding and parser. 77/// <returns>A new instance of <see cref="FunctionCallContent"/> containing the parse result.</returns> 82public static FunctionCallContent CreateFromParsedArguments<TEncoding>(
Contents\FunctionResultContent.cs (2)
38/// If this is the result for a <see cref="FunctionCallContent"/>, this property should contain the same 39/// <see cref="FunctionCallContent.CallId"/> value.
Microsoft.Extensions.AI.Abstractions.Tests (35)
AssertExtensions.cs (3)
38if (expectedItem is FunctionCallContent expectedFunctionCall) 40var chatFunctionCall = (FunctionCallContent)chatItem;
ChatCompletion\ChatMessageTests.cs (2)
326var functionCallContent = deserializedMessage.Contents[4] as FunctionCallContent;
ChatCompletion\ChatResponseUpdateTests.cs (2)
148Assert.IsType<FunctionCallContent>(result.Contents[2]); 149Assert.Equal("fc1", ((FunctionCallContent)result.Contents[2]).Name);
Contents\FunctionApprovalRequestContentTests.cs (4)
16FunctionCallContent functionCall = new("FCC1", "TestFunction"); 31FunctionCallContent functionCall = new("FCC1", "TestFunction"); 45FunctionCallContent functionCall = new("FCC1", "TestFunction"); 66FunctionCallContent functionCall = new("FCC1", "TestFunction");
Contents\FunctionApprovalResponseContentTests.cs (2)
15FunctionCallContent functionCall = new("FCC1", "TestFunction"); 30FunctionCallContent functionCall = new("FCC1", "TestFunction");
Contents\FunctionCallContentTests.cs (22)
21FunctionCallContent c = new("callId1", "name"); 39FunctionCallContent c = new("id", "name", args); 52FunctionCallContent c = new("callId1", "name"); 87var sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) 121var deserialized = JsonSerializer.Deserialize<FunctionCallContent>(json, TestJsonSerializerContext.Default.Options); 134var deserialized = JsonSerializer.Deserialize<FunctionCallContent>(json, TestJsonSerializerContext.Default.Options); 148var original = new FunctionCallContent("callId1", "functionName") { InformationalOnly = informationalOnly }; 150var deserialized = JsonSerializer.Deserialize<FunctionCallContent>(json, TestJsonSerializerContext.Default.Options); 164var sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) { Exception = ex }; 168var deserializedSut = JsonSerializer.Deserialize<FunctionCallContent>(json, TestJsonSerializerContext.Default.Options); 344var content = FunctionCallContent.CreateFromParsedArguments( 389var content = FunctionCallContent.CreateFromParsedArguments(exc, "callId", "functionName", ThrowingParser); 403Assert.Throws<ArgumentNullException>("encodedArguments", () => FunctionCallContent.CreateFromParsedArguments((string)null!, "callId", "functionName", _ => null)); 404Assert.Throws<ArgumentNullException>("callId", () => FunctionCallContent.CreateFromParsedArguments("{}", null!, "functionName", _ => null)); 405Assert.Throws<ArgumentNullException>("name", () => FunctionCallContent.CreateFromParsedArguments("{}", "callId", null!, _ => null)); 406Assert.Throws<ArgumentNullException>("argumentParser", () => FunctionCallContent.CreateFromParsedArguments("{}", "callId", "functionName", null!));
Microsoft.Extensions.AI.Evaluation.Quality (13)
ChatResponseExtensions.cs (3)
31if (content is FunctionCallContent or FunctionResultContent) 34content is FunctionCallContent ? typeof(FunctionCallContent) : typeof(FunctionResultContent);
IntentResolutionEvaluator.cs (2)
120IEnumerable<FunctionCallContent> toolCalls = 121modelResponse.Messages.SelectMany(m => m.Contents).OfType<FunctionCallContent>();
TaskAdherenceEvaluator.cs (2)
119IEnumerable<FunctionCallContent> toolCalls = 120modelResponse.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 99IEnumerable<FunctionCallContent> toolCalls = 100modelResponse.Messages.SelectMany(m => m.Contents).OfType<FunctionCallContent>(); 105EvaluationDiagnostic.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.Integration.Tests (1)
PromptBasedFunctionCallingChatClient.cs (1)
74else 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, 155var toolCallUpdates = update.Contents.OfType<FunctionCallContent>().Select((fcc, index) => 198var fcc = OpenAIClientExtensions.ParseCallContent(toolCall.FunctionArguments, toolCall.Id, toolCall.FunctionName);
OpenAIAssistantsChatClient.cs (1)
191var fcc = OpenAIClientExtensions.ParseCallContent(
OpenAIChatClient.cs (3)
212case FunctionCallContent fc: 453var callContent = OpenAIClientExtensions.ParseCallContent( 528var callContent = OpenAIClientExtensions.ParseCallContent(toolCall.FunctionArguments, toolCall.Id, toolCall.FunctionName);
OpenAIClientExtensions.cs (8)
207/// <summary>Creates a new instance of <see cref="FunctionCallContent"/> parsing arguments using a specified encoding and parser.</summary> 211/// <returns>A new instance of <see cref="FunctionCallContent"/> containing the parse result.</returns> 215internal static FunctionCallContent ParseCallContent(string json, string callId, string name) => 216FunctionCallContent.CreateFromParsedArguments(json, callId, name, 220/// <summary>Creates a new instance of <see cref="FunctionCallContent"/> parsing arguments using a specified encoding and parser.</summary> 224/// <returns>A new instance of <see cref="FunctionCallContent"/> containing the parse result.</returns> 228internal static FunctionCallContent ParseCallContent(BinaryData utf8json, string callId, string name) => 229FunctionCallContent.CreateFromParsedArguments(utf8json, callId, name,
OpenAIResponsesChatClient.cs (2)
201var fcc = OpenAIClientExtensions.ParseCallContent(functionCall.FunctionArguments, functionCall.CallId, functionCall.FunctionName); 1159case FunctionCallContent callContent:
Microsoft.Extensions.AI.OpenAI.Tests (18)
OpenAIChatClientTests.cs (4)
1168FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Messages.Single().Contents[0]); 1347FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
OpenAIConversionTests.cs (7)
825Assert.Equal("functionName", Assert.IsType<FunctionCallContent>(message.Contents[2], exactMatch: false).Name); 856Assert.Equal("functionName", Assert.IsType<FunctionCallContent>(message.Contents[2], exactMatch: false).Name); 968var functionCall = message.Contents.OfType<FunctionCallContent>().FirstOrDefault(); 1243var functionCallContent = new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?> 1281var functionCall1 = new FunctionCallContent("call-1", "Function1", new Dictionary<string, object?> { ["param1"] = "value1" }); 1282var functionCall2 = new FunctionCallContent("call-2", "Function2", new Dictionary<string, object?> { ["param2"] = "value2" });
OpenAIResponseClientTests.cs (4)
5428var functionCallUpdate = updates.FirstOrDefault(u => u.Contents.OfType<FunctionCallContent>().Any()); 5431var fcc = functionCallUpdate.Contents.OfType<FunctionCallContent>().Single(); 5456Assert.Single(message.Contents.OfType<FunctionCallContent>());
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (3)
38if (expectedItem is FunctionCallContent expectedFunctionCall) 40var chatFunctionCall = (FunctionCallContent)chatItem;
Microsoft.Extensions.AI.Tests (39)
ChatCompletion\DistributedCachingChatClientTest.cs (8)
348c => Assert.IsType<FunctionCallContent>(c), 356c => Assert.IsType<FunctionCallContent>(Assert.Single(c.Contents)), 816if (expectedItem is FunctionCallContent expectedFcc) 818var actualFcc = (FunctionCallContent)actualItem; 850if (expectedItemItem is FunctionCallContent expectedFcc) 852var actualFcc = (FunctionCallContent)actualItemItem;
ChatCompletion\FunctionInvocationContextTests.cs (1)
55FunctionCallContent callContent = new(string.Empty, string.Empty, new Dictionary<string, object?>());
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (3)
993var functionCall = update.Contents.OfType<FunctionCallContent>().First(); 1134var alreadyProcessedFunctionCall = new FunctionCallContent("callId1", "Func1") { InformationalOnly = true };
ChatCompletion\FunctionInvokingChatClientTests.cs (17)
1001Assert.Contains(content, c => c is FunctionCallContent or FunctionResultContent); 1217c => Assert.Equal("Input 1", Assert.IsType<FunctionCallContent>(c).Arguments!["text"]), 1218c => Assert.Equal("Input 2", Assert.IsType<FunctionCallContent>(c).Arguments!["text"])), 1258Assert.IsType<FunctionCallContent>(Assert.Single(response.Messages[0].Contents)); 1260Assert.IsType<FunctionCallContent>(Assert.Single(response.Messages[2].Contents)); 1643if (!chatContents.Any(m => m.Contents.OfType<FunctionCallContent>().Any())) 2003var functionCallMessage = chat.First(m => m.Contents.Any(c => c is FunctionCallContent)); 2004var functionCallContent = functionCallMessage.Contents.OfType<FunctionCallContent>().First(); 2022var alreadyProcessedFunctionCall = new FunctionCallContent("callId1", "Func1") { InformationalOnly = true }; 2052Assert.Contains(response.Messages, m => m.Contents.Any(c => c is FunctionCallContent fcc && fcc.InformationalOnly)); 2074var needsProcessing = new FunctionCallContent("callId1", "Func1") { InformationalOnly = false }; 2075var alreadyProcessed = new FunctionCallContent("callId2", "Func2") { InformationalOnly = true }; 2169Assert.Contains(response.Messages, m => m.Contents.Any(c => c is FunctionCallContent fcc && fcc.CallId == "callId1" && fcc.InformationalOnly)); 2316if (content is FunctionCallContent fcc) 3489m.Contents.Any(c => c is FunctionCallContent fcc2 && fcc2.CallId == "callId1" && fcc2.InformationalOnly)); 3567m.Contents.Any(c => c is FunctionCallContent fcc2 && fcc2.CallId == "callId1" && fcc2.InformationalOnly));
ChatReduction\MessageCountingChatReducerTests.cs (2)
143Assert.DoesNotContain(m.Contents, c => c is FunctionCallContent); 150Assert.DoesNotContain(m.Contents, c => c is FunctionCallContent);
ChatReduction\SummarizingChatReducerTests.cs (5)
107Assert.DoesNotContain(msgs, m => m.Contents.Any(c => c is FunctionCallContent or FunctionResultContent or TestUserInputRequestContent or TestUserInputResponseContent)); 122Assert.Contains(m.Contents, c => c is FunctionCallContent); 203Assert.DoesNotContain(msgList, m => m.Contents.Any(c => c is FunctionCallContent or FunctionResultContent or TestUserInputRequestContent or TestUserInputResponseContent)); 219Assert.Contains(resultList, m => m.Contents.Any(c => c is FunctionCallContent fc && fc.CallId == "call2")); 221Assert.DoesNotContain(resultList, m => m.Contents.Any(c => c is FunctionCallContent fc && fc.CallId == "call1"));
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (3)
38if (expectedItem is FunctionCallContent expectedFunctionCall) 40var chatFunctionCall = (FunctionCallContent)chatItem;