Skip to content
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

.Net: Allow HttpClient to be passed in for AzureOpenAI when building from s… #10703

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

strtdusty
Copy link

@strtdusty strtdusty commented Feb 27, 2025

Allow HttpClient to be passed in for AzureOpenAI when building from service collection, just like it is from the Kernel Builder

Motivation and Context

Description

Add an optional HTTPClient to the extension methods and utilize it just like the kernel builder versions. Note that I don't think this is the proper way to handle things. It would likely be better to allow an optional client name to be sent in and then SK could/should use the client factory to fetch it. However, my change makes the interface consistent with what is already there.

Contribution Checklist

@strtdusty strtdusty requested a review from a team as a code owner February 27, 2025 00:27
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Feb 27, 2025
@github-actions github-actions bot changed the title Allow HttpClient to be passed in for AzureOpenAI when building from s… .Net: Allow HttpClient to be passed in for AzureOpenAI when building from s… Feb 27, 2025
@strtdusty
Copy link
Author

Note: I ran the build.cmd and it did flag API compatibility issues for the extension methods I am adding new optional parameters to. I could understand how this would create a binary incompatibility but I thought clients would get a new nuget package and rebuild? If this is a real incompatibility I could use some advice on fixing. I can't go the method overload route because the new and old method become ambiguous if the last parameter is not provided.

@strtdusty
Copy link
Author

@microsoft-github-policy-service agree

@RogerBarreto
Copy link
Member

RogerBarreto commented Feb 28, 2025

@strtdusty Thanks for the contribution. This is welcomed, could you please add Unit Tests ensuring the behavior of the httpClient picking the one in the extension method and not the one in the IServiceColletion ?

I am adding new optional parameters to

That's fine, since you are adding the parameter to the end of the method, it is flagged as incompatibility but for a very niche scenario.

Regarding the ApiCompatibility you need to install the tool to generate the file automatically.

dotnet tool install --global Microsoft.DotNet.ApiCompat.Tool

Use the command below in the solution folder to generate the suppression file:

dotnet build -c Release /p:ApiCompatGenerateSuppressionFile=true

Thanks!

@strtdusty
Copy link
Author

Tests updated, build passing locally with the API suppressions @RogerBarreto

@strtdusty
Copy link
Author

Comments/test resolved

@strtdusty
Copy link
Author

@RogerBarreto comments resolved. I think the PR is ready now.

@RogerBarreto
Copy link
Member

For some obscure reason this PR says the maintainer allows edit the PR but I'm unable to help.

image

Getting

error: Authentication error: Authentication required: You must have push access to verify locks
error: failed to push some refs to 'https://github.com/strtdusty/semantic-kernel.git'

Anyways, update the order of the usings in the file test, and LGTM.

@strtdusty
Copy link
Author

For some obscure reason this PR says the maintainer allows edit the PR but I'm unable to help.

image

Getting

error: Authentication error: Authentication required: You must have push access to verify locks
error: failed to push some refs to 'https://github.com/strtdusty/semantic-kernel.git'

Anyways, update the order of the usings in the file test, and LGTM.

@RogerBarreto it looks like your commit made it in to the PR so the usings are ordered.

@RogerBarreto
Copy link
Member

RogerBarreto commented Mar 7, 2025

I did through the github IDE but unfortunately doing this changed the encoding of the file, I will need you to pull the changes and save with the proper encoding and push a new commit

@strtdusty
Copy link
Author

I did through the github IDE but unfortunately doing this changed the encoding of the file, I will need you to pull the changes and save with the proper encoding and push a new commit

Done

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants