From 25afe6d6974372abe69a3626eff9ea5bd8433e75 Mon Sep 17 00:00:00 2001 From: Branislav Burdiliak Date: Fri, 9 Aug 2024 17:32:46 +0200 Subject: [PATCH] Fix serialization of assistant's code interpreter tool's file IDs --- .../src/main/scala/io/cequence/openaiscala/JsonFormats.scala | 2 +- .../scala/io/cequence/openaiscala/examples/CreateThread.scala | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openai-client/src/main/scala/io/cequence/openaiscala/JsonFormats.scala b/openai-client/src/main/scala/io/cequence/openaiscala/JsonFormats.scala index 29316abb..86497a97 100644 --- a/openai-client/src/main/scala/io/cequence/openaiscala/JsonFormats.scala +++ b/openai-client/src/main/scala/io/cequence/openaiscala/JsonFormats.scala @@ -533,7 +533,7 @@ object JsonFormats { implicit lazy val assistantToolResourceWrites: Writes[AssistantToolResource] = { case c: CodeInterpreterResources => - Json.obj("code_interpreter" -> Json.obj("file_ids" -> c.fileIds)) + Json.obj("code_interpreter" -> Json.obj("file_ids" -> c.fileIds.map(_.file_id))) case f: FileSearchResources => assert( diff --git a/openai-examples/src/main/scala/io/cequence/openaiscala/examples/CreateThread.scala b/openai-examples/src/main/scala/io/cequence/openaiscala/examples/CreateThread.scala index 653f0e4f..3091eed1 100755 --- a/openai-examples/src/main/scala/io/cequence/openaiscala/examples/CreateThread.scala +++ b/openai-examples/src/main/scala/io/cequence/openaiscala/examples/CreateThread.scala @@ -1,6 +1,7 @@ package io.cequence.openaiscala.examples -import io.cequence.openaiscala.domain.ThreadMessage +import io.cequence.openaiscala.domain.{AssistantToolResource, FileId, ThreadMessage} + import scala.concurrent.Future object CreateThread extends Example { @@ -12,6 +13,7 @@ object CreateThread extends Example { ThreadMessage("Hello, what is AI?"), // file_ids = Seq("file-abc123") ThreadMessage("How does AI work? Explain it in simple terms.") ), + toolResources = Seq(AssistantToolResource.CodeInterpreterResources(Seq(FileId("file1.txt")))), metadata = Map("user_id" -> "986413") ) } yield {