Documentation
Table of Contents

Method AsAIFunction

Namespace
IntentSharp.Extensions.AI
Assembly
IntentSharp.Extensions.AI.dll

AsAIFunction(IntentRuntime, string, string?, ILogger?)

A tool that runs the named intent through RunAsync(string, object?, CancellationToken).

public static AIFunction AsAIFunction(this IntentRuntime runtime, string name, string? toolName = null, ILogger? logger = null)

Parameters

runtime IntentRuntime

The intent runtime.

name string

The intent name. Must exist when the tool is created.

toolName string

The tool name to use instead of the one derived from name (see ToToolName(string)): 1 to MaxToolNameLength characters from A-Z a-z 0-9 _ -.

logger ILogger

Optional logger for exceptions the tool answers with success: false (logged at Warning).

Returns

AIFunction

Exceptions

ArgumentNullException

runtime or name is null.

ArgumentException

name is empty or white space, toolName is not a valid tool name, or the tool name derived from name is longer than MaxToolNameLength characters.

IntentNotFoundException

The runtime's catalog has no intent with that name.

AsAIFunction(IIntentInvoker, string, string?, ILogger?)

A tool that runs the named intent.

public static AIFunction AsAIFunction(this IIntentInvoker invoker, string name, string? toolName = null, ILogger? logger = null)

Parameters

invoker IIntentInvoker

The intent runner.

name string

The intent name. Must exist when the tool is created: whatever Describe(string) throws for an unknown name propagates.

toolName string

The tool name to use instead of the one derived from name (see ToToolName(string)): 1 to MaxToolNameLength characters from A-Z a-z 0-9 _ -.

logger ILogger

Optional logger for exceptions the tool answers with success: false (logged at Warning).

Returns

AIFunction

Exceptions

ArgumentNullException

invoker or name is null.

ArgumentException

name is empty or white space, toolName is not a valid tool name, or the tool name derived from name is longer than MaxToolNameLength characters.