79 instantiations of FunctionCallContent
Microsoft.Extensions.AI (1)
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.AI.Abstractions.Tests (9)
Microsoft.Extensions.AI.AzureAIInference.Tests (1)
Microsoft.Extensions.AI.Integration.Tests (1)
Microsoft.Extensions.AI.OpenAI.Tests (12)
OpenAIConversionTests.cs (10)
95new FunctionCallContent("callid123", "SomeFunction", new Dictionary<string, object?>
161new FunctionCallContent("callid123", "SomeFunction", new Dictionary<string, object?>
364new FunctionCallContent("call123", "TestFunction", new Dictionary<string, object?> { ["param"] = "value" })
469new FunctionCallContent("process_data", "ProcessComplexData", complexArgs)
652var functionCallContent = new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?>
690var functionCall1 = new FunctionCallContent("call-1", "Function1", new Dictionary<string, object?> { ["param1"] = "value1" });
691var functionCall2 = new FunctionCallContent("call-2", "Function2", new Dictionary<string, object?> { ["param2"] = "value2" });
724new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" }),
966new FunctionCallContent("call-123", "TestFunction", new Dictionary<string, object?> { ["param"] = "value" })
1001new FunctionCallContent("call-456", "GetWeather", new Dictionary<string, object?> { ["location"] = "Seattle" })
Microsoft.Extensions.AI.Tests (54)
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\FunctionInvokingChatClientTests.cs (43)
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 } })]),
379new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId0", "VoidReturn")]),
387plan.Add(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent($"callId{(i + 1)}", "VoidReturn")]));
529assistantMessage.Contents.Add(new FunctionCallContent(callId, "Func",
553new ChatMessage(ChatRole.Assistant, [new TextContent("extra"), new FunctionCallContent("callId1", "Func1"), new TextContent("stuff")]),
555new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })]),
557new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "VoidReturn", arguments: new Dictionary<string, object?> { { "i", 43 } }), new TextContent("more")]),
590new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]),
612new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
668new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
743new() { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] },
744new() { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] }
796new(ChatRole.Assistant, [new FunctionCallContent($"callId{chatContents.Count()}", "Func1")]) :
845new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["i"] = 41 })]),
847new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["i"] = 42 })]),
855new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId3", "Func1", new Dictionary<string, object?> { ["i"] = 43 })]),
915new FunctionCallContent("callId1", "Search"),
916new FunctionCallContent("callId2", "Search", new Dictionary<string, object?> { { "result", "birds" } }),
917new FunctionCallContent("callId3", "Search"),
963return new ChatResponse(new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId-abc", "Func1")]))
1001new ChatMessage(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg1"] = "value1" })]),
1031new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["arg"] = "value1" }),
1032new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["arg"] = "value2" }),
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)]),
118 references to FunctionCallContent
Microsoft.Extensions.AI (18)
ChatCompletion\FunctionInvokingChatClient.cs (13)
30/// When this client receives a <see cref="FunctionCallContent"/> in a chat response, it responds
246List<FunctionCallContent>? functionCallContents = null; // function call contents that need responding to in the current turn
339List<FunctionCallContent>? functionCallContents = null; // function call contents that need responding to in the current turn
516/// <summary>Copies any <see cref="FunctionCallContent"/> from <paramref name="messages"/> to <paramref name="functionCalls"/>.</summary>
518IList<ChatMessage> messages, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls)
530/// <summary>Copies any <see cref="FunctionCallContent"/> from <paramref name="content"/> to <paramref name="functionCalls"/>.</summary>
532IList<AIContent> content, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls)
538if (content[i] is FunctionCallContent functionCall)
586List<ChatMessage> messages, ChatOptions? options, List<FunctionCallContent> functionCallContents, int iteration, int consecutiveErrorCount,
715List<ChatMessage> messages, ChatOptions? options, List<FunctionCallContent> callContents,
718var callContent = callContents[functionCallIndex];
959internal FunctionInvocationResult(bool terminate, FunctionInvocationStatus status, FunctionCallContent callContent, object? result, Exception? exception)
972public FunctionCallContent CallContent { get; }
Microsoft.Extensions.AI.Abstractions (7)
Microsoft.Extensions.AI.Abstractions.Tests (18)
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)
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
Microsoft.Extensions.AI.Evaluation.Quality (13)
Microsoft.Extensions.AI.Integration.Tests (1)
Microsoft.Extensions.AI.OpenAI (18)
OpenAIClientExtensions.cs (8)
196/// <summary>Creates a new instance of <see cref="FunctionCallContent"/> parsing arguments using a specified encoding and parser.</summary>
200/// <returns>A new instance of <see cref="FunctionCallContent"/> containing the parse result.</returns>
203internal static FunctionCallContent ParseCallContent(string json, string callId, string name) =>
204FunctionCallContent.CreateFromParsedArguments(json, callId, name,
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>
214internal static FunctionCallContent ParseCallContent(BinaryData utf8json, string callId, string name) =>
215FunctionCallContent.CreateFromParsedArguments(utf8json, callId, name,
Microsoft.Extensions.AI.OpenAI.Tests (11)
OpenAIConversionTests.cs (7)
234Assert.Equal("functionName", Assert.IsType<FunctionCallContent>(message.Contents[2], exactMatch: false).Name);
265Assert.Equal("functionName", Assert.IsType<FunctionCallContent>(message.Contents[2], exactMatch: false).Name);
377var functionCall = message.Contents.OfType<FunctionCallContent>().FirstOrDefault();
652var functionCallContent = new FunctionCallContent("call-123", "GetWeather", new Dictionary<string, object?>
690var functionCall1 = new FunctionCallContent("call-1", "Function1", new Dictionary<string, object?> { ["param1"] = "value1" });
691var functionCall2 = new FunctionCallContent("call-2", "Function2", new Dictionary<string, object?> { ["param2"] = "value2" });
Microsoft.Extensions.AI.Tests (23)