Skip to content

Commit 66459e3

Browse files
authored
Merging internal commits (#6801)
2 parents 20349f8 + bae0537 commit 66459e3

File tree

67 files changed

+4287
-558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+4287
-558
lines changed

eng/Version.Details.xml

Lines changed: 94 additions & 94 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<!--
1111
When StabilizePackageVersion is set to 'true', this branch will produce stable outputs for 'Shipping' packages
1212
-->
13-
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">false</StabilizePackageVersion>
13+
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">true</StabilizePackageVersion>
1414
<!--
1515
When DotNetFinalVersionKind is set to 'release' (only for the release branches),
1616
the build will produce stable outputs for 'Shipping' packages.
1717
1818
This is used by the Arcade SDK (Publish.proj) to determine if the build is a release build or not.
1919
-->
20-
<DotNetFinalVersionKind />
20+
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>
2121
<!-- Enabling this rule will cause build failures on undocumented public APIs. -->
2222
<SkipArcadeNoWarnCS1591>true</SkipArcadeNoWarnCS1591>
2323
</PropertyGroup>
@@ -33,55 +33,55 @@
3333
-->
3434
<PropertyGroup Label="Automated Maestro dependency updates">
3535
<!-- Packages from dotnet/runtime -->
36-
<MicrosoftBclAsyncInterfacesVersion>9.0.8</MicrosoftBclAsyncInterfacesVersion>
37-
<MicrosoftBclTimeProviderVersion>9.0.8</MicrosoftBclTimeProviderVersion>
38-
<MicrosoftExtensionsCachingAbstractionsVersion>9.0.8</MicrosoftExtensionsCachingAbstractionsVersion>
39-
<MicrosoftExtensionsCachingMemoryVersion>9.0.8</MicrosoftExtensionsCachingMemoryVersion>
40-
<MicrosoftExtensionsConfigurationAbstractionsVersion>9.0.8</MicrosoftExtensionsConfigurationAbstractionsVersion>
41-
<MicrosoftExtensionsConfigurationBinderVersion>9.0.8</MicrosoftExtensionsConfigurationBinderVersion>
42-
<MicrosoftExtensionsConfigurationJsonVersion>9.0.8</MicrosoftExtensionsConfigurationJsonVersion>
43-
<MicrosoftExtensionsConfigurationVersion>9.0.8</MicrosoftExtensionsConfigurationVersion>
44-
<MicrosoftExtensionsDependencyInjectionAbstractionsVersion>9.0.8</MicrosoftExtensionsDependencyInjectionAbstractionsVersion>
45-
<MicrosoftExtensionsDependencyInjectionVersion>9.0.8</MicrosoftExtensionsDependencyInjectionVersion>
46-
<MicrosoftExtensionsDiagnosticsVersion>9.0.8</MicrosoftExtensionsDiagnosticsVersion>
47-
<MicrosoftExtensionsHostingAbstractionsVersion>9.0.8</MicrosoftExtensionsHostingAbstractionsVersion>
48-
<MicrosoftExtensionsHostingVersion>9.0.8</MicrosoftExtensionsHostingVersion>
49-
<MicrosoftExtensionsHttpVersion>9.0.8</MicrosoftExtensionsHttpVersion>
50-
<MicrosoftExtensionsLoggingAbstractionsVersion>9.0.8</MicrosoftExtensionsLoggingAbstractionsVersion>
51-
<MicrosoftExtensionsLoggingConfigurationVersion>9.0.8</MicrosoftExtensionsLoggingConfigurationVersion>
52-
<MicrosoftExtensionsLoggingConsoleVersion>9.0.8</MicrosoftExtensionsLoggingConsoleVersion>
53-
<MicrosoftExtensionsLoggingVersion>9.0.8</MicrosoftExtensionsLoggingVersion>
54-
<MicrosoftExtensionsOptionsConfigurationExtensionsVersion>9.0.8</MicrosoftExtensionsOptionsConfigurationExtensionsVersion>
55-
<MicrosoftExtensionsOptionsVersion>9.0.8</MicrosoftExtensionsOptionsVersion>
56-
<MicrosoftNETCoreAppRefVersion>9.0.8</MicrosoftNETCoreAppRefVersion>
57-
<MicrosoftNETCoreAppRuntimewinx64Version>9.0.8</MicrosoftNETCoreAppRuntimewinx64Version>
58-
<SystemCollectionsImmutableVersion>9.0.8</SystemCollectionsImmutableVersion>
59-
<SystemConfigurationConfigurationManagerVersion>9.0.8</SystemConfigurationConfigurationManagerVersion>
60-
<SystemDiagnosticsDiagnosticSourceVersion>9.0.8</SystemDiagnosticsDiagnosticSourceVersion>
61-
<SystemDiagnosticsPerformanceCounterVersion>9.0.8</SystemDiagnosticsPerformanceCounterVersion>
62-
<SystemIOHashingVersion>9.0.8</SystemIOHashingVersion>
63-
<SystemIOPipelinesVersion>9.0.8</SystemIOPipelinesVersion>
64-
<SystemMemoryDataVersion>9.0.8</SystemMemoryDataVersion>
65-
<SystemNetHttpJsonVersion>9.0.8</SystemNetHttpJsonVersion>
66-
<SystemRuntimeCachingVersion>9.0.8</SystemRuntimeCachingVersion>
67-
<SystemSecurityCryptographyPkcsVersion>9.0.8</SystemSecurityCryptographyPkcsVersion>
68-
<SystemSecurityCryptographyXmlVersion>9.0.8</SystemSecurityCryptographyXmlVersion>
69-
<SystemTextEncodingsWebVersion>9.0.8</SystemTextEncodingsWebVersion>
70-
<SystemNumericsTensorsVersion>9.0.8</SystemNumericsTensorsVersion>
71-
<SystemTextJsonVersion>9.0.8</SystemTextJsonVersion>
72-
<SystemThreadingChannelsVersion>9.0.8</SystemThreadingChannelsVersion>
36+
<MicrosoftBclAsyncInterfacesVersion>9.0.9</MicrosoftBclAsyncInterfacesVersion>
37+
<MicrosoftBclTimeProviderVersion>9.0.9</MicrosoftBclTimeProviderVersion>
38+
<MicrosoftExtensionsCachingAbstractionsVersion>9.0.9</MicrosoftExtensionsCachingAbstractionsVersion>
39+
<MicrosoftExtensionsCachingMemoryVersion>9.0.9</MicrosoftExtensionsCachingMemoryVersion>
40+
<MicrosoftExtensionsConfigurationAbstractionsVersion>9.0.9</MicrosoftExtensionsConfigurationAbstractionsVersion>
41+
<MicrosoftExtensionsConfigurationBinderVersion>9.0.9</MicrosoftExtensionsConfigurationBinderVersion>
42+
<MicrosoftExtensionsConfigurationJsonVersion>9.0.9</MicrosoftExtensionsConfigurationJsonVersion>
43+
<MicrosoftExtensionsConfigurationVersion>9.0.9</MicrosoftExtensionsConfigurationVersion>
44+
<MicrosoftExtensionsDependencyInjectionAbstractionsVersion>9.0.9</MicrosoftExtensionsDependencyInjectionAbstractionsVersion>
45+
<MicrosoftExtensionsDependencyInjectionVersion>9.0.9</MicrosoftExtensionsDependencyInjectionVersion>
46+
<MicrosoftExtensionsDiagnosticsVersion>9.0.9</MicrosoftExtensionsDiagnosticsVersion>
47+
<MicrosoftExtensionsHostingAbstractionsVersion>9.0.9</MicrosoftExtensionsHostingAbstractionsVersion>
48+
<MicrosoftExtensionsHostingVersion>9.0.9</MicrosoftExtensionsHostingVersion>
49+
<MicrosoftExtensionsHttpVersion>9.0.9</MicrosoftExtensionsHttpVersion>
50+
<MicrosoftExtensionsLoggingAbstractionsVersion>9.0.9</MicrosoftExtensionsLoggingAbstractionsVersion>
51+
<MicrosoftExtensionsLoggingConfigurationVersion>9.0.9</MicrosoftExtensionsLoggingConfigurationVersion>
52+
<MicrosoftExtensionsLoggingConsoleVersion>9.0.9</MicrosoftExtensionsLoggingConsoleVersion>
53+
<MicrosoftExtensionsLoggingVersion>9.0.9</MicrosoftExtensionsLoggingVersion>
54+
<MicrosoftExtensionsOptionsConfigurationExtensionsVersion>9.0.9</MicrosoftExtensionsOptionsConfigurationExtensionsVersion>
55+
<MicrosoftExtensionsOptionsVersion>9.0.9</MicrosoftExtensionsOptionsVersion>
56+
<MicrosoftNETCoreAppRefVersion>9.0.9</MicrosoftNETCoreAppRefVersion>
57+
<MicrosoftNETCoreAppRuntimewinx64Version>9.0.9</MicrosoftNETCoreAppRuntimewinx64Version>
58+
<SystemCollectionsImmutableVersion>9.0.9</SystemCollectionsImmutableVersion>
59+
<SystemConfigurationConfigurationManagerVersion>9.0.9</SystemConfigurationConfigurationManagerVersion>
60+
<SystemDiagnosticsDiagnosticSourceVersion>9.0.9</SystemDiagnosticsDiagnosticSourceVersion>
61+
<SystemDiagnosticsPerformanceCounterVersion>9.0.9</SystemDiagnosticsPerformanceCounterVersion>
62+
<SystemIOHashingVersion>9.0.9</SystemIOHashingVersion>
63+
<SystemIOPipelinesVersion>9.0.9</SystemIOPipelinesVersion>
64+
<SystemMemoryDataVersion>9.0.9</SystemMemoryDataVersion>
65+
<SystemNetHttpJsonVersion>9.0.9</SystemNetHttpJsonVersion>
66+
<SystemRuntimeCachingVersion>9.0.9</SystemRuntimeCachingVersion>
67+
<SystemSecurityCryptographyPkcsVersion>9.0.9</SystemSecurityCryptographyPkcsVersion>
68+
<SystemSecurityCryptographyXmlVersion>9.0.9</SystemSecurityCryptographyXmlVersion>
69+
<SystemTextEncodingsWebVersion>9.0.9</SystemTextEncodingsWebVersion>
70+
<SystemNumericsTensorsVersion>9.0.9</SystemNumericsTensorsVersion>
71+
<SystemTextJsonVersion>9.0.9</SystemTextJsonVersion>
72+
<SystemThreadingChannelsVersion>9.0.9</SystemThreadingChannelsVersion>
7373
<!-- Dependencies from https://github.com/aspnet/AspNetCore -->
74-
<MicrosoftAspNetCoreAppRefVersion>9.0.8</MicrosoftAspNetCoreAppRefVersion>
75-
<MicrosoftAspNetCoreAppRuntimewinx64Version>9.0.8</MicrosoftAspNetCoreAppRuntimewinx64Version>
76-
<MicrosoftAspNetCoreMvcTestingVersion>9.0.8</MicrosoftAspNetCoreMvcTestingVersion>
77-
<MicrosoftAspNetCoreTestHostVersion>9.0.8</MicrosoftAspNetCoreTestHostVersion>
78-
<MicrosoftExtensionsCachingSqlServerVersion>9.0.8</MicrosoftExtensionsCachingSqlServerVersion>
79-
<MicrosoftExtensionsCachingStackExchangeRedisVersion>9.0.8</MicrosoftExtensionsCachingStackExchangeRedisVersion>
80-
<MicrosoftExtensionsDiagnosticsHealthChecksVersion>9.0.8</MicrosoftExtensionsDiagnosticsHealthChecksVersion>
81-
<MicrosoftExtensionsHttpPollyVersion>9.0.8</MicrosoftExtensionsHttpPollyVersion>
82-
<MicrosoftExtensionsObjectPoolVersion>9.0.8</MicrosoftExtensionsObjectPoolVersion>
74+
<MicrosoftAspNetCoreAppRefVersion>9.0.9</MicrosoftAspNetCoreAppRefVersion>
75+
<MicrosoftAspNetCoreAppRuntimewinx64Version>9.0.9</MicrosoftAspNetCoreAppRuntimewinx64Version>
76+
<MicrosoftAspNetCoreMvcTestingVersion>9.0.9</MicrosoftAspNetCoreMvcTestingVersion>
77+
<MicrosoftAspNetCoreTestHostVersion>9.0.9</MicrosoftAspNetCoreTestHostVersion>
78+
<MicrosoftExtensionsCachingSqlServerVersion>9.0.9</MicrosoftExtensionsCachingSqlServerVersion>
79+
<MicrosoftExtensionsCachingStackExchangeRedisVersion>9.0.9</MicrosoftExtensionsCachingStackExchangeRedisVersion>
80+
<MicrosoftExtensionsDiagnosticsHealthChecksVersion>9.0.9</MicrosoftExtensionsDiagnosticsHealthChecksVersion>
81+
<MicrosoftExtensionsHttpPollyVersion>9.0.9</MicrosoftExtensionsHttpPollyVersion>
82+
<MicrosoftExtensionsObjectPoolVersion>9.0.9</MicrosoftExtensionsObjectPoolVersion>
8383
<!-- Dependencies from https://github.com/dotnet/efcore -->
84-
<MicrosoftEntityFrameworkCoreSqliteVersion>9.0.8</MicrosoftEntityFrameworkCoreSqliteVersion>
84+
<MicrosoftEntityFrameworkCoreSqliteVersion>9.0.9</MicrosoftEntityFrameworkCoreSqliteVersion>
8585
<!-- Dependencies from https://github.com/dotnet/arcade -->
8686
<MicrosoftDotNetBuildTasksTemplatingVersion>9.0.0-beta.25428.3</MicrosoftDotNetBuildTasksTemplatingVersion>
8787
</PropertyGroup>
@@ -107,8 +107,8 @@
107107
<MicrosoftExtensionsLoggingLTSVersion>8.0.1</MicrosoftExtensionsLoggingLTSVersion>
108108
<MicrosoftExtensionsOptionsConfigurationExtensionsLTSVersion>8.0.0</MicrosoftExtensionsOptionsConfigurationExtensionsLTSVersion>
109109
<MicrosoftExtensionsOptionsLTSVersion>8.0.2</MicrosoftExtensionsOptionsLTSVersion>
110-
<MicrosoftNETCoreAppRefLTSVersion>8.0.19</MicrosoftNETCoreAppRefLTSVersion>
111-
<MicrosoftNETCoreAppRuntimewinx64LTSVersion>8.0.19</MicrosoftNETCoreAppRuntimewinx64LTSVersion>
110+
<MicrosoftNETCoreAppRefLTSVersion>8.0.20</MicrosoftNETCoreAppRefLTSVersion>
111+
<MicrosoftNETCoreAppRuntimewinx64LTSVersion>8.0.20</MicrosoftNETCoreAppRuntimewinx64LTSVersion>
112112
<SystemCollectionsImmutableLTSVersion>8.0.0</SystemCollectionsImmutableLTSVersion>
113113
<SystemConfigurationConfigurationManagerLTSVersion>8.0.1</SystemConfigurationConfigurationManagerLTSVersion>
114114
<SystemDiagnosticsDiagnosticSourceLTSVersion>8.0.1</SystemDiagnosticsDiagnosticSourceLTSVersion>
@@ -125,17 +125,17 @@
125125
<SystemTextJsonLTSVersion>8.0.6</SystemTextJsonLTSVersion>
126126
<SystemThreadingChannelsLTSVersion>8.0.0</SystemThreadingChannelsLTSVersion>
127127
<!-- Dependencies from https://github.com/aspnet/AspNetCore -->
128-
<MicrosoftAspNetCoreAppRefLTSVersion>8.0.19</MicrosoftAspNetCoreAppRefLTSVersion>
129-
<MicrosoftAspNetCoreAppRuntimewinx64LTSVersion>8.0.19</MicrosoftAspNetCoreAppRuntimewinx64LTSVersion>
130-
<MicrosoftAspNetCoreMvcTestingLTSVersion>8.0.19</MicrosoftAspNetCoreMvcTestingLTSVersion>
131-
<MicrosoftAspNetCoreTestHostLTSVersion>8.0.19</MicrosoftAspNetCoreTestHostLTSVersion>
132-
<MicrosoftExtensionsCachingSqlServerLTSVersion>8.0.19</MicrosoftExtensionsCachingSqlServerLTSVersion>
133-
<MicrosoftExtensionsCachingStackExchangeRedisLTSVersion>8.0.19</MicrosoftExtensionsCachingStackExchangeRedisLTSVersion>
134-
<MicrosoftExtensionsDiagnosticsHealthChecksLTSVersion>8.0.19</MicrosoftExtensionsDiagnosticsHealthChecksLTSVersion>
135-
<MicrosoftExtensionsHttpPollyLTSVersion>8.0.19</MicrosoftExtensionsHttpPollyLTSVersion>
136-
<MicrosoftExtensionsObjectPoolLTSVersion>8.0.19</MicrosoftExtensionsObjectPoolLTSVersion>
128+
<MicrosoftAspNetCoreAppRefLTSVersion>8.0.20</MicrosoftAspNetCoreAppRefLTSVersion>
129+
<MicrosoftAspNetCoreAppRuntimewinx64LTSVersion>8.0.20</MicrosoftAspNetCoreAppRuntimewinx64LTSVersion>
130+
<MicrosoftAspNetCoreMvcTestingLTSVersion>8.0.20</MicrosoftAspNetCoreMvcTestingLTSVersion>
131+
<MicrosoftAspNetCoreTestHostLTSVersion>8.0.20</MicrosoftAspNetCoreTestHostLTSVersion>
132+
<MicrosoftExtensionsCachingSqlServerLTSVersion>8.0.20</MicrosoftExtensionsCachingSqlServerLTSVersion>
133+
<MicrosoftExtensionsCachingStackExchangeRedisLTSVersion>8.0.20</MicrosoftExtensionsCachingStackExchangeRedisLTSVersion>
134+
<MicrosoftExtensionsDiagnosticsHealthChecksLTSVersion>8.0.20</MicrosoftExtensionsDiagnosticsHealthChecksLTSVersion>
135+
<MicrosoftExtensionsHttpPollyLTSVersion>8.0.20</MicrosoftExtensionsHttpPollyLTSVersion>
136+
<MicrosoftExtensionsObjectPoolLTSVersion>8.0.20</MicrosoftExtensionsObjectPoolLTSVersion>
137137
<!-- Dependencies from https://github.com/dotnet/efcore -->
138-
<MicrosoftEntityFrameworkCoreSqliteLTSVersion>8.0.19</MicrosoftEntityFrameworkCoreSqliteLTSVersion>
138+
<MicrosoftEntityFrameworkCoreSqliteLTSVersion>8.0.20</MicrosoftEntityFrameworkCoreSqliteLTSVersion>
139139
</PropertyGroup>
140140
<!--
141141

eng/packages/General.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageVersion Include="Microsoft.ML.Tokenizers" Version="$(MicrosoftMLTokenizersVersion)" />
1717
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
1818
<PackageVersion Include="OllamaSharp" Version="5.1.9" />
19-
<PackageVersion Include="OpenAI" Version="2.3.0" />
19+
<PackageVersion Include="OpenAI" Version="2.4.0" />
2020
<PackageVersion Include="Polly" Version="8.4.2" />
2121
<PackageVersion Include="Polly.Core" Version="8.4.2" />
2222
<PackageVersion Include="Polly.Extensions" Version="8.4.2" />

eng/packages/TestOnly.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
44
<PackageVersion Include="AutoFixture.AutoMoq" Version="4.17.0" />
5-
<PackageVersion Include="Azure.AI.OpenAI" Version="2.3.0-beta.1" />
5+
<PackageVersion Include="Azure.AI.OpenAI" Version="2.3.0-beta.2" />
66
<PackageVersion Include="autofixture" Version="4.17.0" />
77
<PackageVersion Include="BenchmarkDotNet" Version="0.13.5" />
88
<PackageVersion Include="AwesomeAssertions" Version="8.0.2" />

src/Libraries/Microsoft.Extensions.AI.Abstractions/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## NOT YET RELEASED
44

55
- Added non-invocable `AIFunctionDeclaration` (base class for `AIFunction`), `AIFunctionFactory.CreateDeclaration`, and `AIFunction.AsDeclarationOnly`.
6+
- Added `[Experimental]` support for user approval of function invocations via `ApprovalRequiredAIFunction`, `FunctionApprovalRequestContent`, and friends.
7+
- Added `[Experimental]` support for MCP server-hosted tools via `HostedMcpServerTool`, `HostedMcpServerToolApprovalMode`, and friends.
68

79
## 9.8.0
810

src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ private static void FinalizeResponse(ChatResponse response)
303303
private static void ProcessUpdate(ChatResponseUpdate update, ChatResponse response)
304304
{
305305
// If there is no message created yet, or if the last update we saw had a different
306-
// message ID than the newest update, create a new message.
306+
// message ID or role than the newest update, create a new message.
307307
ChatMessage message;
308308
var isNewMessage = false;
309309
if (response.Messages.Count == 0)
@@ -316,6 +316,12 @@ private static void ProcessUpdate(ChatResponseUpdate update, ChatResponse respon
316316
{
317317
isNewMessage = true;
318318
}
319+
else if (update.Role is { } updateRole
320+
&& response.Messages[response.Messages.Count - 1].Role is { } lastRole
321+
&& updateRole != lastRole)
322+
{
323+
isNewMessage = true;
324+
}
319325

320326
if (isNewMessage)
321327
{

src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/RequiredChatToolMode.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ public RequiredChatToolMode(string? requiredFunctionName)
4141
RequiredFunctionName = requiredFunctionName;
4242
}
4343

44-
// The reason for not overriding Equals/GetHashCode (e.g., so two instances are equal if they
45-
// have the same RequiredFunctionName) is to leave open the option to unseal the type in the
46-
// future. If we did define equality based on RequiredFunctionName but a subclass added further
47-
// fields, this would lead to wrong behavior unless the subclass author remembers to re-override
48-
// Equals/GetHashCode as well, which they likely won't.
49-
5044
/// <summary>Gets a string representing this instance to display in the debugger.</summary>
5145
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
5246
private string DebuggerDisplay => $"Required: {RequiredFunctionName ?? "Any"}";

src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/AIContent.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ namespace Microsoft.Extensions.AI;
1818
[JsonDerivedType(typeof(TextReasoningContent), typeDiscriminator: "reasoning")]
1919
[JsonDerivedType(typeof(UriContent), typeDiscriminator: "uri")]
2020
[JsonDerivedType(typeof(UsageContent), typeDiscriminator: "usage")]
21+
22+
// These should be added in once they're no longer [Experimental]. If they're included while still
23+
// experimental, any JsonSerializerContext that includes AIContent will incur errors about using
24+
// experimental types in its source generated files.
25+
// [JsonDerivedType(typeof(FunctionApprovalRequestContent), typeDiscriminator: "functionApprovalRequest")]
26+
// [JsonDerivedType(typeof(FunctionApprovalResponseContent), typeDiscriminator: "functionApprovalResponse")]
27+
// [JsonDerivedType(typeof(McpServerToolCallContent), typeDiscriminator: "mcpServerToolCall")]
28+
// [JsonDerivedType(typeof(McpServerToolResultContent), typeDiscriminator: "mcpServerToolResult")]
29+
// [JsonDerivedType(typeof(McpServerToolApprovalRequestContent), typeDiscriminator: "mcpServerToolApprovalRequest")]
30+
// [JsonDerivedType(typeof(McpServerToolApprovalResponseContent), typeDiscriminator: "mcpServerToolApprovalResponse")]
31+
2132
public class AIContent
2233
{
2334
/// <summary>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Diagnostics.CodeAnalysis;
6+
using Microsoft.Shared.Diagnostics;
7+
8+
namespace Microsoft.Extensions.AI;
9+
10+
/// <summary>
11+
/// Represents a request for user approval of a function call.
12+
/// </summary>
13+
[Experimental("MEAI001")]
14+
public sealed class FunctionApprovalRequestContent : UserInputRequestContent
15+
{
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="FunctionApprovalRequestContent"/> class.
18+
/// </summary>
19+
/// <param name="id">The ID that uniquely identifies the function approval request/response pair.</param>
20+
/// <param name="functionCall">The function call that requires user approval.</param>
21+
/// <exception cref="ArgumentNullException"><paramref name="id"/> is <see langword="null"/>.</exception>
22+
/// <exception cref="ArgumentException"><paramref name="id"/> is empty or composed entirely of whitespace.</exception>
23+
/// <exception cref="ArgumentNullException"><paramref name="functionCall"/> is <see langword="null"/>.</exception>
24+
public FunctionApprovalRequestContent(string id, FunctionCallContent functionCall)
25+
: base(id)
26+
{
27+
FunctionCall = Throw.IfNull(functionCall);
28+
}
29+
30+
/// <summary>
31+
/// Gets the function call that pre-invoke approval is required for.
32+
/// </summary>
33+
public FunctionCallContent FunctionCall { get; }
34+
35+
/// <summary>
36+
/// Creates a <see cref="FunctionApprovalResponseContent"/> to indicate whether the function call is approved or rejected based on the value of <paramref name="approved"/>.
37+
/// </summary>
38+
/// <param name="approved"><see langword="true"/> if the function call is approved; otherwise, <see langword="false"/>.</param>
39+
/// <returns>The <see cref="FunctionApprovalResponseContent"/> representing the approval response.</returns>
40+
public FunctionApprovalResponseContent CreateResponse(bool approved) => new(Id, approved, FunctionCall);
41+
}

0 commit comments

Comments
 (0)