35 instantiations of FunctionApprovalResponseContent
Microsoft.Extensions.AI.Abstractions (1)
Contents\FunctionApprovalRequestContent.cs (1)
41
public FunctionApprovalResponseContent CreateResponse(bool approved, string? reason = null) =>
new
(Id, approved, FunctionCall) { Reason = reason };
Microsoft.Extensions.AI.Abstractions.Tests (9)
Contents\AIContentTests.cs (1)
74
new
FunctionApprovalResponseContent
("request123", approved: true, new FunctionCallContent("call123", "functionName", new Dictionary<string, object?> { { "param1", 123 } })),
Contents\FunctionApprovalResponseContentTests.cs (6)
17
Assert.Throws<ArgumentNullException>("id", () => new
FunctionApprovalResponseContent
(null!, true, functionCall));
18
Assert.Throws<ArgumentException>("id", () => new
FunctionApprovalResponseContent
("", true, functionCall));
19
Assert.Throws<ArgumentException>("id", () => new
FunctionApprovalResponseContent
("\r\t\n ", true, functionCall));
21
Assert.Throws<ArgumentNullException>("functionCall", () => new
FunctionApprovalResponseContent
("id", true, null!));
31
FunctionApprovalResponseContent content =
new
(id, approved, functionCall);
43
var content = new
FunctionApprovalResponseContent
("request123", true, new FunctionCallContent("call123", "functionName"))
Contents\UserInputResponseContentTests.cs (2)
34
UserInputResponseContent content = new
FunctionApprovalResponseContent
("request123", true, new FunctionCallContent("call123", "functionName"));
42
new
FunctionApprovalResponseContent
("request123", true, new FunctionCallContent("call123", "functionName")),
Microsoft.Extensions.AI.Tests (25)
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (25)
160
new
FunctionApprovalResponseContent
("callId1", true, new FunctionCallContent("callId1", "Func1")),
161
new
FunctionApprovalResponseContent
("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
212
new
FunctionApprovalResponseContent
("callId1", true, new FunctionCallContent("callId1", "Func1")),
213
new
FunctionApprovalResponseContent
("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
267
new
FunctionApprovalResponseContent
("callId1", true, new FunctionCallContent("callId1", "Func1")),
271
new
FunctionApprovalResponseContent
("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
323
new
FunctionApprovalResponseContent
("callId1", false, new FunctionCallContent("callId1", "Func1")),
324
new
FunctionApprovalResponseContent
("callId2", false, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
382
new
FunctionApprovalResponseContent
("callId1", false, new FunctionCallContent("callId1", "Func1")),
383
new
FunctionApprovalResponseContent
("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
446
new
FunctionApprovalResponseContent
("callId1", false, new FunctionCallContent("callId1", "Func1"))
450
new
FunctionApprovalResponseContent
("callId2", false, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
513
new
FunctionApprovalResponseContent
("callId1", false, new FunctionCallContent("callId1", "Func1")) { Reason = "Custom rejection for Func1" },
514
new
FunctionApprovalResponseContent
("callId2", false, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } })),
515
new
FunctionApprovalResponseContent
("callId3", true, new FunctionCallContent("callId3", "Func3", arguments: new Dictionary<string, object?> { { "s", "test" } }))
603
new
FunctionApprovalResponseContent
("callId1", false, new FunctionCallContent("callId1", "Func1"))
662
new
FunctionApprovalResponseContent
("callId1", true, new FunctionCallContent("callId1", "Func1")),
663
new
FunctionApprovalResponseContent
("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
716
new
FunctionApprovalResponseContent
("callId1", true, new FunctionCallContent("callId1", "Func1")),
717
new
FunctionApprovalResponseContent
("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
727
new
FunctionApprovalResponseContent
("callId3", true, new FunctionCallContent("callId3", "Func1")),
867
new
FunctionApprovalResponseContent
("callId1", true, new FunctionCallContent("callId1", "Func1")),
868
new
FunctionApprovalResponseContent
("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
913
new
FunctionApprovalResponseContent
("callId1", true, new FunctionCallContent("callId1", "Func1")),
914
new
FunctionApprovalResponseContent
("callId2", true, new FunctionCallContent("callId2", "Func2", arguments: new Dictionary<string, object?> { { "i", 42 } }))
26 references to FunctionApprovalResponseContent
Microsoft.Extensions.AI (12)
ChatCompletion\FunctionInvokingChatClient.cs (12)
45
/// responsible for responding to that approval request by sending a corresponding <see cref="
FunctionApprovalResponseContent
"/> in a subsequent
751
/// Gets whether <paramref name="messages"/> contains any <see cref="FunctionApprovalRequestContent"/> or <see cref="
FunctionApprovalResponseContent
"/> instances.
754
messages.Exists(static m => m.Contents.Any(static c => c is FunctionApprovalRequestContent or
FunctionApprovalResponseContent
));
1246
/// 1. Remove all <see cref="FunctionApprovalRequestContent"/> and <see cref="
FunctionApprovalResponseContent
"/> from the <paramref name="originalMessages"/>.
1247
/// 2. Recreate <see cref="FunctionCallContent"/> for any <see cref="
FunctionApprovalResponseContent
"/> that haven't been executed yet.
1248
/// 3. Genreate failed <see cref="FunctionResultContent"/> for any rejected <see cref="
FunctionApprovalResponseContent
"/>.
1306
List<
FunctionApprovalResponseContent
>? allApprovalResponses = null;
1335
case
FunctionApprovalResponseContent
farc:
1393
foreach (
var
approvalResponse in allApprovalResponses)
1434
/// Extracts the <see cref="FunctionCallContent"/> from the provided <see cref="
FunctionApprovalResponseContent
"/> to recreate the original function call messages.
1652
/// Execute the provided <see cref="
FunctionApprovalResponseContent
"/> and return the resulting <see cref="FunctionCallContent"/>
1747
public
FunctionApprovalResponseContent
Response { get; set; }
Microsoft.Extensions.AI.Abstractions (8)
Contents\FunctionApprovalRequestContent.cs (3)
36
/// Creates a <see cref="
FunctionApprovalResponseContent
"/> to indicate whether the function call is approved or rejected based on the value of <paramref name="approved"/>.
40
/// <returns>The <see cref="
FunctionApprovalResponseContent
"/> representing the approval response.</returns>
41
public
FunctionApprovalResponseContent
CreateResponse(bool approved, string? reason = null) => new(Id, approved, FunctionCall) { Reason = reason };
Contents\FunctionApprovalResponseContent.cs (1)
17
/// Initializes a new instance of the <see cref="
FunctionApprovalResponseContent
"/> class.
Contents\McpServerToolApprovalRequestContent.cs (1)
39
/// <returns>The <see cref="
FunctionApprovalResponseContent
"/> representing the approval response.</returns>
Contents\UserInputResponseContent.cs (1)
16
[JsonDerivedType(typeof(
FunctionApprovalResponseContent
), "functionApprovalResponse")]
Utilities\AIJsonUtilities.Defaults.cs (2)
55
AddAIContentType(options, typeof(
FunctionApprovalResponseContent
), typeDiscriminatorId: "functionApprovalResponse", checkBuiltIn: false);
129
[JsonSerializable(typeof(
FunctionApprovalResponseContent
))]
Microsoft.Extensions.AI.Abstractions.Tests (6)
Contents\FunctionApprovalRequestContentTests.cs (2)
49
var
response = content.CreateResponse(approved);
70
var
response = content.CreateResponse(approved, reason);
Contents\FunctionApprovalResponseContentTests.cs (4)
31
FunctionApprovalResponseContent
content = new(id, approved, functionCall);
43
var
content = new FunctionApprovalResponseContent("request123", true, new FunctionCallContent("call123", "functionName"))
49
var
deserializedContent = JsonSerializer.Deserialize<
FunctionApprovalResponseContent
>(json, AIJsonUtilities.DefaultOptions);