Skip to content

Commit

Permalink
BaseMessage json formats fix
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbanda committed Aug 28, 2024
1 parent e574416 commit 397f21f
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,12 @@ object JsonFormats {
}

case ChatRole.Tool =>
json.asOpt[AssistantToolMessage] match {
case Some(assistantToolMessage) => assistantToolMessage
case None => json.as[ToolMessage]
}
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

0 comments on commit 397f21f

Please sign in to comment.