ConfigureOptionsChatClient Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A delegating chat client that updates or replaces the ChatOptions 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
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, Func<ChatOptions,ChatOptions>) |
Initializes a new instance of the ConfigureOptionsChatClient class with the specified |
Properties
InnerClient |
Gets the inner IChatClient. (Inherited from DelegatingChatClient) |
Metadata |
Gets metadata that describes the IChatClient. (Inherited from DelegatingChatClient) |
Methods
CompleteAsync(IList<ChatMessage>, ChatOptions, CancellationToken) | |
CompleteStreamingAsync(IList<ChatMessage>, ChatOptions, CancellationToken) | |
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) |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetService<TService>(Object) |
Asks the IChatClient for an object of type |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |