ResponseCachingChatClient Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a new instance of ResponseCachingChatClient that wraps the supplied
originalChatClient
and caches all responses generated using
originalChatClient
in the supplied cache
.
public ResponseCachingChatClient (Microsoft.Extensions.AI.IChatClient originalChatClient, Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, System.Collections.Generic.IEnumerable<string> cachingKeys, System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = default);
new Microsoft.Extensions.AI.Evaluation.Reporting.ResponseCachingChatClient : Microsoft.Extensions.AI.IChatClient * Microsoft.Extensions.Caching.Distributed.IDistributedCache * seq<string> * System.Text.Json.JsonSerializerOptions -> Microsoft.Extensions.AI.Evaluation.Reporting.ResponseCachingChatClient
Public Sub New (originalChatClient As IChatClient, cache As IDistributedCache, cachingKeys As IEnumerable(Of String), Optional jsonSerializerOptions As JsonSerializerOptions = Nothing)
Parameters
- originalChatClient
- IChatClient
The IChatClient that is wrapped.
- cache
- IDistributedCache
The IDistributedCache where the cached responses are stored.
- cachingKeys
- IEnumerable<String>
A collection of unique strings that should be hashed when generating the cache keys for cached AI responses. See CachingKeys for more information about this concept.
- jsonSerializerOptions
- JsonSerializerOptions
The JsonSerializerOptions that should be used when serializing and deserializing responses to and
from the supplied cache
.