Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,60 @@
<Right>lib/netstandard2.0/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Microsoft.Extensions.AI.FunctionCallContent</Target>
<Left>lib/net462/Microsoft.Extensions.AI.Abstractions.dll</Left>
<Right>lib/net462/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Microsoft.Extensions.AI.FunctionResultContent</Target>
<Left>lib/net462/Microsoft.Extensions.AI.Abstractions.dll</Left>
<Right>lib/net462/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Microsoft.Extensions.AI.FunctionCallContent</Target>
<Left>lib/net8.0/Microsoft.Extensions.AI.Abstractions.dll</Left>
<Right>lib/net8.0/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Microsoft.Extensions.AI.FunctionResultContent</Target>
<Left>lib/net8.0/Microsoft.Extensions.AI.Abstractions.dll</Left>
<Right>lib/net8.0/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Microsoft.Extensions.AI.FunctionCallContent</Target>
<Left>lib/net9.0/Microsoft.Extensions.AI.Abstractions.dll</Left>
<Right>lib/net9.0/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Microsoft.Extensions.AI.FunctionResultContent</Target>
<Left>lib/net9.0/Microsoft.Extensions.AI.Abstractions.dll</Left>
<Right>lib/net9.0/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Microsoft.Extensions.AI.FunctionCallContent</Target>
<Left>lib/netstandard2.0/Microsoft.Extensions.AI.Abstractions.dll</Left>
<Right>lib/netstandard2.0/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Microsoft.Extensions.AI.FunctionResultContent</Target>
<Left>lib/netstandard2.0/Microsoft.Extensions.AI.Abstractions.dll</Left>
<Right>lib/netstandard2.0/Microsoft.Extensions.AI.Abstractions.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
</Suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace Microsoft.Extensions.AI;
// [JsonDerivedType(typeof(FunctionApprovalResponseContent), typeDiscriminator: "functionApprovalResponse")]
// [JsonDerivedType(typeof(McpServerToolCallContent), typeDiscriminator: "mcpServerToolCall")]
// [JsonDerivedType(typeof(McpServerToolResultContent), typeDiscriminator: "mcpServerToolResult")]
// [JsonDerivedType(typeof(McpServerToolApprovalRequestContent), typeDiscriminator: "mcpServerToolApprovalRequest")]
// [JsonDerivedType(typeof(McpServerToolApprovalResponseContent), typeDiscriminator: "mcpServerToolApprovalResponse")]
// [JsonDerivedType(typeof(CodeInterpreterToolCallContent), typeDiscriminator: "codeInterpreterToolCall")]
// [JsonDerivedType(typeof(CodeInterpreterToolResultContent), typeDiscriminator: "codeInterpreterToolResult")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents a request for user approval of a function call.
/// Represents a request for user approval of a call content.
/// </summary>
[Experimental("MEAI001")]
public sealed class FunctionApprovalRequestContent : UserInputRequestContent
Expand All @@ -17,26 +17,26 @@ public sealed class FunctionApprovalRequestContent : UserInputRequestContent
/// Initializes a new instance of the <see cref="FunctionApprovalRequestContent"/> class.
/// </summary>
/// <param name="id">The ID that uniquely identifies the function approval request/response pair.</param>
/// <param name="functionCall">The function call that requires user approval.</param>
/// <param name="callContent">The call content that requires user approval.</param>
/// <exception cref="ArgumentNullException"><paramref name="id"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="id"/> is empty or composed entirely of whitespace.</exception>
/// <exception cref="ArgumentNullException"><paramref name="functionCall"/> is <see langword="null"/>.</exception>
public FunctionApprovalRequestContent(string id, FunctionCallContent functionCall)
/// <exception cref="ArgumentNullException"><paramref name="callContent"/> is <see langword="null"/>.</exception>
public FunctionApprovalRequestContent(string id, AIContent callContent)
: base(id)
{
FunctionCall = Throw.IfNull(functionCall);
CallContent = Throw.IfNull(callContent);
}

/// <summary>
/// Gets the function call that pre-invoke approval is required for.
/// Gets the call content that pre-invoke approval is required for.
/// </summary>
public FunctionCallContent FunctionCall { get; }
public AIContent CallContent { get; }

/// <summary>
/// Creates a <see cref="FunctionApprovalResponseContent"/> to indicate whether the function call is approved or rejected based on the value of <paramref name="approved"/>.
/// Creates a <see cref="FunctionApprovalResponseContent"/> to indicate whether the call is approved or rejected based on the value of <paramref name="approved"/>.
/// </summary>
/// <param name="approved"><see langword="true"/> if the function call is approved; otherwise, <see langword="false"/>.</param>
/// <param name="approved"><see langword="true"/> if the call is approved; otherwise, <see langword="false"/>.</param>
/// <param name="reason">An optional reason for the approval or rejection.</param>
/// <returns>The <see cref="FunctionApprovalResponseContent"/> representing the approval response.</returns>
public FunctionApprovalResponseContent CreateResponse(bool approved, string? reason = null) => new(Id, approved, FunctionCall) { Reason = reason };
public FunctionApprovalResponseContent CreateResponse(bool approved, string? reason = null) => new(Id, approved, CallContent) { Reason = reason };
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
namespace Microsoft.Extensions.AI;

/// <summary>
/// Represents a response to a function approval request.
/// Represents a response to an approval request.
/// </summary>
[Experimental("MEAI001")]
public sealed class FunctionApprovalResponseContent : UserInputResponseContent
{
/// <summary>
/// Initializes a new instance of the <see cref="FunctionApprovalResponseContent"/> class.
/// </summary>
/// <param name="id">The ID that uniquely identifies the function approval request/response pair.</param>
/// <param name="approved"><see langword="true"/> if the function call is approved; otherwise, <see langword="false"/>.</param>
/// <param name="functionCall">The function call that requires user approval.</param>
/// <param name="id">The ID that uniquely identifies the approval request/response pair.</param>
/// <param name="approved"><see langword="true"/> if the call is approved; otherwise, <see langword="false"/>.</param>
/// <param name="callContent">The call content that requires user approval.</param>
/// <exception cref="ArgumentNullException"><paramref name="id"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="id"/> is empty or composed entirely of whitespace.</exception>
/// <exception cref="ArgumentNullException"><paramref name="functionCall"/> is <see langword="null"/>.</exception>
public FunctionApprovalResponseContent(string id, bool approved, FunctionCallContent functionCall)
/// <exception cref="ArgumentNullException"><paramref name="callContent"/> is <see langword="null"/>.</exception>
public FunctionApprovalResponseContent(string id, bool approved, AIContent callContent)
: base(id)
{
Approved = approved;
FunctionCall = Throw.IfNull(functionCall);
CallContent = Throw.IfNull(callContent);
}

/// <summary>
Expand All @@ -35,9 +35,9 @@ public FunctionApprovalResponseContent(string id, bool approved, FunctionCallCon
public bool Approved { get; }

/// <summary>
/// Gets the function call for which approval was requested.
/// Gets the call content for which approval was requested.
/// </summary>
public FunctionCallContent FunctionCall { get; }
public AIContent CallContent { get; }

/// <summary>
/// Gets or sets the optional reason for the approval or rejection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.Extensions.AI;
/// Represents a function call request.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public sealed class FunctionCallContent : AIContent
public class FunctionCallContent : AIContent
{
/// <summary>
/// Initializes a new instance of the <see cref="FunctionCallContent"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.AI;
/// Represents the result of a function call.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public sealed class FunctionResultContent : AIContent
public class FunctionResultContent : AIContent
{
/// <summary>
/// Initializes a new instance of the <see cref="FunctionResultContent"/> class.
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.Diagnostics;
using System.Text.Json.Serialization;

namespace Microsoft.Extensions.AI;

Expand All @@ -16,7 +16,7 @@ namespace Microsoft.Extensions.AI;
/// It is informational only.
/// </remarks>
[Experimental("MEAI001")]
public sealed class McpServerToolCallContent : AIContent
public sealed class McpServerToolCallContent : FunctionCallContent
{
/// <summary>
/// Initializes a new instance of the <see cref="McpServerToolCallContent"/> class.
Expand All @@ -26,22 +26,17 @@ public sealed class McpServerToolCallContent : AIContent
/// <param name="serverName">The MCP server name that hosts the tool.</param>
/// <exception cref="ArgumentNullException"><paramref name="callId"/> or <paramref name="toolName"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="callId"/> or <paramref name="toolName"/> is empty or composed entirely of whitespace.</exception>
[JsonConstructor]
public McpServerToolCallContent(string callId, string toolName, string? serverName)
: base(callId, toolName, arguments: null)
{
CallId = Throw.IfNullOrWhitespace(callId);
ToolName = Throw.IfNullOrWhitespace(toolName);
ServerName = serverName;
}

/// <summary>
/// Gets the tool call ID.
/// </summary>
public string CallId { get; }

/// <summary>
/// Gets the name of the tool called.
/// </summary>
public string ToolName { get; }
public string ToolName => Name;

/// <summary>
/// Gets the name of the MCP server that hosts the tool.
Expand All @@ -51,5 +46,10 @@ public McpServerToolCallContent(string callId, string toolName, string? serverNa
/// <summary>
/// Gets or sets the arguments used for the tool call.
/// </summary>
public IReadOnlyDictionary<string, object?>? Arguments { get; set; }
[JsonIgnore]
public new IReadOnlyDictionary<string, object?>? Arguments
{
get => base.Arguments as IReadOnlyDictionary<string, object?>;
set => base.Arguments = value as IDictionary<string, object?>;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.Diagnostics;
using System.Text.Json.Serialization;

namespace Microsoft.Extensions.AI;

Expand All @@ -16,26 +16,27 @@ namespace Microsoft.Extensions.AI;
/// It is informational only.
/// </remarks>
[Experimental("MEAI001")]
public sealed class McpServerToolResultContent : AIContent
public sealed class McpServerToolResultContent : FunctionResultContent
{
/// <summary>
/// Initializes a new instance of the <see cref="McpServerToolResultContent"/> class.
/// </summary>
/// <param name="callId">The tool call ID.</param>
/// <exception cref="ArgumentNullException"><paramref name="callId"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="callId"/> is empty or composed entirely of whitespace.</exception>
[JsonConstructor]
public McpServerToolResultContent(string callId)
: base(callId, result: null)
{
CallId = Throw.IfNullOrWhitespace(callId);
}

/// <summary>
/// Gets the tool call ID.
/// </summary>
public string CallId { get; }

/// <summary>
/// Gets or sets the output of the tool call.
/// </summary>
public IList<AIContent>? Output { get; set; }
[JsonIgnore]
public IList<AIContent>? Output
{
get => Result as IList<AIContent>;
set => Result = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Microsoft.Extensions.AI;
[Experimental("MEAI001")]
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(FunctionApprovalRequestContent), "functionApprovalRequest")]
[JsonDerivedType(typeof(McpServerToolApprovalRequestContent), "mcpServerToolApprovalRequest")]
public class UserInputRequestContent : AIContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Microsoft.Extensions.AI;
[Experimental("MEAI001")]
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(FunctionApprovalResponseContent), "functionApprovalResponse")]
[JsonDerivedType(typeof(McpServerToolApprovalResponseContent), "mcpServerToolApprovalResponse")]
public class UserInputResponseContent : AIContent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ private static JsonSerializerOptions CreateDefaultOptions()
AddAIContentType(options, typeof(FunctionApprovalResponseContent), typeDiscriminatorId: "functionApprovalResponse", checkBuiltIn: false);
AddAIContentType(options, typeof(McpServerToolCallContent), typeDiscriminatorId: "mcpServerToolCall", checkBuiltIn: false);
AddAIContentType(options, typeof(McpServerToolResultContent), typeDiscriminatorId: "mcpServerToolResult", checkBuiltIn: false);
AddAIContentType(options, typeof(McpServerToolApprovalRequestContent), typeDiscriminatorId: "mcpServerToolApprovalRequest", checkBuiltIn: false);
AddAIContentType(options, typeof(McpServerToolApprovalResponseContent), typeDiscriminatorId: "mcpServerToolApprovalResponse", checkBuiltIn: false);
AddAIContentType(options, typeof(CodeInterpreterToolCallContent), typeDiscriminatorId: "codeInterpreterToolCall", checkBuiltIn: false);
AddAIContentType(options, typeof(CodeInterpreterToolResultContent), typeDiscriminatorId: "codeInterpreterToolResult", checkBuiltIn: false);

Expand Down Expand Up @@ -129,8 +127,6 @@ private static JsonSerializerOptions CreateDefaultOptions()
[JsonSerializable(typeof(FunctionApprovalResponseContent))]
[JsonSerializable(typeof(McpServerToolCallContent))]
[JsonSerializable(typeof(McpServerToolResultContent))]
[JsonSerializable(typeof(McpServerToolApprovalRequestContent))]
[JsonSerializable(typeof(McpServerToolApprovalResponseContent))]
[JsonSerializable(typeof(CodeInterpreterToolCallContent))]
[JsonSerializable(typeof(CodeInterpreterToolResultContent))]
[JsonSerializable(typeof(ResponseContinuationToken))]
Expand Down
Loading
Loading