56 instantiations of FunctionCallContent
Microsoft.Extensions.AI.Abstractions (1)
Contents\FunctionCallContent.cs (1)
93return new FunctionCallContent(callId, name, arguments)
Microsoft.Extensions.AI.Abstractions.Tests (11)
ChatCompletion\ChatCompletionTests.cs (1)
251new FunctionCallContent("call123", "name"),
ChatCompletion\ChatMessageTests.cs (3)
129new FunctionCallContent("callId1", "fc1"), 168new FunctionCallContent("callId1", "fc1"), 280new FunctionCallContent("function-id", "plugin-name-function-name", new Dictionary<string, object?> { ["parameter"] = "argument" }),
ChatCompletion\StreamingChatCompletionUpdateTests.cs (3)
96new FunctionCallContent("callId1", "fc1"), 141new FunctionCallContent("callId1", "fc1"), 173new 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 };
Microsoft.Extensions.AI.AzureAIInference.Tests (1)
AzureAIInferenceChatClientTests.cs (1)
511new(ChatRole.Assistant, [new FunctionCallContent("abcd123", "GetMood")]),
Microsoft.Extensions.AI.Integration.Tests (1)
PromptBasedFunctionCallingChatClient.cs (1)
113message.Contents.Add(new FunctionCallContent(id, toolCallParsed.Name!, toolCallParsed.Arguments is { } args ? new ReadOnlyDictionary<string, object?>(args) : null));
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
278return new FunctionCallContent(id, function.Name, function.Arguments);
Microsoft.Extensions.AI.Ollama.Tests (1)
OllamaChatClientTests.cs (1)
462new(ChatRole.Assistant, [new FunctionCallContent("abcd1234", "GetPersonAge", new Dictionary<string, object?> { ["personName"] = "Alice" })]),
Microsoft.Extensions.AI.OpenAI.Tests (5)
OpenAIChatClientTests.cs (2)
1020new FunctionCallContent("12345", "SayHello"), 1021new FunctionCallContent("12346", "SayHi"),
OpenAISerializationTests.cs (3)
474new FunctionCallContent( 598FunctionCallContent fcc = new( 706FunctionCallContent fcc = new(
Microsoft.Extensions.AI.Tests (35)
ChatCompletion\DistributedCachingChatClientTest.cs (1)
46Contents = [new FunctionCallContent("someCallId", "functionName", new Dictionary<string, object?>
ChatCompletion\FunctionInvokingChatClientTests.cs (33)
61new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 63new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 65new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 94new FunctionCallContent("callId1", "Func1"), 95new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 34 } }), 96new FunctionCallContent("callId3", "Func2", arguments: new Dictionary<string, object?> { { "i", 56 } }), 106new FunctionCallContent("callId4", "Func2", arguments: new Dictionary<string, object?> { { "i", 78 } }), 107new FunctionCallContent("callId5", "Func1") 147new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 148new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 191new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 192new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 225new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 227new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 229new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 278new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 280new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 282new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 302new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 304new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 306new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 345new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 366new(ChatRole.Assistant, [new FunctionCallContent("callId1", func1.Metadata.Name)]), 367new(ChatRole.Assistant, [new FunctionCallContent("callId2", func2.Metadata.Name)]), 405new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 464new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 538new StreamingChatCompletionUpdate { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] }, 539new StreamingChatCompletionUpdate { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] }) 598new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["i"] = 41 })]), 600new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["i"] = 42 })]), 608new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1", new Dictionary<string, object?> { ["i"] = 43 })]), 618new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["i"] = 42 })]), 674return new ChatCompletion(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId-abc", "Func1")]))
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
114new(ChatRole.Assistant, [new FunctionCallContent("12345", "GetPersonName")]),
85 references to FunctionCallContent
Microsoft.Extensions.AI (16)
ChatCompletion\FunctionInvokingChatClient.cs (15)
25/// When this client receives a <see cref="FunctionCallContent"/> in a chat completion, it responds 154/// When the inner <see cref="IChatClient"/> returns <see cref="FunctionCallContent"/> to the 258FunctionCallContent[] functionCallContents = response.Message.Contents.OfType<FunctionCallContent>().ToArray(); 292if (response.Message.Contents.Any(c => c is not FunctionCallContent)) 295clone.Contents = clone.Contents.Where(c => c is not FunctionCallContent).ToList(); 334List<FunctionCallContent> functionCallContents = []; 353functionCallContents.AddRange(update.Contents.OfType<FunctionCallContent>()); 361[] : update.Contents.Where(c => c is not FunctionCallContent).ToList(); 494IList<ChatMessage> chatMessages, ChatOptions options, IReadOnlyList<FunctionCallContent> functionCallContents, int iteration, CancellationToken cancellationToken) 554IList<ChatMessage> chatMessages, ChatOptions options, FunctionCallContent functionCallContent, 759FunctionCallContent functionCallContent, 771public FunctionCallContent CallContent { get; set; } 810internal FunctionInvocationResult(ContinueMode continueMode, FunctionStatus status, FunctionCallContent callContent, object? result, Exception? exception) 823public FunctionCallContent CallContent { get; }
ChatCompletion\OpenTelemetryChatClient.cs (1)
514var toolCalls = message.Contents.OfType<FunctionCallContent>().Select(fc => new ToolCall
Microsoft.Extensions.AI.Abstractions (7)
Contents\AIContent.cs (1)
11[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> 68public 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 (19)
ChatCompletion\ChatCompletionTests.cs (1)
288Assert.IsType<FunctionCallContent>(update1.Contents[0]);
ChatCompletion\ChatMessageTests.cs (2)
334var functionCallContent = deserializedMessage.Contents[4] as FunctionCallContent;
ChatCompletion\StreamingChatCompletionUpdateTests.cs (2)
198Assert.IsType<FunctionCallContent>(result.Contents[2]); 199Assert.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); 273var content = FunctionCallContent.CreateFromParsedArguments( 318var content = FunctionCallContent.CreateFromParsedArguments(exc, "callId", "functionName", ThrowingParser); 332Assert.Throws<ArgumentNullException>("encodedArguments", () => FunctionCallContent.CreateFromParsedArguments((string)null!, "callId", "functionName", _ => null)); 333Assert.Throws<ArgumentNullException>("callId", () => FunctionCallContent.CreateFromParsedArguments("{}", null!, "functionName", _ => null)); 334Assert.Throws<ArgumentNullException>("name", () => FunctionCallContent.CreateFromParsedArguments("{}", "callId", null!, _ => null)); 335Assert.Throws<ArgumentNullException>("argumentParser", () => FunctionCallContent.CreateFromParsedArguments("{}", "callId", "functionName", null!));
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (5)
111FunctionCallContent callContent = ParseCallContentFromJsonString(ftc.Arguments, toolCall.Id, ftc.Name); 245FunctionCallContent callContent = ParseCallContentFromJsonString( 441if (content is FunctionCallContent { CallId: not null } callRequest) 487private static FunctionCallContent ParseCallContentFromJsonString(string json, string callId, string name) => 488FunctionCallContent.CreateFromParsedArguments(json, callId, name,
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
AzureAIInferenceChatClientTests.cs (4)
788FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Message.Contents[0]); 878FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
Microsoft.Extensions.AI.Integration.Tests (1)
PromptBasedFunctionCallingChatClient.cs (1)
70else if (message.Contents[itemIndex] is FunctionCallContent fcc)
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
271private static FunctionCallContent ToFunctionCallContent(OllamaFunctionToolCall function) 433case FunctionCallContent fcc:
Microsoft.Extensions.AI.Ollama.Tests (2)
OllamaChatClientTests.cs (2)
385FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Message.Contents[0]);
Microsoft.Extensions.AI.OpenAI (9)
OpenAIModelMapper.ChatCompletion.cs (5)
43if (content is FunctionCallContent callRequest) 622private static FunctionCallContent ParseCallContentFromJsonString(string json, string callId, string name) => 623FunctionCallContent.CreateFromParsedArguments(json, callId, name, 626private static FunctionCallContent ParseCallContentFromBinaryData(BinaryData ut8Json, string callId, string name) => 627FunctionCallContent.CreateFromParsedArguments(ut8Json, callId, name,
OpenAIModelMapper.ChatMessage.cs (1)
174if (content is FunctionCallContent callRequest)
OpenAIModelMappers.StreamingChatCompletion.cs (1)
33if (content is FunctionCallContent functionCallContent)
OpenAIRealtimeExtensions.cs (2)
99var functionCallContent = FunctionCallContent.CreateFromParsedArguments(
Microsoft.Extensions.AI.OpenAI.Tests (8)
OpenAIChatClientTests.cs (4)
796FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Message.Contents[0]); 896FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
OpenAISerializationTests.cs (4)
445FunctionCallContent text = Assert.IsType<FunctionCallContent>(Assert.Single(msg.Contents)); 598FunctionCallContent fcc = new( 706FunctionCallContent fcc = new(
Microsoft.Extensions.AI.Tests (12)
ChatCompletion\FunctionInvokingChatClientTests.cs (12)
251Assert.Contains(content, c => c is FunctionCallContent or FunctionResultContent); 255Assert.All(content, c => Assert.False(c is FunctionCallContent or FunctionResultContent)); 320Assert.Contains(content, c => c is FunctionCallContent or FunctionResultContent); 324Assert.All(content, c => Assert.False(c is FunctionCallContent or FunctionResultContent)); 557c => Assert.Equal("Input 1", Assert.IsType<FunctionCallContent>(c).Arguments!["text"]), 558c => Assert.Equal("Input 2", Assert.IsType<FunctionCallContent>(c).Arguments!["text"])), 760if (expectedItem is FunctionCallContent expectedFunctionCall) 762var chatFunctionCall = (FunctionCallContent)chatItem; 849if (expectedItem is FunctionCallContent expectedFunctionCall) 851var chatFunctionCall = (FunctionCallContent)chatItem;