-
Notifications
You must be signed in to change notification settings - Fork 38
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
Failing to fix a truncated string containing a delimeter like a colon :
#130
Comments
It's not so trivial to repair as you may think 😉. It would be great to improve on this though. Help would be very welcome. Related issues: |
:
:
:
A very kludge workaround I found is to add a quote |
That's a smart workaround in case you know you have a truncated JSON document 👍 |
We are experiencing the same when receiving JSON content from AI (ChatGPT) via streaming, and in our case the strings in JSON contain sentences with commas etc. It seems the problem is that it detects "delimiters" even within a string value, prematurely finishes the string by adding Regarding possible fixes:
|
@hejtmii Would be curious if you find a workaround. I'm still on my pseudo-hack for the same usecase than you. |
@JpEncausse in our case we accumulate ChatGPT messages to a (growing) truncated JSON string. So our workaround is to "just" ignore the stages that throw while fixing the JSON and wait for some that passes. We always return JSON array, and only process "complete" objects from the array (basically always ignoring the last object from parsed array until the response is finished) So in our case it is not really a blocking issue, I just wanted to share my findings and somewhat follow up with some thoughts on "It's not so trivial to repair as you may think" I didn't want to implement some heuristic just for the sake of reducing the number of thrown and caught exceptions. |
:
:
We've experienced the same with iso 8601 date strings which contain colons in the time part. |
Fixed now in |
I give a try to handle partial JSON return from an LLM. But it fail on very simple content. May be I use it wrong ?
{"text":"🌶️ Here is a Poeme for you :
Library should simply close the quote then the accolade ...
{"text":"🌶️ Here is a Poeme for you :"}
But return
Error: Object key expected at position 37
The text was updated successfully, but these errors were encountered: