org.http4k.connect.openai.plugins.UserPluginIntegration.kt Maven / Gradle / Ivy
The newest version!
package org.http4k.connect.openai.plugins
import org.http4k.connect.openai.auth.OpenAIPluginId
import org.http4k.connect.openai.plugins.internal.ForwardCallsToPluginServer
import org.http4k.connect.openai.plugins.internal.LoadOpenApi
import org.http4k.core.Filter
import org.http4k.core.HttpHandler
import org.http4k.core.Uri
import org.http4k.routing.routes
import java.time.Clock
/**
* Plugin implementation which plugs into the FakeOpenAI server. It uses Basic or Bearer
* auth to auth against the server.
*/
fun UserPluginIntegration(
securityFilter: Filter,
pluginId: OpenAIPluginId,
pluginUri: Uri
) = object : PluginIntegration {
override val pluginId = pluginId
override fun buildIntegration(openAiUrl: Uri, http: HttpHandler, clock: Clock) =
IntegratedPlugin(
pluginId,
routes(
LoadOpenApi(pluginId, openAiUrl, http, pluginUri),
ForwardCallsToPluginServer(pluginId, http, pluginUri) {
securityFilter
}
),
securityFilter
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy