Compartir a través de


DistributedCachingChatClient Class

Definition

A delegating chat client that caches the results of response calls, storing them as JSON in an IDistributedCache.

public ref class DistributedCachingChatClient : Microsoft::Extensions::AI::CachingChatClient
public class DistributedCachingChatClient : Microsoft.Extensions.AI.CachingChatClient
type DistributedCachingChatClient = class
    inherit CachingChatClient
Public Class DistributedCachingChatClient
Inherits CachingChatClient
Inheritance
DistributedCachingChatClient
Derived

Remarks

The provided implementation of IChatClient is thread-safe for concurrent use so long as the employed IDistributedCache is similarly thread-safe for concurrent use.

Constructors

DistributedCachingChatClient(IChatClient, IDistributedCache)

Initializes a new instance of the DistributedCachingChatClient class.

Properties

CoalesceStreamingUpdates

Gets or sets a value indicating whether streaming updates are coalesced.

(Inherited from CachingChatClient)
InnerClient

Gets the inner IChatClient.

(Inherited from DelegatingChatClient)
JsonSerializerOptions

Gets or sets JSON serialization options to use when serializing cache data.

Methods

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)
GetCacheKey(ReadOnlySpan<Object>)

Computes a cache key for the specified values.

GetResponseAsync(IList<ChatMessage>, ChatOptions, CancellationToken) (Inherited from CachingChatClient)
GetService(Type, Object)

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

(Inherited from DelegatingChatClient)
GetStreamingResponseAsync(IList<ChatMessage>, ChatOptions, CancellationToken) (Inherited from CachingChatClient)
ReadCacheAsync(String, CancellationToken)

Returns a previously cached ChatResponse, if available. This is used when there is a call to GetResponseAsync(IList<ChatMessage>, ChatOptions, CancellationToken).

ReadCacheStreamingAsync(String, CancellationToken)

Returns a previously cached list of ChatResponseUpdate values, if available. This is used when there is a call to GetStreamingResponseAsync(IList<ChatMessage>, ChatOptions, CancellationToken).

WriteCacheAsync(String, ChatResponse, CancellationToken)

Stores a ChatResponse in the underlying cache. This is used when there is a call to GetResponseAsync(IList<ChatMessage>, ChatOptions, CancellationToken).

WriteCacheStreamingAsync(String, IReadOnlyList<ChatResponseUpdate>, CancellationToken)

Stores a list of ChatResponseUpdate values in the underlying cache. This is used when there is a call to GetStreamingResponseAsync(IList<ChatMessage>, ChatOptions, CancellationToken).

Extension Methods

AsBuilder(IChatClient)

Creates a new ChatClientBuilder using innerClient as its inner client.

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.

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.

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

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

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

Applies to