FunctionInvokingChatClient class

A delegating chat client that automatically invokes functions requested by the model.

When the model responds with function call requests, this client invokes the corresponding AIFunction tools and feeds the results back to the model, repeating until the model produces a final response or the maximum number of iterations is reached.

Inheritance
Available extensions

Constructors

FunctionInvokingChatClient(ChatClient innerClient, {Logger? logger})
Creates a new FunctionInvokingChatClient.

Properties

additionalTools List<AITool>?
Additional tools available for function invocation beyond those specified in ChatOptions.tools.
getter/setter pair
allowConcurrentInvocation bool
Whether to allow concurrent invocation of multiple function calls.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
includeDetailedErrors bool
Whether to include detailed error information in function results sent to the model.
getter/setter pair
innerClient ChatClient
The inner client to delegate to.
finalinherited
logger Logger?
An optional logger for diagnostic output.
final
maximumConsecutiveErrorsPerRequest int
The maximum number of consecutive errors before stopping.
getter/setter pair
maximumIterationsPerRequest int
The maximum number of roundtrips per request.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
terminateOnUnknownCalls bool
Whether to terminate when a function call references an unknown tool.
getter/setter pair

Methods

dispose() → void
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
inherited
getChatResponse({required Iterable<ChatMessage> messages, ChatOptions? options, CancellationToken? cancellationToken}) Future<ChatResponse>
Sends a chat request and returns the complete response.
override
getChatResponseFromMessage(ChatMessage message, {ChatOptions? options, CancellationToken? cancellationToken}) Future<ChatResponse>

Available on ChatClient, provided by the ChatClientExtensions extension

Sends a single message and returns the response.
getChatResponseFromText(String message, {ChatOptions? options, CancellationToken? cancellationToken}) Future<ChatResponse>

Available on ChatClient, provided by the ChatClientExtensions extension

Sends a single user text message and returns the response.
getService<T>({Object? key}) → T?
Gets a service of the specified type.
inherited
getStreamingChatResponse({required Iterable<ChatMessage> messages, ChatOptions? options, CancellationToken? cancellationToken}) Stream<ChatResponseUpdate>
Sends a chat request and returns a stream of response updates.
override
getStreamingChatResponseFromMessage(ChatMessage message, {ChatOptions? options, CancellationToken? cancellationToken}) Stream<ChatResponseUpdate>

Available on ChatClient, provided by the ChatClientExtensions extension

Sends a single message and returns a streaming response.
getStreamingChatResponseFromText(String message, {ChatOptions? options, CancellationToken? cancellationToken}) Stream<ChatResponseUpdate>

Available on ChatClient, provided by the ChatClientExtensions extension

Sends a single user text message and returns a streaming response.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited