Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f973c9

Browse files
eiriktsarpalisstephentoubSteveSandersonMS
authored
ReplaceAIFunctionParameterMetadata withMethodInfo (#5886)
* Replace AIFunctionParemeterMetadata with MethodInfo* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionMetadata.csCo-authored-by: Stephen Toub <stoub@microsoft.com>* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionMetadata.csCo-authored-by: Stephen Toub <stoub@microsoft.com>* Address feedback,* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.csCo-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>* Flatten AIFunctionMetadata properties into AIFunction.* Address feedback.* Mark JSO as virtual---------Co-authored-by: Stephen Toub <stoub@microsoft.com>Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>
1 parent584a56a commit2f973c9

File tree

24 files changed

+207
-735
lines changed

24 files changed

+207
-735
lines changed

‎src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs‎

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
usingSystem.Collections.Generic;
55
usingSystem.Diagnostics;
6+
usingSystem.Reflection;
7+
usingSystem.Text.Json;
68
usingSystem.Threading;
79
usingSystem.Threading.Tasks;
810
usingMicrosoft.Shared.Collections;
@@ -13,8 +15,52 @@ namespace Microsoft.Extensions.AI;
1315
[DebuggerDisplay("{DebuggerDisplay,nq}")]
1416
publicabstractclassAIFunction:AITool
1517
{
16-
/// <summary>Gets metadata describing the function.</summary>
17-
publicabstractAIFunctionMetadataMetadata{get;}
18+
/// <summary>Gets the name of the function.</summary>
19+
publicabstractstringName{get;}
20+
21+
/// <summary>Gets a description of the function, suitable for use in describing the purpose to a model.</summary>
22+
publicabstractstringDescription{get;}
23+
24+
/// <summary>Gets a JSON Schema describing the function and its input parameters.</summary>
25+
/// <remarks>
26+
/// <para>
27+
/// When specified, declares a self-contained JSON schema document that describes the function and its input parameters.
28+
/// A simple example of a JSON schema for a function that adds two numbers together is shown below:
29+
/// </para>
30+
/// <code>
31+
/// {
32+
/// "title" : "addNumbers",
33+
/// "description": "A simple function that adds two numbers together.",
34+
/// "type": "object",
35+
/// "properties": {
36+
/// "a" : { "type": "number" },
37+
/// "b" : { "type": "number", "default": 1 }
38+
/// },
39+
/// "required" : ["a"]
40+
/// }
41+
/// </code>
42+
/// <para>
43+
/// The metadata present in the schema document plays an important role in guiding AI function invocation.
44+
/// </para>
45+
/// <para>
46+
/// When no schema is specified, consuming chat clients should assume the "{}" or "true" schema, indicating that any JSON input is admissible.
47+
/// </para>
48+
/// </remarks>
49+
publicvirtualJsonElementJsonSchema=>AIJsonUtilities.DefaultJsonSchema;
50+
51+
/// <summary>
52+
/// Gets the underlying <see cref="MethodInfo"/> that this <see cref="AIFunction"/> might be wrapping.
53+
/// </summary>
54+
/// <remarks>
55+
/// Provides additional metadata on the function and its signature. Implementations not wrapping .NET methods may return <see langword="null"/>.
56+
/// </remarks>
57+
publicvirtualMethodInfo?UnderlyingMethod=>null;
58+
59+
/// <summary>Gets any additional properties associated with the function.</summary>
60+
publicvirtualIReadOnlyDictionary<string,object?>AdditionalProperties=>EmptyReadOnlyDictionary<string,object?>.Instance;
61+
62+
/// <summary>Gets a <see cref="JsonSerializerOptions"/> that can be used to marshal function parameters.</summary>
63+
publicvirtualJsonSerializerOptions?JsonSerializerOptions=>AIJsonUtilities.DefaultOptions;
1864

1965
/// <summary>Invokes the <see cref="AIFunction"/> and returns its result.</summary>
2066
/// <param name="arguments">The arguments to pass to the function's invocation.</param>
@@ -30,7 +76,7 @@ public abstract class AIFunction : AITool
3076
}
3177

3278
/// <inheritdoc/>
33-
publicoverridestringToString()=>Metadata.Name;
79+
publicoverridestringToString()=>Name;
3480

3581
/// <summary>Invokes the <see cref="AIFunction"/> and returns its result.</summary>
3682
/// <param name="arguments">The arguments to pass to the function's invocation.</param>
@@ -42,8 +88,5 @@ public abstract class AIFunction : AITool
4288

4389
/// <summary>Gets the string to display in the debugger for this instance.</summary>
4490
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
45-
privatestringDebuggerDisplay=>
46-
string.IsNullOrWhiteSpace(Metadata.Description)?
47-
Metadata.Name:
48-
$"{Metadata.Name} ({Metadata.Description})";
91+
privatestringDebuggerDisplay=>string.IsNullOrWhiteSpace(Description)?Name:$"{Name} ({Description})";
4992
}

‎src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionMetadata.cs‎

Lines changed: 0 additions & 153 deletions
This file was deleted.

‎src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionParameterMetadata.cs‎

Lines changed: 0 additions & 63 deletions
This file was deleted.

‎src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionReturnParameterMetadata.cs‎

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp