Http client consistency
Motivation, Context and Description
This PR introduces the following changes:
-
Reuse of globally configured policies and handlers: The AzureOpenAI, OpenAI, and custom connectors now use the globally configured policies and handlers provided with the custom HttpClient, eliminating the need for connector-specific implementations. This change improves consistency and allows reuse of globally configured settings.
-
Mandatory HttpClient parameter: HttpClient is now a mandatory parameter for AzureOpenAI, OpenAI, and custom connectors. This removes the responsibility of connectors to create their own HttpClients and manage(dispose) their lifetime, simplifying the code and promoting centralized HttpClient management.
-
To minimize the number of handlers utilized by the SK SDK, all AzureOpenAI, OpenAI, and custom connectors have been configured to reuse the same instance of HttpClientHandler.
Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [x] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with
dotnet format - [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone :smile: