All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cequence.openaiscala.service.impl.RunBodyMaker.scala Maven / Gradle / Ivy

There is a newer version: 1.1.0.RC.2
Show newest version
package io.cequence.openaiscala.service.impl

import io.cequence.openaiscala.JsonFormats._
import io.cequence.openaiscala.domain.settings.CreateRunSettings
import io.cequence.wsclient.service.WSClient
import play.api.libs.json.{JsValue, Json}

trait RunBodyMaker {

  this: WSClient =>

  protected def createBodyParamsForRun(
    settings: CreateRunSettings,
    stream: Boolean
  ): Seq[(Param, Option[JsValue])] = {

    jsonBodyParams(
      Param.model -> settings.model,
      Param.temperature -> settings.temperature,
      Param.top_p -> settings.topP,
      Param.stream -> Some(stream),
      Param.max_prompt_tokens -> settings.maxPromptTokens,
      Param.response_format -> settings.responseFormat.map { format =>
        Json.toJson(format)
      }
    )
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy