Skip to content

Fix chat reponse deserialization with no toolCalls - #137

Merged
DybekK merged 1 commit into
softwaremill:masterfrom
guersam:fix-toolcalls
Nov 24, 2023
Merged

Fix chat reponse deserialization with no toolCalls#137
DybekK merged 1 commit into
softwaremill:masterfrom
guersam:fix-toolcalls

Conversation

@guersam

@guersam guersam commented Nov 24, 2023

Copy link
Copy Markdown
Contributor

Currently, missing toolCalls causes a deserialization error when there are no tools:

OpenAISyncClient(secret).createChatCompletion(ChatBody(
  model = ChatCompletionModel.GPT4Turbo,
  messages = Seq(
    Message.UserMessage(
      content = Content.TextContent("Hello!")
    )
  )
))
Fail(sttp.openai.OpenAIExceptions$OpenAIException$DeserializationOpenAIException: missing keys in dictionary: toolCalls at index 352

This commit sets default value for toolCalls to avoid the error.

@DybekK
DybekK merged commit 19feaec into softwaremill:master Nov 24, 2023
@DybekK

DybekK commented Nov 24, 2023

Copy link
Copy Markdown
Contributor

Thank you for your contribution 😃

@guersam

guersam commented Nov 29, 2023

Copy link
Copy Markdown
Contributor Author

My bad. At least in Scala 3, even with the default function argument, it still fails to deserialize when there are no toolCalls field in the JSON response 😢

Sorry again, I updated my build.sbt a few days go but forgot to refresh my SBT shell... Now it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants