42 instantiations of FunctionCallContent
Microsoft.Extensions.AI.Abstractions (1)
Contents\FunctionCallContent.cs (1)
93return new FunctionCallContent(callId, name, arguments)
Microsoft.Extensions.AI.Abstractions.Tests (15)
ChatCompletion\ChatMessageTests.cs (5)
128new FunctionCallContent("callId1", "fc1"), 131new FunctionResultContent(new FunctionCallContent("callId1", "fc2"), "result"), 167new FunctionCallContent("callId1", "fc1"), 293new FunctionCallContent("function-id", "plugin-name-function-name", new Dictionary<string, object?> { ["parameter"] = "argument" }), 294new FunctionResultContent(new FunctionCallContent("function-id", "plugin-name-function-name"), "function-result"),
ChatCompletion\StreamingChatCompletionUpdateTests.cs (4)
96new FunctionCallContent("callId1", "fc1"), 99new FunctionResultContent(new FunctionCallContent("callId1", "fc2"), "result"), 141new FunctionCallContent("callId1", "fc1"), 173new FunctionCallContent("callId1", "fc1"),
Contents\FunctionCallContentTests..cs (4)
21FunctionCallContent c = new("callId1", "name"); 39FunctionCallContent c = new("id", "name", args); 53FunctionCallContent c = new("callId1", "name"); 89var sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) { Exception = ex };
Contents\FunctionResultContentTests.cs (2)
45FunctionResultContent c = new(new FunctionCallContent("id", "name"), "result", e); 91var sut = new FunctionResultContent(new FunctionCallContent("id", "p1-f1"), "result");
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)
214contents.Add(new FunctionCallContent(id, function.Name, function.Arguments));
Microsoft.Extensions.AI.Ollama.Tests (1)
OllamaChatClientTests.cs (1)
445new(ChatRole.Assistant, [new FunctionCallContent("abcd1234", "GetPersonAge", new Dictionary<string, object?> { ["personName"] = "Alice" })]),
Microsoft.Extensions.AI.Tests (23)
ChatCompletion\DistributedCachingChatClientTest.cs (1)
46Contents = [new FunctionCallContent("someCallId", "functionName", new Dictionary<string, object?>
ChatCompletion\FunctionInvokingChatClientTests.cs (21)
42new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 44new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 46new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 67new FunctionCallContent("callId1", "Func1"), 68new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 34 } }), 69new FunctionCallContent("callId3", "Func2", arguments: new Dictionary<string, object?> { { "i", 56 } }), 77new FunctionCallContent("callId4", "Func2", arguments: new Dictionary<string, object?> { { "i", 78 } }), 78new FunctionCallContent("callId5", "Func1")]), 105new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 106new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 138new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 139new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 169new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 171new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 173new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 216new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 218new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 220new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 261new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 281new(ChatRole.Assistant, [new FunctionCallContent("callId1", func1.Metadata.Name)]), 282new(ChatRole.Assistant, [new FunctionCallContent("callId2", func2.Metadata.Name)]),
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
101new(ChatRole.Assistant, [new FunctionCallContent("12345", "GetPersonName")]),
68 references to FunctionCallContent
Microsoft.Extensions.AI (14)
ChatCompletion\FunctionInvokingChatClient.cs (13)
21/// When this client receives a <see cref="FunctionCallContent"/> in a chat completion, it responds 120/// When the inner <see cref="IChatClient"/> returns <see cref="FunctionCallContent"/> to the 207FunctionCallContent[] functionCallContents = response.Message.Contents.OfType<FunctionCallContent>().ToArray(); 283List<FunctionCallContent>? functionCallContents = null; 290foreach (var item in chunk.Contents.OfType<FunctionCallContent>()) 399IList<ChatMessage> chatMessages, ChatOptions options, IReadOnlyList<FunctionCallContent> functionCallContents, int iteration, CancellationToken cancellationToken) 459IList<ChatMessage> chatMessages, ChatOptions options, FunctionCallContent functionCallContent, 581FunctionCallContent functionCallContent, 593public FunctionCallContent CallContent { get; set; } 632internal FunctionInvocationResult(ContinueMode continueMode, FunctionStatus status, FunctionCallContent callContent, object? result, Exception? exception) 645public FunctionCallContent CallContent { get; }
ChatCompletion\OpenTelemetryChatClient.cs (1)
520var toolCalls = message.Contents.OfType<FunctionCallContent>().Select(fc => new ToolCall
Microsoft.Extensions.AI.Abstractions (8)
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> 68public static FunctionCallContent CreateFromParsedArguments<TEncoding>(
Contents\FunctionResultContent.cs (3)
65public FunctionResultContent(FunctionCallContent functionCall, object? result, Exception? exception = null) 74/// If this is the result for a <see cref="FunctionCallContent"/>, this should contain the same 75/// <see cref="FunctionCallContent.CallId"/> value.
Microsoft.Extensions.AI.Abstractions.Tests (18)
ChatCompletion\ChatMessageTests.cs (2)
369var functionCallContent = deserializedMessage.Contents[6] 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"); 39FunctionCallContent c = new("id", "name", args); 53FunctionCallContent c = new("callId1", "name"); 89var sut = new FunctionCallContent("callId1", "functionName", new Dictionary<string, object?> { ["key"] = "value" }) { Exception = ex }; 93var deserializedSut = JsonSerializer.Deserialize<FunctionCallContent>(json, TestJsonSerializerContext.Default.Options); 281var content = FunctionCallContent.CreateFromParsedArguments( 326FunctionCallContent content = FunctionCallContent.CreateFromParsedArguments(exc, "callId", "functionName", ThrowingParser); 340Assert.Throws<ArgumentNullException>(() => FunctionCallContent.CreateFromParsedArguments((string)null!, "callId", "functionName", _ => null)); 341Assert.Throws<ArgumentNullException>(() => FunctionCallContent.CreateFromParsedArguments("{}", null!, "functionName", _ => null)); 342Assert.Throws<ArgumentNullException>(() => FunctionCallContent.CreateFromParsedArguments("{}", "callId", null!, _ => null)); 343Assert.Throws<ArgumentNullException>(() => FunctionCallContent.CreateFromParsedArguments("{}", "callId", "functionName", null!));
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (5)
99FunctionCallContent callContent = ParseCallContentFromJsonString(ftc.Arguments, toolCall.Id, ftc.Name); 229FunctionCallContent callContent = ParseCallContentFromJsonString( 468if (content is FunctionCallContent callRequest && callRequest.CallId is not null && toolCalls?.ContainsKey(callRequest.CallId) is not true) 499private static FunctionCallContent ParseCallContentFromJsonString(string json, string callId, string name) => 500FunctionCallContent.CreateFromParsedArguments(json, callId, name,
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
AzureAIInferenceChatClientTests.cs (4)
429FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Message.Contents[0]); 524FunctionCallContent 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 (1)
OllamaChatClient.cs (1)
364case FunctionCallContent fcc:
Microsoft.Extensions.AI.Ollama.Tests (2)
OllamaChatClientTests.cs (2)
368FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Message.Contents[0]);
Microsoft.Extensions.AI.OpenAI (7)
OpenAIChatClient.cs (7)
127var callContent = ParseCallContentFromBinaryData(toolCall.FunctionArguments, toolCall.Id, toolCall.FunctionName); 321var callContent = ParseCallContentFromJsonString( 629if (content is FunctionCallContent callRequest && callRequest.CallId is not null && toolCalls?.ContainsKey(callRequest.CallId) is not true) 654private static FunctionCallContent ParseCallContentFromJsonString(string json, string callId, string name) => 655FunctionCallContent.CreateFromParsedArguments(json, callId, name, 658private static FunctionCallContent ParseCallContentFromBinaryData(BinaryData ut8Json, string callId, string name) => 659FunctionCallContent.CreateFromParsedArguments(ut8Json, callId, name,
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAIChatClientTests.cs (4)
475FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Message.Contents[0]); 575FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
Microsoft.Extensions.AI.Tests (4)
ChatCompletion\FunctionInvokingChatClientTests.cs (4)
189Assert.Contains(content, c => c is FunctionCallContent or FunctionResultContent); 193Assert.All(content, c => Assert.False(c is FunctionCallContent or FunctionResultContent)); 238Assert.Contains(content, c => c is FunctionCallContent or FunctionResultContent); 242Assert.All(content, c => Assert.False(c is FunctionCallContent or FunctionResultContent));