Compartir a través de


ConfigureOptionsChatClient Class

Definition

Represents a delegating chat client that configures a ChatOptions instance used by the remainder of the pipeline.

public ref class ConfigureOptionsChatClient sealed : Microsoft::Extensions::AI::DelegatingChatClient
public sealed class ConfigureOptionsChatClient : Microsoft.Extensions.AI.DelegatingChatClient
type ConfigureOptionsChatClient = class
    inherit DelegatingChatClient
Public NotInheritable Class ConfigureOptionsChatClient
Inherits DelegatingChatClient
Inheritance
ConfigureOptionsChatClient

Remarks

The configuration callback is invoked with the caller-supplied ChatOptions instance. To override the caller-supplied options with a new instance, the callback may simply return that new instance, for example _ => new ChatOptions() { MaxTokens = 1000 }. To provide a new instance only if the caller-supplied instance is null, the callback may conditionally return a new instance, for example options => options ?? new ChatOptions() { MaxTokens = 1000 }. Any changes to the caller-provided options instance will persist on the original instance, so the callback must take care to only do so when such mutations are acceptable, such as by cloning the original instance and mutating the clone, for example: options => { var newOptions = options?.Clone() ?? new(); newOptions.MaxTokens = 1000; return newOptions; }

The callback may return null, in which case a null options will be passed to the next client in the pipeline.

The provided implementation of IChatClient is thread-safe for concurrent use so long as the employed configuration callback is also thread-safe for concurrent requests. If callers employ a shared options instance, care should be taken in the configuration callback, as multiple calls to it may end up running in parallel with the same options instance.

Constructors

ConfigureOptionsChatClient(IChatClient, Action<ChatOptions>)

Initializes a new instance of the ConfigureOptionsChatClient class with the specified configure callback.

Properties

InnerClient

Gets the inner IChatClient.

(Inherited from DelegatingChatClient)

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from DelegatingChatClient)
Dispose(Boolean)

Provides a mechanism for releasing unmanaged resources.

(Inherited from DelegatingChatClient)
GetResponseAsync(IList<ChatMessage>, ChatOptions, CancellationToken)
GetService(Type, Object)

Asks the IChatClient for an object of the specified type serviceType.

(Inherited from DelegatingChatClient)
GetStreamingResponseAsync(IList<ChatMessage>, ChatOptions, CancellationToken)

Extension Methods

AsBuilder(IChatClient)

Creates a new ChatClientBuilder using innerClient as its inner client.

GetResponseAsync(IChatClient, ChatMessage, ChatOptions, CancellationToken)

Sends a chat message and returns the response messages.

GetResponseAsync(IChatClient, String, ChatOptions, CancellationToken)

Sends a user chat text message and returns the response messages.

GetService<TService>(IChatClient, Object)

Asks the IChatClient for an object of type TService.

GetStreamingResponseAsync(IChatClient, ChatMessage, ChatOptions, CancellationToken)

Sends a chat message and streams the response messages.

GetStreamingResponseAsync(IChatClient, String, ChatOptions, CancellationToken)

Sends a user chat text message and streams the response messages.

GetResponseAsync<T>(IChatClient, ChatMessage, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends a chat message, requesting a response matching the type T.

GetResponseAsync<T>(IChatClient, ChatMessage, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends a chat message, requesting a response matching the type T.

GetResponseAsync<T>(IChatClient, IList<ChatMessage>, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends chat messages, requesting a response matching the type T.

GetResponseAsync<T>(IChatClient, IList<ChatMessage>, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends chat messages, requesting a response matching the type T.

GetResponseAsync<T>(IChatClient, String, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends a user chat text message, requesting a response matching the type T.

GetResponseAsync<T>(IChatClient, String, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends a user chat text message, requesting a response matching the type T.

Applies to