次の方法で共有


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>)

Initializes a new instance of the ResponseCachingChatClient class 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 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.

(Inherited from DistributedCachingChatClient)

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.

(Inherited from DistributedCachingChatClient)
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).

(Inherited from DistributedCachingChatClient)
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).

(Inherited from DistributedCachingChatClient)
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).

(Inherited from DistributedCachingChatClient)
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).

(Inherited from DistributedCachingChatClient)

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