Skip to content

Commit

Permalink
Formatting + ws client bump
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbanda committed Sep 18, 2024
1 parent 5e89f4b commit 51adcbf
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sealed trait JsonSchema {

object JsonSchema {

import java.lang.{ String => JString }
import java.lang.{String => JString}

case class Object(
properties: Map[JString, JsonSchema],
Expand Down Expand Up @@ -53,4 +53,4 @@ object JsonType {
case object Array extends JsonType("array")
}

sealed abstract class JsonType(value: String) extends NamedEnumValue(value)
sealed abstract class JsonType(value: String) extends NamedEnumValue(value)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ trait JsonSchemaReflectionHelper {
dateAsNumber: Boolean = false,
useRuntimeMirror: Boolean = false
): JsonSchema = {
val mirror = if (useRuntimeMirror) runtimeMirror(getClass.getClassLoader) else typeTag[T].mirror
val mirror =
if (useRuntimeMirror) runtimeMirror(getClass.getClassLoader) else typeTag[T].mirror
asJsonSchema(typeOf[T], mirror, dateAsNumber)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,36 @@ object ChatCompletionSettingsConversions {
FieldConversionDef(
settings => settings.temperature.isDefined && settings.temperature.get != 1,
_.copy(temperature = Some(1d)),
Some("O1 models don't support temperature values other than the default of 1, converting to 1."),
Some(
"O1 models don't support temperature values other than the default of 1, converting to 1."
),
warning = true
),
// top_p
FieldConversionDef(
settings => settings.top_p.isDefined && settings.top_p.get != 1,
_.copy(top_p = Some(1d)),
Some("O1 models don't support top p values other than the default of 1, converting to 1."),
Some(
"O1 models don't support top p values other than the default of 1, converting to 1."
),
warning = true
),
// presence_penalty
FieldConversionDef(
settings => settings.presence_penalty.isDefined && settings.presence_penalty.get != 0,
_.copy(presence_penalty = Some(0d)),
Some("O1 models don't support presence penalty values other than the default of 0, converting to 0."),
Some(
"O1 models don't support presence penalty values other than the default of 0, converting to 0."
),
warning = true
),
// frequency_penalty
FieldConversionDef(
settings => settings.frequency_penalty.isDefined && settings.frequency_penalty.get != 0,
_.copy(frequency_penalty = Some(0d)),
Some("O1 models don't support frequency penalty values other than the default of 0, converting to 0."),
Some(
"O1 models don't support frequency penalty values other than the default of 0, converting to 0."
),
warning = true
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ object MessageConversions {
(messages: Seq[BaseMessage]) => {
val nonSystemMessages = messages.map {
case SystemMessage(content, _) =>
logger.warn(s"System message found but not supported by an underlying model. Converting to a user message instead: '${content}'")
logger.warn(
s"System message found but not supported by an underlying model. Converting to a user message instead: '${content}'"
)
UserMessage(s"System: ${content}")

case x: BaseMessage => x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import play.api.libs.json.Json
import scala.concurrent.Future

// experimental
object CreateChatCompletionJsonForCaseClass extends Example with TestFixtures with JsonSchemaReflectionHelper with OpenAIServiceConsts {
object CreateChatCompletionJsonForCaseClass
extends Example
with TestFixtures
with JsonSchemaReflectionHelper
with OpenAIServiceConsts {

private val messages = Seq(
SystemMessage(capitalsPrompt),
Expand All @@ -18,7 +22,7 @@ object CreateChatCompletionJsonForCaseClass extends Example with TestFixtures wi

// Case class(es)
private case class CapitalsResponse(
countries: Seq[Country],
countries: Seq[Country]
)

private case class Country(
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Dependencies {

object Versions {
val wsClient = "0.5.9"
val wsClient = "0.6.0"
val scalaMock = "6.0.0"
}
}

0 comments on commit 51adcbf

Please sign in to comment.