RoutingChatClient 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.
Provides a template for an IChatClient that selects and invokes another chat client.
public ref class RoutingChatClient abstract : IDisposable, Microsoft::Extensions::AI::IChatClient
[System.Diagnostics.CodeAnalysis.Experimental("MEAI001", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")]
public abstract class RoutingChatClient : IDisposable, Microsoft.Extensions.AI.IChatClient
[<System.Diagnostics.CodeAnalysis.Experimental("MEAI001", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")>]
type RoutingChatClient = class
interface IChatClient
interface IDisposable
Public MustInherit Class RoutingChatClient
Implements IChatClient, IDisposable
- Inheritance
-
RoutingChatClient
- Derived
- Attributes
- Implements
Remarks
Derived classes implement SelectClientAsync(RoutingContext, CancellationToken) to supply one client for each request. The selected client is invoked once, and its response or failure is propagated to the caller. The exact client instance represents the selected routing identity. Caller-supplied options may vary per invocation, but they are ephemeral and do not participate in that identity. Applications can use distinct configured client wrappers when configurations require distinct routing identities, while custom policies may maintain separate application-specific grouping keys.
ChatOptions holds the options for the request and is what the selected client receives. Options that belong to a particular route are configured on the client instead, typically with a ConfigureOptionsChatClient wrapper, which clones the request options and applies the route's own values on top of them.
Constructors
| Name | Description |
|---|---|
| RoutingChatClient() | |
Methods
| Name | Description |
|---|---|
| Create(Func<RoutingContext,CancellationToken,ValueTask<IChatClient>>) |
Creates a routing client that selects one client for each request. |
| Dispose() |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
| Dispose(Boolean) |
Provides a mechanism for releasing resources owned by the derived instance. |
| GetResponseAsync(IEnumerable<ChatMessage>, ChatOptions, CancellationToken) |
Sends chat messages and returns the response. |
| GetService(Type, Object) |
Asks the IChatClient for an object of the specified type |
| GetStreamingResponseAsync(IEnumerable<ChatMessage>, ChatOptions, CancellationToken) |
Sends chat messages and streams the response. |
| SelectClientAsync(RoutingContext, CancellationToken) |
Selects the client to invoke for the request. |