OrderedFailoverChatClient Class

Definition

Provides ordered failover across a sequence of chat clients.

public ref class OrderedFailoverChatClient sealed : Microsoft::Extensions::AI::FailoverChatClient
[System.Diagnostics.CodeAnalysis.Experimental("MEAI001", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")]
public sealed class OrderedFailoverChatClient : Microsoft.Extensions.AI.FailoverChatClient
[<System.Diagnostics.CodeAnalysis.Experimental("MEAI001", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")>]
type OrderedFailoverChatClient = class
    inherit FailoverChatClient
Public NotInheritable Class OrderedFailoverChatClient
Inherits FailoverChatClient
Inheritance
OrderedFailoverChatClient
Attributes

Remarks

The clients are tried in order. An invocation failure before streaming output is exposed advances to the next client. Cancellation and failures after streaming output is exposed are propagated without failover.

The configured clients are snapshotted by the constructor. The same client may appear more than once, in which case it is invoked once per position. When every client has failed, the final failure is rethrown.

Constructors

Name Description
OrderedFailoverChatClient(IReadOnlyList<IChatClient>, Boolean)

Initializes a new instance of the OrderedFailoverChatClient class.

Properties

Name Description
MaximumAttemptsPerRequest

Gets or sets the maximum number of client invocations permitted for one request.

(Inherited from FailoverChatClient)

Methods

Name Description
Dispose()

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

(Inherited from RoutingChatClient)
Dispose(Boolean)

Provides a mechanism for releasing resources owned by the derived instance.

(Inherited from RoutingChatClient)
GetResponseAsync(IEnumerable<ChatMessage>, ChatOptions, CancellationToken) (Inherited from FailoverChatClient)
GetService(Type, Object)

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

(Inherited from RoutingChatClient)
GetStreamingResponseAsync(IEnumerable<ChatMessage>, ChatOptions, CancellationToken) (Inherited from FailoverChatClient)
OnRoutingUpdateAsync(RoutingContext, FailoverChatClientAttempt, Boolean, CancellationToken)

Invoked after a client invocation completes, fails, or is abandoned.

(Inherited from FailoverChatClient)
SelectClientAsync(RoutingContext, CancellationToken)

Selects the client to invoke for the request.

(Inherited from RoutingChatClient)

Extension Methods

Name Description
AsBuilder(IChatClient)

Creates a new ChatClientBuilder using innerClient as its inner client.

GetRequiredService(IChatClient, Type, Object)

Asks the IChatClient for an object of the specified type serviceType and throws an exception if one isn't available.

GetRequiredService<TService>(IChatClient, Object)

Asks the IChatClient for an object of type TService and throws an exception if one isn't available.

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.

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, IEnumerable<ChatMessage>, ChatOptions, Nullable<Boolean>, CancellationToken)

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

GetResponseAsync<T>(IChatClient, IEnumerable<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.

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.

Applies to