Skip to content

Commit ab79936

Browse files
committed
format run reason correctly to pass 3.2.2 compilation
1 parent 376706e commit ab79936

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ val scala213 = "2.13.11"
66
val scala3 = "3.2.2"
77

88
ThisBuild / organization := "io.cequence"
9-
ThisBuild / scalaVersion := scala212
9+
ThisBuild / scalaVersion := scala3
1010
ThisBuild / version := "1.0.1-RC.21"
1111
ThisBuild / isSnapshot := false
1212

openai-client/src/main/scala/io/cequence/openaiscala/JsonFormats.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ object JsonFormats {
8181

8282
implicit lazy val contentReads: Reads[Content] = Reads[Content] { (json: JsValue) =>
8383
(json \ "type").validate[String].flatMap {
84-
case "text" => (json \ "text").validate[String].map(TextContent)
85-
case "image_url" => (json \ "image_url" \ "url").validate[String].map(ImageURLContent)
86-
case _ => JsError("Invalid type")
84+
case "text" => (json \ "text").validate[String].map(TextContent.apply)
85+
case "image_url" =>
86+
(json \ "image_url" \ "url").validate[String].map(ImageURLContent.apply)
87+
case _ => JsError("Invalid type")
8788
}
8889
}
8990

@@ -504,7 +505,9 @@ object JsonFormats {
504505

505506
implicit lazy val assistantToolResourceReads: Reads[AssistantToolResource] = Reads { json =>
506507
(json \ "code_interpreter").toOption.map { codeInterpreterJson =>
507-
(codeInterpreterJson \ "file_ids").validate[Seq[FileId]].map(CodeInterpreterResources)
508+
(codeInterpreterJson \ "file_ids")
509+
.validate[Seq[FileId]]
510+
.map(CodeInterpreterResources.apply)
508511
}.orElse(
509512
(json \ "file_search").toOption.map { fileSearchJson =>
510513
val fileSearchVectorStoreIds = (fileSearchJson \ "vector_store_ids").asOpt[Seq[String]]
@@ -784,10 +787,9 @@ object JsonFormats {
784787
Format(reads, writes)
785788
}
786789

787-
implicit lazy val runReasonFormat: Format[Run.Reason] = {
788-
implicit lazy val stringStringMapFormat: Format[Map[String, String]] =
789-
JsonUtil.StringStringMapFormat
790-
Json.format[Run.Reason]
790+
implicit lazy val runReasonFormat: Format[Run.Reason] = new Format[Run.Reason] {
791+
def reads(json: JsValue): JsResult[Run.Reason] = json.validate[String].map(Run.Reason)
792+
def writes(o: Run.Reason): JsValue = JsString(o.value)
791793
}
792794

793795
implicit lazy val lastRunErrorCodeFormat: Format[Run.LastErrorCode] = {

openai-core/src/main/scala/io/cequence/openaiscala/domain/Run.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ object Run {
8383

8484
sealed trait LastErrorCode extends SnakeCaseEnumValue
8585

86-
// server_error, rate_limit_exceeded, or invalid_prompt
8786
object LastErrorCode {
8887
case object ServerError extends LastErrorCode
8988
case object RateLimitExceeded extends LastErrorCode

0 commit comments

Comments
 (0)