3 types derived from AIFunctionDeclaration
Microsoft.Extensions.AI.Abstractions (3)
Functions\AIFunction.cs (1)
12
public abstract class AIFunction :
AIFunctionDeclaration
Functions\AIFunctionFactory.cs (1)
523
AIFunctionDeclaration
Functions\DelegatingAIFunctionDeclaration.cs (1)
14
internal class DelegatingAIFunctionDeclaration :
AIFunctionDeclaration
// could be made public in the future if there's demand
92 references to AIFunctionDeclaration
Microsoft.Extensions.AI (10)
ChatCompletion\FunctionInvokingChatClient.cs (5)
37
/// If a requested function is an <see cref="
AIFunctionDeclaration
"/> but not an <see cref="AIFunction"/>, the
826
private static
AIFunctionDeclaration
? FindTool(string name, params ReadOnlySpan<IList<AITool>?> toolLists)
834
if (tool is
AIFunctionDeclaration
declaration && string.Equals(tool.Name, name, StringComparison.Ordinal))
1066
if (tool is not
AIFunctionDeclaration
)
1120
AIFunctionDeclaration
? tool = FindTool(fcc.Name, options?.Tools, AdditionalTools);
Common\OtelMessageParts.cs (1)
100
if (tool.GetService<
AIFunctionDeclaration
>() is { } function)
Realtime\FunctionInvokingRealtimeClientSession.cs (4)
36
/// If a requested function is an <see cref="
AIFunctionDeclaration
"/> but not an <see cref="AIFunction"/>, the
232
private static
AIFunctionDeclaration
? FindTool(string name, params ReadOnlySpan<IEnumerable<AITool>?> toolLists)
240
if (tool is
AIFunctionDeclaration
declaration && string.Equals(tool.Name, name, StringComparison.Ordinal))
296
AIFunctionDeclaration
? tool = FindTool(fcc.Name, AdditionalTools, _innerSession.Options?.Tools);
Microsoft.Extensions.AI.Abstractions (36)
Functions\AIFunction.cs (3)
47
/// <summary>Creates a <see cref="
AIFunctionDeclaration
"/> representation of this <see cref="AIFunction"/> that can't be invoked.</summary>
50
/// <see cref="AIFunction"/> derives from <see cref="
AIFunctionDeclaration
"/>, layering on the ability to invoke the function in addition
53
public
AIFunctionDeclaration
AsDeclarationOnly() => new NonInvocableAIFunction(this);
Functions\AIFunctionDeclaration.cs (3)
11
/// <see cref="
AIFunctionDeclaration
"/> is the base class for <see cref="AIFunction"/>, which
13
/// for <see cref="
AIFunctionDeclaration
"/> to determine whether they can be described as functions,
18
/// <summary>Initializes a new instance of the <see cref="
AIFunctionDeclaration
"/> class.</summary>
Functions\AIFunctionFactory.cs (17)
35
/// automatically derived for both the function's input parameters (exposed via <see cref="
AIFunctionDeclaration
.JsonSchema"/>)
36
/// and, by default, the function's return type (exposed via <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/>).
62
/// <see cref="
AIFunctionDeclaration
.JsonSchema"/>. There are a few exceptions to this:
118
/// returned <see cref="AIFunction"/>'s <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/>. For methods returning
151
/// <see cref="
AIFunctionDeclaration
.JsonSchema"/>. There are a few exceptions to this:
195
/// A JSON schema is also derived from the method's return type and exposed via <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/>.
233
/// <see cref="
AIFunctionDeclaration
.JsonSchema"/>. There are a few exceptions to this:
287
/// returned <see cref="AIFunction"/>'s <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/>. For methods returning
330
/// <see cref="
AIFunctionDeclaration
.JsonSchema"/>. There are a few exceptions to this:
374
/// A JSON schema is also derived from the method's return type and exposed via <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/>.
425
/// <see cref="
AIFunctionDeclaration
.JsonSchema"/>. There are a few exceptions to this:
479
/// returned <see cref="AIFunction"/>'s <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/>. For methods returning
498
/// <summary>Creates an <see cref="
AIFunctionDeclaration
"/> using the specified parameters as the implementation of its corresponding properties.</summary>
503
/// <returns>The created <see cref="
AIFunctionDeclaration
"/> that describes a function.</returns>
506
/// <see cref="CreateDeclaration"/> creates an <see cref="
AIFunctionDeclaration
"/> that can be used to describe a function
507
/// but not invoke it. To create an invocable <see cref="AIFunction"/>, use Create. A non-invocable <see cref="
AIFunctionDeclaration
"/>
510
public static
AIFunctionDeclaration
CreateDeclaration(
Functions\AIFunctionFactoryOptions.cs (4)
46
/// This setting affects both the <see cref="
AIFunctionDeclaration
.JsonSchema"/> (input parameters) and
47
/// the <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/> (return type).
126
/// via <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/> when the method has a return type other than
130
/// When set to <see langword="true"/>, the produced <see cref="
AIFunctionDeclaration
.ReturnJsonSchema"/> will always be <see langword="null"/>.
Functions\DelegatingAIFunctionDeclaration.cs (4)
12
/// Provides an optional base class for an <see cref="
AIFunctionDeclaration
"/> that passes through calls to another instance.
21
protected DelegatingAIFunctionDeclaration(
AIFunctionDeclaration
innerFunction)
26
/// <summary>Gets the inner <see cref="
AIFunctionDeclaration
" />.</summary>
27
protected
AIFunctionDeclaration
InnerFunction { get; }
Utilities\AIJsonSchemaTransformCache.cs (5)
26
private readonly ConditionalWeakTable<
AIFunctionDeclaration
, object> _functionSchemaCache = new();
29
private readonly ConditionalWeakTable<
AIFunctionDeclaration
, object>.CreateValueCallback _functionSchemaCreateValueCallback;
62
GetOrCreateTransformedSchema((
AIFunctionDeclaration
)function);
65
/// Gets or creates a transformed JSON schema for the specified <see cref="
AIFunctionDeclaration
"/> instance.
69
public JsonElement GetOrCreateTransformedSchema(
AIFunctionDeclaration
function)
Microsoft.Extensions.AI.Evaluation.Quality (17)
AIToolExtensions.cs (2)
22
foreach (
AIFunctionDeclaration
function in toolDefinitions.OfType<
AIFunctionDeclaration
>())
IntentResolutionEvaluator.cs (1)
28
/// defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
IntentResolutionEvaluatorContext.cs (4)
22
/// defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
39
/// are defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions will be ignored.
58
/// are defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions will be ignored.
84
/// are defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
TaskAdherenceEvaluator.cs (1)
27
/// defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
TaskAdherenceEvaluatorContext.cs (4)
23
/// defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
40
/// are defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions will be ignored.
59
/// are defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions will be ignored.
86
/// defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
ToolCallAccuracyEvaluator.cs (1)
28
/// defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
ToolCallAccuracyEvaluatorContext.cs (4)
24
/// defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
41
/// are defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions will be ignored.
60
/// are defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions will be ignored.
88
/// are defined as <see cref="
AIFunctionDeclaration
"/>s. Any other <see cref="AITool"/> definitions that are supplied via
Microsoft.Extensions.AI.OpenAI (18)
MicrosoftExtensionsAIAssistantsExtensions.cs (2)
16
/// <summary>Creates an OpenAI <see cref="FunctionToolDefinition"/> from an <see cref="
AIFunctionDeclaration
"/>.</summary>
20
public static FunctionToolDefinition AsOpenAIAssistantsFunctionToolDefinition(this
AIFunctionDeclaration
function) =>
MicrosoftExtensionsAIChatExtensions.cs (2)
24
/// <summary>Creates an OpenAI <see cref="ChatTool"/> from an <see cref="
AIFunctionDeclaration
"/>.</summary>
28
public static ChatTool AsOpenAIChatTool(this
AIFunctionDeclaration
function) =>
MicrosoftExtensionsAIRealtimeExtensions.cs (2)
16
/// <summary>Creates an OpenAI <see cref="RealtimeFunctionTool"/> from an <see cref="
AIFunctionDeclaration
"/>.</summary>
20
public static RealtimeFunctionTool AsOpenAIRealtimeFunctionTool(this
AIFunctionDeclaration
function) =>
MicrosoftExtensionsAIResponsesExtensions.cs (2)
20
/// <summary>Creates an OpenAI <see cref="ResponseTool"/> from an <see cref="
AIFunctionDeclaration
"/>.</summary>
24
public static FunctionTool AsOpenAIResponseTool(this
AIFunctionDeclaration
function) =>
OpenAIAssistantsChatClient.cs (2)
323
internal static FunctionToolDefinition ToOpenAIAssistantsFunctionToolDefinition(
AIFunctionDeclaration
aiFunction, ChatOptions? options = null)
384
case
AIFunctionDeclaration
aiFunction:
OpenAIChatClient.cs (2)
136
internal static ChatTool ToOpenAIChatTool(
AIFunctionDeclaration
aiFunction, ChatOptions? options = null)
639
case
AIFunctionDeclaration
af:
OpenAIClientExtensions.cs (2)
239
/// <summary>Extracts from an <see cref="
AIFunctionDeclaration
"/> the parameters and strictness setting for use with OpenAI's APIs.</summary>
240
internal static BinaryData ToOpenAIFunctionParameters(
AIFunctionDeclaration
aiFunction, bool? strict)
OpenAIRealtimeConversationClient.cs (1)
14
public static RealtimeFunctionTool ToOpenAIRealtimeFunctionTool(
AIFunctionDeclaration
aiFunction, ChatOptions? options = null)
OpenAIResponsesChatClient.cs (3)
731
case
AIFunctionDeclaration
aiFunction:
867
internal static FunctionTool ToResponseTool(
AIFunctionDeclaration
aiFunction, ChatOptions? options = null)
1128
AIFunctionDeclaration
aiFunction => aiFunction.Name,
Microsoft.Extensions.AI.OpenAI.Tests (5)
OpenAIConversionTests.cs (3)
122
var
function = AIFunctionFactory.CreateDeclaration(
160
var
functionWithDefs = AIFunctionFactory.CreateDeclaration(
213
var
function = AIFunctionFactory.CreateDeclaration(
OpenAIResponseClientTests.cs (2)
8834
var
tool = AIFunctionFactory.CreateDeclaration("TagResource", "Tags a resource with key-value labels.", JsonDocument.Parse(ExplicitSchema).RootElement);
8927
var
tool = AIFunctionFactory.CreateDeclaration("TagResource", "Tags a resource with key-value labels.", JsonDocument.Parse(ExplicitSchema).RootElement);
Microsoft.Extensions.AI.Tests (6)
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
1573
var
declarationOnly = AIFunctionFactory.Create(() => "unused", "DefOnly").AsDeclarationOnly();
1599
var
defOnly = AIFunctionFactory.Create(() => "unused", "DefOnly").AsDeclarationOnly();
3279
var
declarationOnly = AIFunctionFactory.Create(() => "Result 1", "Func1").AsDeclarationOnly();
Functions\AIFunctionFactoryTest.cs (2)
344
AIFunctionDeclaration
declaration = func.AsDeclarationOnly();
1306
AIFunctionDeclaration
f = AIFunctionFactory.CreateDeclaration("something", "amazing", schema);
Realtime\FunctionInvokingRealtimeClientTests.cs (1)
594
var
declaration = AIFunctionFactory.CreateDeclaration("my_declaration", "A non-invocable tool", schema);