Skip to content

Commit

Permalink
Base message formats fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbanda committed Sep 19, 2024
1 parent 627642d commit 3870f7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,17 @@ object JsonFormats {
}

case ChatRole.Tool =>
json.asOpt[AssistantToolMessage] match {
case Some(assistantToolMessage) => assistantToolMessage
case None => json.as[ToolMessage]
}
json.as[ToolMessage]
// TODO: fixed.... originally was
// json.asOpt[AssistantToolMessage] match {
// case Some(assistantToolMessage) => assistantToolMessage
// case None => json.as[ToolMessage]
// }

case ChatRole.Assistant =>
json.asOpt[AssistantToolMessage] match {
case Some(assistantToolMessage) => assistantToolMessage
// if contains tool_calls, then it is AssistantToolMessage
(json \ "tool_calls").asOpt[JsArray] match {
case Some(_) => json.as[AssistantToolMessage]
case None =>
json.asOpt[AssistantMessage] match {
case Some(assistantMessage) => assistantMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.cequence.openaiscala.examples.scenario

import io.cequence.openaiscala.domain.AssistantTool.FileSearchTool
import io.cequence.openaiscala.domain.settings.FileUploadPurpose
import io.cequence.openaiscala.domain.{AssistantId, AssistantToolResource, Run, RunStatus}
import io.cequence.openaiscala.domain.{AssistantId, AssistantToolResource, ModelId, Run, RunStatus}
import io.cequence.openaiscala.examples.{Example, PollingHelper}

import java.io.File
Expand Down Expand Up @@ -31,7 +31,7 @@ object CreateThreadAndRunScenario extends Example with PollingHelper {
)

assistant <- service.createAssistant(
model = "gpt-4o-2024-05-13",
model = ModelId.gpt_4o_2024_05_13,
name = Some("Customer Relationship Assistant"),
description = Some(
"You are a trustworthy and reliable assistant that helps businesses with their customer relationship agreements."
Expand Down

0 comments on commit 3870f7d

Please sign in to comment.