New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some clean up in OpenAIClientBase #788
Merged
Merged
Conversation
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
- 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.
github-actions
bot
added
.NET
Issue or Pull requests regarding .NET code
kernel
Issues or pull requests impacting the core kernel
labels
May 3, 2023
lemillermicrosoft
previously approved these changes
May 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lemillermicrosoft
added
the
PR: ready to merge
PR has been approved by all reviewers, and is ready to merge.
label
May 3, 2023
dluc
reviewed
May 3, 2023
dotnet/src/Connectors/Connectors.AI.OpenAI/ImageGeneration/OpenAIImageGeneration.cs
Show resolved
Hide resolved
shawncal
reviewed
May 4, 2023
dotnet/src/Connectors/Connectors.AI.OpenAI/ImageGeneration/OpenAIImageGeneration.cs
Outdated
Show resolved
Hide resolved
shawncal
approved these changes
May 4, 2023
codebrain
pushed a commit
to searchpioneer/semantic-kernel
that referenced
this pull request
May 16, 2023
### 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.
dehoward
pushed a commit
to lemillermicrosoft/semantic-kernel
that referenced
this pull request
Jun 1, 2023
### 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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kernel
Issues or pull requests impacting the core kernel
.NET
Issue or Pull requests regarding .NET code
PR: ready to merge
PR has been approved by all reviewers, and is ready to merge.
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.
Motivation and Context
Fix some possible functional issues as well as remove unnecessary code.
Description
Contribution Checklist
dotnet format