* Expose a schema transformer on AIJsonSchemaCreateOptions.
* Address feedback
* Disable caching if a transformer is specified.
* Remove `FilterDisallowedKeywords`.
* Document caching.
* Apply suggestions from code review
- The non-streaming path explicitly throws if the response contains multiple choices. The streaming path wasn't doing the same and was instead silently producing bad results.
- The streaming path was yielding function call content _and_ adding them to the chat history. It should only have been doing the latter.
This fixes both issues. We also had close to zero test coverage in our FunctionInvocationChatClient tests for streaming, only for non-streaming. This also fixes that.
It's already yielded during streaming, but it's not being surfaced for non-streaming. Do so by manufacturing a new UsageContent for the UsageDetails and adding that to the response message that's added to the history.
* Add ToBuilder extensions for IChatClient and IEmbeddingGenerator
Enables a fluent style of construction of a pipeline from a client/generator, and not having to specify the generic type parameters for the embedding generator builder.
* Rename ToBuilder to AsBuilder
* Remove duplicate GetCacheKey methods
Consolidate to only the `ReadOnlySpan<object>`-based method.
* Update XML comments to say that the values are serialized
* Change ChatClientBuilder to register singletons and support lambda-less chaining
* Add generic keyed version
* Improve XML doc
* Update README files
* Remove generic DI registration methods
* Rework cache key handling in caching client / generator
- Expose the default cache key helper so that customization doesn't require re-implementing the whole thing.
- Make it easy to incorporate additional state into the cache key.
- Avoid serializing all of the values for the key into a new byte[], at least on .NET 8+. There, we can serialize directly into a stream that targets an IncrementalHash.
- Include Chat/EmbeddingGenerationOptions in the cache key by default.
* Update test/Libraries/Microsoft.Extensions.AI.Tests/Embeddings/DistributedCachingEmbeddingGeneratorTest.cs
Co-authored-by: Shyam N <shyamnamboodiripad@users.noreply.github.com>
---------
Co-authored-by: Shyam N <shyamnamboodiripad@users.noreply.github.com>
* Tweak ChatMessage/StreamingChatCompletionUpdate.ToString
Include all text rather than just the first text content.
* Address PR feedback and fix / add tests
* Use ToChatCompletion / ToStreamingChatCompletionUpdates in CachingChatClient
Adds a ToStreamingChatCompletionUpdates method that's the counterpart to the recently added ToChatCompletion.
Then uses both from CachingChatClient instead of its now bespoke coalescing implementation. When coalescing is enabled (the default), CachingChatClient caches everything as a ChatCompletion, rather than distinguishing streaming and non-streaming.
* Address PR feedback
* Update README to include a section on UseChatOptions
* Rework UseChat/EmbeddingGenerationOptions to always clone
The callbacks now configure the supplied instance.
* Improve JsonSchemaExporter trimmer safety.
* Remove var
* Address feedback.
* Remove DynamicallyAccessedMemberTypes.All
* Extract reflection helpers into separate file and remove a number of warning suppressions.
* Re-enable failing tests that were patched in .NET 9
* Plug JsonSchemaExporter test data to the AIJsonUtilities tests
* Update src/LegacySupport/DiagnosticAttributes/README.md
* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.cs
* Address feedback.