Compartilhar via


ResponseCachingChatClient Class

Definition

An IChatClient that wraps another IChatClient and caches all responses generated using the wrapped IChatClient in the supplied IDistributedCache.

public ref class ResponseCachingChatClient sealed : Microsoft::Extensions::AI::DistributedCachingChatClient
public sealed class ResponseCachingChatClient : Microsoft.Extensions.AI.DistributedCachingChatClient
type ResponseCachingChatClient = class
    inherit DistributedCachingChatClient
Public NotInheritable Class ResponseCachingChatClient
Inherits DistributedCachingChatClient
Inheritance

Constructors

ResponseCachingChatClient(IChatClient, IDistributedCache, IEnumerable<String>, JsonSerializerOptions)

Creates a new instance of ResponseCachingChatClient that wraps the supplied originalChatClient and caches all responses generated using originalChatClient in the supplied cache.

Properties

CoalesceStreamingUpdates

Gets or sets a value indicating whether to coalesce streaming updates.

(Inherited from CachingChatClient)
InnerClient

Gets the inner IChatClient.

(Inherited from DelegatingChatClient)
JsonSerializerOptions

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

(Inherited from DistributedCachingChatClient)
Metadata

Gets metadata that describes the IChatClient.

(Inherited from DelegatingChatClient)

Methods

CompleteAsync(IList<ChatMessage>, ChatOptions, CancellationToken) (Inherited from CachingChatClient)
CompleteStreamingAsync(IList<ChatMessage>, ChatOptions, CancellationToken) (Inherited from CachingChatClient)
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)
Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetCacheKey(ReadOnlySpan<Object>)

Computes a cache key for the specified values.

(Inherited from DistributedCachingChatClient)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetService(Type, Object)

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

(Inherited from DelegatingChatClient)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ReadCacheAsync(String, CancellationToken)

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

(Inherited from DistributedCachingChatClient)
ReadCacheStreamingAsync(String, CancellationToken)

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

(Inherited from DistributedCachingChatClient)
ToString()

Returns a string that represents the current object.

(Inherited from Object)
WriteCacheAsync(String, ChatCompletion, CancellationToken)

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

(Inherited from DistributedCachingChatClient)
WriteCacheStreamingAsync(String, IReadOnlyList<StreamingChatCompletionUpdate>, CancellationToken)

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

(Inherited from DistributedCachingChatClient)

Extension Methods

AsBuilder(IChatClient)

Creates a new ChatClientBuilder using innerClient as its inner client.

CompleteAsync(IChatClient, String, ChatOptions, CancellationToken)

Sends a user chat text message to the model and returns the response messages.

CompleteStreamingAsync(IChatClient, String, ChatOptions, CancellationToken)

Sends a user chat text message to the model and streams the response messages.

GetService<TService>(IChatClient, Object)

Asks the IChatClient for an object of type TService.

CompleteAsync<T>(IChatClient, IList<ChatMessage>, ChatOptions, Nullable<Boolean>, CancellationToken)

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

CompleteAsync<T>(IChatClient, IList<ChatMessage>, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken)

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

CompleteAsync<T>(IChatClient, String, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends a user chat text message to the model, requesting a response matching the type T.

CompleteAsync<T>(IChatClient, String, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends a user chat text message to the model, requesting a response matching the type T.

Applies to