Skip to content

Commit

Permalink
Fix serialization of assistant's code interpreter tool's file IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
branislav-burdiliak committed Aug 9, 2024
1 parent c2a80dd commit 25afe6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 25afe6d

Please sign in to comment.