-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Handle unterminated escape character when parsing partial JSON #29065
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @balvisio thanks for looking into this. Could you add a unit test for this scenario?
a78ea9d
to
261d1c0
Compare
@eyurtsev Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
Description
Currently, when parsing a partial JSON, if a string ends with the escape character, the whole key/value is removed. For example:
My expectation (and with this fix) would be for
parse_partial_json()
to return:Notes:
\\
langchain/libs/core/langchain_core/output_parsers/transform.py
Line 111 in 187131c
since what happens is that, for example, if the received sequence of chunks are:
{"foo": "b
,ar\\
:Then, the result of calling
self.parse_result()
is:and the second time: