FailoverChatClient Class

Definition

Provides a template for a RoutingChatClient that can select another client after an invocation fails.

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

Remarks

The client for each attempt is supplied by SelectClientAsync(RoutingContext, CancellationToken). After an invocation, OnRoutingUpdateAsync(RoutingContext, FailoverChatClientAttempt, Boolean, CancellationToken) reports the concrete attempt and whether another selection will follow. An uncanceled failure causes another selection only when it happened before any streaming output was exposed and the attempt limit permits it.

The base class owns invocation, streaming commitment, attempt limits, and attempt reporting. Derived classes own client selection, policy state, selection-failure cleanup, and the lifetime of clients they retain.

Once streaming enumeration begins, callers must dispose the enumerator. Abandoning an active enumerator without disposing it prevents both inner enumerator disposal and the terminal routing update.

Constructors

Name Description
FailoverChatClient()

Properties

Name Description
MaximumAttemptsPerRequest

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

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)
GetService(Type, Object)

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

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

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

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