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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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