Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Fix for arguments parsing, loses all encodings otherwise #474

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

widoriezebos
Copy link

@widoriezebos widoriezebos commented Feb 22, 2024

Description

When using functions combined with streaming completions, the ChatFunctionCallArgumentsSerializerAndDeserializer is used to deserialize arguments. This is broken because quotes get stripped from the chunks that get returned. This leads to a JSON deserialization exception of the combined chunks (when the arguments JSON gets parsed).

The token ":{" is decoded to :{ and then decoded again, so losing all quotes in the process. This leads to a Jackson parse exception later when the aggregate of the chunks is (attempted to be) deserialised into the arguments.

I tried to use my own ChatFunctionCallMixIn but failed to plug that in. Also: there seems to be no way to override the mapper in OpenAiService which is kind of bummer because then I could have just plugged in a fix (in stead of patching the source below)

Changes

Added a call to the mapper to encode quotes before decoding them again. Without this fix the JSON arguments string loses all quotes and becomes invalid for parsing later on

New API Checklist

  1. Documentation for every variable
  2. Class-level documentation
  3. POJO JSON parsing tests
  4. Service integration tests

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant