50 instantiations of FunctionCallContent
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvocationContext.cs (1)
27private FunctionCallContent _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 (8)
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)
89new FunctionCallContent("callId1", "fc1"), 118new 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)
539new(ChatRole.Assistant, [new FunctionCallContent("abcd123", "GetMood")]),
Microsoft.Extensions.AI.Integration.Tests (1)
PromptBasedFunctionCallingChatClient.cs (1)
119message.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)
284return new FunctionCallContent(id, function.Name, function.Arguments);
Microsoft.Extensions.AI.Ollama.Tests (1)
OllamaChatClientTests.cs (1)
466new(ChatRole.Assistant, [new FunctionCallContent("abcd1234", "GetPersonAge", new Dictionary<string, object?> { ["personName"] = "Alice" })]),
Microsoft.Extensions.AI.OpenAI.Tests (5)
OpenAIChatClientTests.cs (2)
1019new FunctionCallContent("12345", "SayHello"), 1020new FunctionCallContent("12346", "SayHi"),
OpenAISerializationTests.cs (3)
470new FunctionCallContent( 572FunctionCallContent fcc = new( 680FunctionCallContent fcc = new(
Microsoft.Extensions.AI.Tests (31)
ChatCompletion\DistributedCachingChatClientTest.cs (4)
46Contents = [new FunctionCallContent("someCallId", "functionName", new Dictionary<string, object?> 224new FunctionCallContent("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" }), 235Contents = [new FunctionCallContent("someCallId", "someFn", new Dictionary<string, object?> { ["arg1"] = "value1" })], 285new() { 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 (25)
57new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 59new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 61new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } })]), 90new FunctionCallContent("callId1", "Func1"), 91new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 34 } }), 92new FunctionCallContent("callId3", "Func2", arguments: new Dictionary<string, object?> { { "i", 56 } }), 102new FunctionCallContent("callId4", "Func2", arguments: new Dictionary<string, object?> { { "i", 78 } }), 103new FunctionCallContent("callId5", "Func1") 143new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 144new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 187new FunctionCallContent("callId1", "Func", arguments: new Dictionary<string, object?> { { "arg", "hello" } }), 188new FunctionCallContent("callId2", "Func", arguments: new Dictionary<string, object?> { { "arg", "world" } }), 219new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]), 221new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]), 223new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]), 256new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]), 278new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 334new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]), 409new() { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] }, 410new() { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] } 462new(ChatRole.Assistant, [new FunctionCallContent($"callId{chatContents.Count()}", "Func1")]) : 511new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["i"] = 41 })]), 513new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["i"] = 42 })]), 521new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1", new Dictionary<string, object?> { ["i"] = 43 })]), 576return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId-abc", "Func1")]))
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
112new(ChatRole.Assistant, [new FunctionCallContent("12345", "GetPersonName")]),
92 references to FunctionCallContent
Microsoft.Extensions.AI (16)
ChatCompletion\FunctionInvocationContext.cs (2)
27private FunctionCallContent _callContent = new(string.Empty, _nopFunction.Name, EmptyReadOnlyDictionary<string, object?>.Instance); 35public FunctionCallContent CallContent
ChatCompletion\FunctionInvokingChatClient.cs (13)
28/// When this client receives a <see cref="FunctionCallContent"/> in a chat response, it responds 197List<FunctionCallContent>? functionCallContents = null; // function call contents that need responding to in the current turn 280List<FunctionCallContent>? functionCallContents = null; // function call contents that need responding to in the current turn 415/// <summary>Copies any <see cref="FunctionCallContent"/> from <paramref name="messages"/> to <paramref name="functionCalls"/>.</summary> 417IList<ChatMessage> messages, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls) 429/// <summary>Copies any <see cref="FunctionCallContent"/> from <paramref name="content"/> to <paramref name="functionCalls"/>.</summary> 431IList<AIContent> content, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls) 437if (content[i] is FunctionCallContent functionCall) 500List<ChatMessage> messages, ChatOptions options, List<FunctionCallContent> functionCallContents, int iteration, CancellationToken cancellationToken) 582List<ChatMessage> messages, ChatOptions options, List<FunctionCallContent> callContents, 585var callContent = callContents[functionCallIndex]; 786internal FunctionInvocationResult(ContinueMode continueMode, FunctionInvocationStatus status, FunctionCallContent callContent, object? result, Exception? exception) 799public FunctionCallContent CallContent { get; }
ChatCompletion\OpenTelemetryChatClient.cs (1)
512var toolCalls = 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> 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)
142Assert.IsType<FunctionCallContent>(result.Contents[2]); 143Assert.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); 240FunctionCallContent callContent = ParseCallContentFromJsonString( 475if (content is FunctionCallContent { CallId: not null } callRequest) 539private static FunctionCallContent ParseCallContentFromJsonString(string json, string callId, string name) => 540FunctionCallContent.CreateFromParsedArguments(json, callId, name,
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
AzureAIInferenceChatClientTests.cs (4)
815FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Messages.Single().Contents[0]); 905FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
Microsoft.Extensions.AI.Integration.Tests (1)
PromptBasedFunctionCallingChatClient.cs (1)
76else if (message.Contents[itemIndex] is FunctionCallContent fcc)
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
277private static FunctionCallContent ToFunctionCallContent(OllamaFunctionToolCall function) 439case FunctionCallContent fcc:
Microsoft.Extensions.AI.Ollama.Tests (2)
OllamaChatClientTests.cs (2)
389FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Messages.Single().Contents[0]);
Microsoft.Extensions.AI.OpenAI (9)
OpenAIModelMapper.ChatCompletion.cs (5)
42if (content is FunctionCallContent callRequest) 612private static FunctionCallContent ParseCallContentFromJsonString(string json, string callId, string name) => 613FunctionCallContent.CreateFromParsedArguments(json, callId, name, 616private static FunctionCallContent ParseCallContentFromBinaryData(BinaryData ut8Json, string callId, string name) => 617FunctionCallContent.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)
103var functionCallContent = FunctionCallContent.CreateFromParsedArguments(
Microsoft.Extensions.AI.OpenAI.Tests (8)
OpenAIChatClientTests.cs (4)
795FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(response.Messages.Single().Contents[0]); 895FunctionCallContent fcc = Assert.IsType<FunctionCallContent>(Assert.Single(updates[updates.Count - 1].Contents));
OpenAISerializationTests.cs (4)
441FunctionCallContent text = Assert.IsType<FunctionCallContent>(Assert.Single(msg.Contents)); 572FunctionCallContent fcc = new( 680FunctionCallContent fcc = new(
Microsoft.Extensions.AI.Tests (20)
ChatCompletion\DistributedCachingChatClientTest.cs (8)
317c => Assert.IsType<FunctionCallContent>(c), 325c => Assert.IsType<FunctionCallContent>(Assert.Single(c.Contents)), 740if (expectedItem is FunctionCallContent expectedFcc) 742var actualFcc = (FunctionCallContent)actualItem; 774if (expectedItemItem is FunctionCallContent expectedFcc) 776var actualFcc = (FunctionCallContent)actualItemItem;
ChatCompletion\FunctionInvocationContextTests.cs (1)
55FunctionCallContent callContent = new(string.Empty, string.Empty, new Dictionary<string, object?>());
ChatCompletion\FunctionInvokingChatClientTests.cs (11)
236Assert.Contains(content, c => c is FunctionCallContent or FunctionResultContent); 434c => Assert.Equal("Input 1", Assert.IsType<FunctionCallContent>(c).Arguments!["text"]), 435c => Assert.Equal("Input 2", Assert.IsType<FunctionCallContent>(c).Arguments!["text"])), 475Assert.IsType<FunctionCallContent>(Assert.Single(response.Messages[0].Contents)); 477Assert.IsType<FunctionCallContent>(Assert.Single(response.Messages[2].Contents)); 665if (expectedItem is FunctionCallContent expectedFunctionCall) 667var chatFunctionCall = (FunctionCallContent)chatItem; 756if (expectedItem is FunctionCallContent expectedFunctionCall) 758var chatFunctionCall = (FunctionCallContent)chatItem;