Cannot inject custom http client for text to audio and audio to text services using open ai services #9277
-
Semantic kernel allows for open AI chat completion to provide your own HTTP client in the constructor while building the kernel . This is very useful for multi tenant scenarios to better organize http client management.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@giannik - thanks for asking. @RogerBarret0 - can you provide some guidance on why we did this? |
Beta Was this translation helpful? Give feedback.
-
When using To achieve your goal, you need to have a
|
Beta Was this translation helpful? Give feedback.
-
@RogerBarret0 thank you. What if i have injected more httpclients for other purposes or if the service collection comes from my main app and not specific to semantic kernel. Maybe if somehow i could specify with a key that this http client is specific for semantic kernel only ? |
Beta Was this translation helpful? Give feedback.
When using
builder.Services
you are targetingServiceCollection
which is a Dependency Injection focused collection.To achieve your goal, you need to have a
HttpClient
added to your services DI Container so it can be injected automatically in the Connector Services.AddOpenAITextToAudio
code.semantic-kernel/dotnet/src/Connectors/Connectors.OpenAI/Extensions/OpenAIServiceCollectionExtensions.cs
Line 179 in e23d636
HttpClientProvider.GetHttpClient
semantic-kernel/dotnet/src/InternalUtilities/src/Http/HttpClientProvider.cs
Line 39 in e23d636