Simplify and improve AI clients registration and configuration#277
Merged
Conversation
Configuration in behavior pipelines is done by adding decorators in the chain. There's no need to down-cast a particular IChatClient implementation to further configure via an Action (if it were a Func returning a new IChatClient, perhaps?). So we just switch to having the original mechanism which is simpler and avoids overload pollution
Introduces Configure*ClientDefaults extension methods for chat, text-to-speech, and speech-to-text clients, supporting both global and section-specific configuration. Adds new files for defaults registration and validation. Refactors AddClients/AddChatClients to apply defaults and deprecates old configure overloads. Updates tests and documentation to cover new defaults behavior. Includes minor code cleanup and improved argument validation.
Remove obsolete AddChatClients API and consolidate all client registration through AddClients, which now registers both IClientFactory and IChatClient keyed services from configuration. Refactor ConfigurableChatClient to use IClientFactory and introduce ConfigurableClientFactory for dynamic provider resolution and API key inheritance. Move DefaultsApplyingClientFactory to its own file and ensure defaults are applied on every client creation. Update all usages, tests, and documentation to reflect AddClients as the canonical entry point for all client types. Add extension methods for resolving clients by id.
- All client registration is now unified under AddAIClients, which handles both IClientFactory (sections with apikey) and IChatClient (sections with modelid) - AddChatClients is replaced with an error-level [Obsolete] stub (DEAI001) that guides callers to migrate to AddAIClients and ConfigureChatClientDefaults - IClientFactoryResolver and ClientFactoryResolver are made internal — they are implementation details not intended for direct consumption - DefaultsEntry record types move into AIClientDefaultsExtensions, consolidating the defaults model with the methods that register them - SKILL.md provides a Copilot skill with migration guide and usage examples; Devlooped.Extensions.AI.targets copies it to consuming repos on build
Member
Author
🧪 Details on Ubuntu 24.04.4 LTSfrom retest v1.1.0 on .NET 10.0.8 with 💜 by @devlooped |
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.
No description provided.