Commit Graph

3 Commits

Author SHA1 Message Date
Charles Packer
f47069ad23
fix: added new json test case + added fix for it (also refactored clean json func) (#739) 2023-12-28 23:01:45 -08:00
Charles Packer
c20ad866ea
add new manual json parser meant to catch send_message calls with trailing bad extra chars (#509)
* add new manual json parser meant to catch send_message calls with stray trailing chars, patch json error passing

* typo
2023-11-25 16:30:12 -08:00
Hans Raaf
17c5e3a0bc
I added some json repairs that helped me with malformed messages (#341)
* I added some json repairs that helped me with malformed messages

There are two of them: The first will remove hard line feeds that appear
in the message part because the model added those instead of escaped
line feeds. This happens a lot in my experiments and that actually fixes
them.

The second one is less tested and should handle the case that the model
answers with multiple blocks of strings in quotes or even uses unescaped
quotes. It should grab everything betwenn the message: " and the ending
curly braces, escape them and makes it propper json that way.

Disclaimer: Both function were written with the help of ChatGPT-4 (I
can't write much Python). I think the first one is quite solid but doubt
that the second one is fully working. Maybe somebody with more Python
skills than me (or with more time) has a better idea for this type of
malformed replies.

* Moved the repair output behind the debug flag and removed the "clean" one

* Added even more fixes (out of what I just encountered while testing)

It seems that cut of json can be corrected and sometimes the model is to
lazy to add not just one curly brace but two. I think it does not "cost"
a lot to try them all out. But the expeptions get massive that way :)

* black

* for the final hail mary with extract_first_json, might as well add a double end bracket instead of single

---------

Co-authored-by: cpacker <packercharles@gmail.com>
2023-11-09 17:05:42 -08:00