60 instantiations of FunctionCallContent
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvocationContext.cs (1)
54get => _callContent ??= new(string.Empty, _nopFunction.Name, EmptyReadOnlyDictionary<string, object?>.Instance);
Microsoft.Extensions.AI.Abstractions (1)
Contents\FunctionCallContent.cs (1)
97return new FunctionCallContent(callId, name, arguments)
Microsoft.Extensions.AI.Abstractions.Tests (9)
ChatCompletion\ChatMessageTests.cs (2)
146new FunctionCallContent("callId1", "fc1"), 255new 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\FunctionCallContentTests..cs (4)
21FunctionCallContent c = new("callId1", "name"); 38FunctionCallContent c = new("id", "name", args); 51FunctionCallContent c = new("callId1", "name"); 81var sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) { Exception = ex };
SpeechToText\SpeechToTextResponseUpdateTests.cs (1)
65new FunctionCallContent("callId1", "fc1"),
Microsoft.Extensions.AI.AzureAIInference.Tests (1)
AzureAIInferenceChatClientTests.cs (1)
990new(ChatRole.Assistant, [new FunctionCallContent("abcd123", "GetMood")]),
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 (4)
OpenAIChatClientTests.cs (2)
1454new FunctionCallContent("12345", "SayHello"), 1455new FunctionCallContent("12346", "SayHi"),
OpenAIConversionTests.cs (2)
92new FunctionCallContent("callid123", "SomeFunction", new Dictionary<string, object?> 144new FunctionCallContent("callid123", "SomeFunction", new Dictionary<string, object?>
Microsoft.Extensions.AI.Tests (43)
ChatCompletion\DistributedCachingChatClientTest.cs (4)
51Contents = [new FunctionCallContent("someCallId", "functionName", new Dictionary<string, object?> 254new FunctionCallContent("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" }), 265Contents = [new FunctionCallContent("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" })], 315new() { Role = ChatRole.Assistant, Contents = [new FunctionCallContent("callId1", "separator")] },
ChatCompletion\FunctionInvocationContextTests.cs (1)
55FunctionCallContent callContent = new(string.Empty, string.Empty, new Dictionary<string, object?>());
ChatCompletion\FunctionInvokingChatClientTests.cs (37)
88new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 90new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 92new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 121new FunctionCallContent("callId1", "Func1"), 122new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 34 } }), 123new FunctionCallContent("callId3", "Func2", arguments: new Dictionary<string, object?> { { "i", 56 } }), 133new FunctionCallContent("callId4", "Func2", arguments: new Dictionary<string, object?> { { "i", 78 } }), 134new FunctionCallContent("callId5", "Func1") 181new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 182new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 225new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 226new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 257new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 259new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 261new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 306new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId0", "VoidReturn")]), 314plan.Add(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{(i + 1)}", "VoidReturn")])); 456assistantMessage.Contents.Add(new FunctionCallContent(callId, "Func", 480new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 482new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 484new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 517new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 539new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 595new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 670new() { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] }, 671new() { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] } 723new(ChatRole.Assistant, [new FunctionCallContent($"callId{chatContents.Count()}", "Func1")]) : 772new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["i"] = 41 })]), 774new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["i"] = 42 })]), 782new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1", new Dictionary<string, object?> { ["i"] = 43 })]), 842new FunctionCallContent("callId1", "Search"), 843new FunctionCallContent("callId2", "Search", new Dictionary<string, object?> { { "result", "birds" } }), 844new FunctionCallContent("callId3", "Search"), 890return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId-abc", "Func1")])) 928new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 958new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg"] = "value1" }), 959new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["arg"] = "value2" }),
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
112new(ChatRole.Assistant, [new FunctionCallContent("12345", "GetPersonName")]),
101 references to FunctionCallContent
Microsoft.Extensions.AI (16)
ChatCompletion\FunctionInvocationContext.cs (2)
27private FunctionCallContent? _callContent; 52public FunctionCallContent CallContent
ChatCompletion\FunctionInvokingChatClient.cs (13)
30/// When this client receives a <see cref="FunctionCallContent"/> in a chat response, it responds 236List<FunctionCallContent>? functionCallContents = null; // function call contents that need responding to in the current turn 329List<FunctionCallContent>? functionCallContents = null; // function call contents that need responding to in the current turn 506/// <summary>Copies any <see cref="FunctionCallContent"/> from <paramref name="messages"/> to <paramref name="functionCalls"/>.</summary> 508IList<ChatMessage> messages, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls) 520/// <summary>Copies any <see cref="FunctionCallContent"/> from <paramref name="content"/> to <paramref name="functionCalls"/>.</summary> 522IList<AIContent> content, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls) 528if (content[i] is FunctionCallContent functionCall) 569List<ChatMessage> messages, ChatOptions options, List<FunctionCallContent> functionCallContents, int iteration, int consecutiveErrorCount, 698List<ChatMessage> messages, ChatOptions options, List<FunctionCallContent> callContents, 701var callContent = callContents[functionCallIndex]; 925internal FunctionInvocationResult(bool terminate, FunctionInvocationStatus status, FunctionCallContent callContent, object? result, Exception? exception) 938public FunctionCallContent CallContent { get; }
ChatCompletion\OpenTelemetryChatClient.cs (1)
527var toolCalls = contents.OfType<FunctionCallContent>().Select(fc => new ToolCall
Microsoft.Extensions.AI.Abstractions (7)
Contents\AIContent.cs (1)
12[JsonDerivedType(typeof(FunctionCallContent), typeDiscriminator: "functionCall")]
Contents\FunctionCallContent.cs (4)
20/// Initializes a new instance of the <see cref="FunctionCallContent"/> class. 60/// Creates a new instance of <see cref="FunctionCallContent"/> parsing arguments using a specified encoding and parser. 67/// <returns>A new instance of <see cref="FunctionCallContent"/> containing the parse result.</returns> 72public 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 (18)
ChatCompletion\ChatMessageTests.cs (2)
310var 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\FunctionCallContentTests..cs (14)
21FunctionCallContent c = new("callId1", "name"); 38FunctionCallContent c = new("id", "name", args); 51FunctionCallContent c = new("callId1", "name"); 81var sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) { Exception = ex }; 85var deserializedSut = JsonSerializer.Deserialize<FunctionCallContent>(json, TestJsonSerializerContext.Default.Options); 261var content = FunctionCallContent.CreateFromParsedArguments( 306var content = FunctionCallContent.CreateFromParsedArguments(exc, "callId", "functionName", ThrowingParser); 320Assert.Throws<ArgumentNullException>("encodedArguments", () => FunctionCallContent.CreateFromParsedArguments((string)null!, "callId", "functionName", _ => null)); 321Assert.Throws<ArgumentNullException>("callId", () => FunctionCallContent.CreateFromParsedArguments("{}", null!, "functionName", _ => null)); 322Assert.Throws<ArgumentNullException>("name", () => FunctionCallContent.CreateFromParsedArguments("{}", "callId", null!, _ => null)); 323Assert.Throws<ArgumentNullException>("argumentParser", () => FunctionCallContent.CreateFromParsedArguments("{}", "callId", "functionName", null!));
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (5)
108FunctionCallContent callContent = ParseCallContentFromJsonString(ftc.Arguments, toolCall.Id, ftc.Name); 242FunctionCallContent callContent = ParseCallContentFromJsonString( 493if (content is FunctionCallContent { CallId: not null } callRequest) 557private static FunctionCallContent ParseCallContentFromJsonString(string json, string callId, string name) => 558FunctionCallContent.CreateFromParsedArguments(json, callId, name,
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
AzureAIInferenceChatClientTests.cs (4)
1267FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Messages.Single().Contents[0]); 1358FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
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)
119IEnumerable<FunctionCallContent> toolCalls = 120modelResponse.Messages.SelectMany(m => m.Contents).OfType<FunctionCallContent>();
TaskAdherenceEvaluator.cs (2)
118IEnumerable<FunctionCallContent> toolCalls = 119modelResponse.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 98IEnumerable<FunctionCallContent> toolCalls = 99modelResponse.Messages.SelectMany(m => m.Contents).OfType<FunctionCallContent>(); 104EvaluationDiagnostic.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 (12)
OpenAIChatClient.cs (7)
177case FunctionCallContent fc: 404var callContent = ParseCallContentFromJsonString( 469var callContent = ParseCallContentFromBinaryData(toolCall.FunctionArguments, toolCall.Id, toolCall.FunctionName); 674private static FunctionCallContent ParseCallContentFromJsonString(string json, string callId, string name) => 675FunctionCallContent.CreateFromParsedArguments(json, callId, name, 678private static FunctionCallContent ParseCallContentFromBinaryData(BinaryData ut8Json, string callId, string name) => 679FunctionCallContent.CreateFromParsedArguments(ut8Json, callId, name,
OpenAIResponsesChatClient.cs (5)
141var fcc = FunctionCallContent.CreateFromParsedArguments( 264var fci = FunctionCallContent.CreateFromParsedArguments( 547case FunctionCallContent callContent:
Microsoft.Extensions.AI.OpenAI.Tests (5)
OpenAIChatClientTests.cs (4)
1151FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Messages.Single().Contents[0]); 1330FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
OpenAIConversionTests.cs (1)
217Assert.Equal("functionName", Assert.IsType<FunctionCallContent>(message.Contents[2]).Name);
Microsoft.Extensions.AI.Tests (20)
ChatCompletion\DistributedCachingChatClientTest.cs (8)
347c => Assert.IsType<FunctionCallContent>(c), 355c => Assert.IsType<FunctionCallContent>(Assert.Single(c.Contents)), 818if (expectedItem is FunctionCallContent expectedFcc) 820var actualFcc = (FunctionCallContent)actualItem; 852if (expectedItemItem is FunctionCallContent expectedFcc) 854var actualFcc = (FunctionCallContent)actualItemItem;
ChatCompletion\FunctionInvocationContextTests.cs (1)
55FunctionCallContent callContent = new(string.Empty, string.Empty, new Dictionary<string, object?>());
ChatCompletion\FunctionInvokingChatClientTests.cs (11)
497Assert.Contains(content, c => c is FunctionCallContent or FunctionResultContent); 695c => Assert.Equal("Input 1", Assert.IsType<FunctionCallContent>(c).Arguments!["text"]), 696c => Assert.Equal("Input 2", Assert.IsType<FunctionCallContent>(c).Arguments!["text"])), 736Assert.IsType<FunctionCallContent>(Assert.Single(response.Messages[0].Contents)); 738Assert.IsType<FunctionCallContent>(Assert.Single(response.Messages[2].Contents)); 1064if (expectedItem is FunctionCallContent expectedFunctionCall) 1066var chatFunctionCall = (FunctionCallContent)chatItem; 1158if (expectedItem is FunctionCallContent expectedFunctionCall) 1160var chatFunctionCall = (FunctionCallContent)chatItem;