OrderedFailoverChatClient class final
Provides ordered failover across a sequence of chat clients.
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.
Upstream marks the ChatRouting family [Experimental]; the surface
may change as upstream stabilizes.
- Inheritance
-
- Object
- RoutingChatClient
- FailoverChatClient
- OrderedFailoverChatClient
- Available extensions
- Annotations
-
- @Source(name: 'OrderedFailoverChatClient.cs', namespace: 'Microsoft.Extensions.AI', repository: 'dotnet/extensions', path: 'src/Libraries/Microsoft.Extensions.AI/ChatRouting/')
Constructors
-
OrderedFailoverChatClient(List<
ChatClient> clients, {bool leaveOpen = false}) -
Creates a new OrderedFailoverChatClient over
clients, in fallback order.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- maximumAttemptsPerRequest ↔ int?
-
The maximum number of client invocations permitted for one request.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asBuilder(
) → ChatClientBuilder -
Available on ChatClient, provided by the ChatClientBuilderChatClientExtensions extension
Creates a new ChatClientBuilder usinginnerClientas its inner client. -
dispose(
) → void -
Performs application-defined tasks associated with freeing, releasing,
or resetting unmanaged resources.
override
-
getChatResponseFromMessage(
ChatMessage message, {ChatOptions? options, CancellationToken? cancellationToken}) → Future< ChatResponse> -
Available on ChatClient, provided by the ChatClientExtensions extension
Sends a single message and returns the response. -
getChatResponseFromText(
String message, {ChatOptions? options, CancellationToken? cancellationToken}) → Future< ChatResponse> -
Available on ChatClient, provided by the ChatClientExtensions extension
Sends a single user text message and returns the response. -
getResponse(
{required Iterable< ChatMessage> messages, ChatOptions? options, CancellationToken? cancellationToken}) → Future<ChatResponse> -
Sends a chat request and returns the complete response.
inherited
-
getService<
T> ({Object? key}) → T? -
Gets a service of the specified type.
inherited
-
getStreamingChatResponseFromMessage(
ChatMessage message, {ChatOptions? options, CancellationToken? cancellationToken}) → Stream< ChatResponseUpdate> -
Available on ChatClient, provided by the ChatClientExtensions extension
Sends a single message and returns a streaming response. -
getStreamingChatResponseFromText(
String message, {ChatOptions? options, CancellationToken? cancellationToken}) → Stream< ChatResponseUpdate> -
Available on ChatClient, provided by the ChatClientExtensions extension
Sends a single user text message and returns a streaming response. -
getStreamingResponse(
{required Iterable< ChatMessage> messages, ChatOptions? options, CancellationToken? cancellationToken}) → Stream<ChatResponseUpdate> -
Sends a chat request and returns a stream of response updates.
inherited
-
getStructuredResponse<
T> ({required Iterable< ChatMessage> messages, required Map<String, dynamic> schema, required StructuredResultFromJson<T> fromJson, String? schemaName, String? schemaDescription, ChatOptions? options, bool? useJsonSchemaResponseFormat, CancellationToken? cancellationToken}) → Future<StructuredChatResponse< T> > -
Available on ChatClient, provided by the ChatClientStructuredOutputExtensions extension
Sends chat messages, requesting a response matchingschemaand deserialized viafromJson. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onRoutingUpdate(
RoutingContext context, FailoverChatClientAttempt attempt, {required bool isTerminal, CancellationToken? cancellationToken}) → Future< void> -
Invoked after a client invocation completes, fails, or is abandoned.
override
-
selectClient(
RoutingContext context, CancellationToken? cancellationToken) → Future< ChatClient> -
Selects the client to invoke for the request.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited