semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Http client consistency

Open SergeyMenshykh opened this issue 2 years ago • 0 comments

Motivation, Context and Description

This PR introduces the following changes:

  1. 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.

  2. 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.

  3. 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:

SergeyMenshykh avatar May 22 '23 18:05 SergeyMenshykh