forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some clean up in OpenAIClientBase (microsoft#788)
### Motivation and Context Fix some possible functional issues as well as remove unnecessary code. ### Description - The type accepts an HttpClient instance that it'll use. It shouldn't then mutate that instance, as it might be shared with other consumers. But it's adding to its DefaultRequestHeaders collection, which will impact all other users of that instance (DefaultRequestHeaders also isn't thread-safe and should only ever be added to while it's not being used for issuing requests). I've removed the interaction with DefaultRequestHeaders and instead added the relevant headers to each message being sent. - The base is exposing a lot of protected surface area, but it's not actually extensible outside of the assembly. I've changed all of its internal and protected members to instead be "private protected" or just "private", reflecting their actual usage and ensuring the surface area doesn't show up in public documentation (which protected members would). - As it's not actually extensible publicly, and as no derived types are finalizable, it needn't implement the full IDisposable pattern nor use GC.SuppressFinalize. - Both the base and the derived image generation client had duplicated APIs for url vs base64 image generation. I've consolidated that via arguments to just have one copy of the code. Note that the base64 image generation was private and unused, so I've deleted that unused member, but the functionality can be exposed easily if desired based on the shared routines now in place. - Removed some unnecessary null checking for things that'll never be null. - Ensured the HttpClient response message is disposed.
- Loading branch information
1 parent
28ebe5e
commit 51ceae9
Showing
2 changed files
with
111 additions
and
158 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.