-
Notifications
You must be signed in to change notification settings - Fork 873
Add AINameAttribute to override the AI-facing name of a function or parameter #7599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ec522c2
d95df66
2a609ef
d6ab8b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using Microsoft.Shared.DiagnosticIds; | ||
| using Microsoft.Shared.Diagnostics; | ||
|
|
||
| namespace Microsoft.Extensions.AI; | ||
|
|
||
| /// <summary> | ||
| /// Specifies the name to use for an <see cref="AIFunction"/> or one of its parameters. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The name is the identifier a model sees and uses to invoke a function or to supply an argument. | ||
| /// By default these names are inferred from .NET metadata: a function's name comes from the method name, and a | ||
| /// parameter's name comes from the .NET parameter name. Apply this attribute to use a different identifier. | ||
| /// </remarks> | ||
| [AttributeUsage(AttributeTargets.Method | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] | ||
| [Experimental(DiagnosticIds.Experiments.AIName, UrlFormat = DiagnosticIds.UrlFormat)] | ||
| public sealed class AINameAttribute : Attribute | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "AI name" seems slightly vague to me. I'd go for either
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is currently scoped to Methods and Params. I thought of AIFunctionName but the "AIFunction" part feels like it can target methods only.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thoughts on
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paging @bartonjs @jeffhandley @halter73 for opinions.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { | ||
| /// <summary>Initializes a new instance of the <see cref="AINameAttribute"/> class.</summary> | ||
| /// <param name="name">The name to use for the function or parameter.</param> | ||
| /// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null"/>.</exception> | ||
| /// <exception cref="ArgumentException"><paramref name="name"/> is empty or composed entirely of whitespace.</exception> | ||
| public AINameAttribute(string name) | ||
| { | ||
| Name = Throw.IfNullOrWhitespace(name); | ||
| } | ||
|
|
||
| /// <summary>Gets the name to use for the function or parameter.</summary> | ||
| public string Name { get; } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.