Add Builder argument to IAIClientFactory methods - #103
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces new overloads to the
IAIClientFactoryinterface that allow callers to configure the builder pipeline for AI clients (chat, embeddings, image generation, speech-to-text, and text-to-speech) before the factory builds the final client. This enables middleware such asUseDefaultResilience()to be applied during client creation, making it easier to add resilience and other behaviors. The documentation and changelogs have been updated to reflect these new patterns, providing clear examples for both the new and existing approaches.API Enhancements:
IAIClientFactoryfor all major AI client types (IChatClient,IEmbeddingGenerator,IImageGenerator,ISpeechToTextClient,ITextToSpeechClient) that accept a builder-configuration delegate, allowing middleware (like resilience policies) to be applied before building the client. [1] [2] [3] [4] [5]Documentation Updates:
ai-core.md,ai-resilience.md, andgetting-started-aspnet.mdto show how to use the newIAIClientFactoryoverloads for configuring resilience and other middleware, including code examples and guidance on when to use each approach. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Changelog and Package References:
Microsoft.Extensions.AIin the project file to support the new builder extensions.These changes make it easier and more consistent to apply cross-cutting concerns like resilience to AI clients, whether you are using the factory or building clients manually.