diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs index 158c560de14..dc8fe9db56f 100644 --- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs +++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs @@ -19,8 +19,18 @@ namespace Microsoft.Extensions.AI; /// A delegating chat client that caches the results of response calls, storing them as JSON in an . /// /// +/// +/// The employs JSON serialization as part of storing cached data. It is not guaranteed that +/// the object models used by , , , , +/// or any of the other objects in the chat client pipeline will roundtrip through JSON serialization with full fidelity. For example, +/// will be ignored, and values in +/// will deserialize as rather than as the original type. In general, code using +/// should only rely on accessing data that can be preserved well enough through JSON serialization and deserialization. +/// +/// /// The provided implementation of is thread-safe for concurrent use so long as the employed /// is similarly thread-safe for concurrent use. +/// /// public class DistributedCachingChatClient : CachingChatClient { diff --git a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClientBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClientBuilderExtensions.cs index 6a9474b751d..0f4f65f8c3a 100644 --- a/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClientBuilderExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClientBuilderExtensions.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Text.Json; using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.DependencyInjection; using Microsoft.Shared.Diagnostics; @@ -23,6 +24,14 @@ public static class DistributedCachingChatClientBuilderExtensions /// An optional callback that can be used to configure the instance. /// The provided as . /// is . + /// + /// The employs JSON serialization as part of storing the cached data. It is not guaranteed that + /// the object models used by , , , , + /// or any of the other objects in the chat client pipeline will roundtrip through JSON serialization with full fidelity. For example, + /// will be ignored, and values in + /// will deserialize as rather than as the original type. In general, code using + /// should only rely on accessing data that can be preserved well enough through JSON serialization and deserialization. + /// public static ChatClientBuilder UseDistributedCache(this ChatClientBuilder builder, IDistributedCache? storage = null, Action? configure = null) { _ = Throw.IfNull(builder);