-
Notifications
You must be signed in to change notification settings - Fork 184
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
Allow for custom Ktor HttpClientPlugin installations #238
Comments
I've been trying to keep Ktor as an implementation detail, but I've been seeing more requests to configure the client. So, why not? Solution 2 looks good to me! |
Completely understand your thought process there. |
Version 3.4.2 is released with your changes! thanks again for your contribution! 🎉 |
Thank you again! |
Feature Description
Allow for OpenAI HttpClient to install custom Ktor HttptClientPlugins.
Problem it Solves
Our team has custom plugins that upload telemetry for various ktor clients.
They extend HttpClientPlugin.
Currently, we're using reflection to install our own HttpClient/HttpTransport to openai-kotlin's OpenAIApi instance.
This is untenable and we'd like for first-class support.
Proposed Solution
There are several ways of doing this:
Solution1:
Add configuration parameter in OpenAIConfig called plugins:
public val plugins: List<HttpClientPlugin<*, *>
And install those plugins in HttpClient.
Solution2:
Add a configuration parameter for a lambda to do custom configuration of the HttpClientConfig. More error prone.
public val configure: HttpClientConfig<*>.() -> Unit = {}
And run that configuration in HttpClient:
config.configure.invoke(this)
I will probably get a PR up to address this soon, but don't want to do unnecessary work if the maintainer doesn't want this.
The text was updated successfully, but these errors were encountered: