io.cequence.openaiscala.service.OpenAIServiceFactory.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openai-scala-client_2.12 Show documentation
Show all versions of openai-scala-client_2.12 Show documentation
Scala client for OpenAI API implemented using Play WS lib.
package io.cequence.openaiscala.service
import akka.stream.Materializer
import io.cequence.openaiscala.service.impl.OpenAIServiceImpl
import io.cequence.wsclient.domain.WsRequestContext
import io.cequence.wsclient.service.WSClientEngine
import scala.concurrent.ExecutionContext
object OpenAIServiceFactory
extends OpenAIServiceFactoryHelper[OpenAIService]
with OpenAIServiceConsts {
override def customInstance(
coreUrl: String,
requestContext: WsRequestContext = WsRequestContext()
)(
implicit ec: ExecutionContext,
materializer: Materializer
): OpenAIService =
new OpenAIServiceClassImpl(coreUrl, requestContext)
}
private class OpenAIServiceClassImpl(
coreUrl: String,
requestContext: WsRequestContext
)(
implicit val ec: ExecutionContext,
val materializer: Materializer
) extends OpenAIServiceImpl {
// we use play ws client engine
protected val engine: WSClientEngine = ProjectWSClientEngine(coreUrl, requestContext)
}