SuperAGI icon indicating copy to clipboard operation
SuperAGI copied to clipboard

Stuck in infinite loop. "Could not parse invalid json"

Open 0xStuart opened this issue 1 year ago • 9 comments

image

0xStuart avatar Jun 05 '23 20:06 0xStuart

Yes, I've been having this issue for several kinds of tasks. The problem is using JSON to parse the agent's answers because even GPT4 isn't good at escaping strings for JSON fields.

So, in the meantime, you could add the following text at the end of the agent description:

Remember to escape the double quotes in the command string whenever you request a command, like creating a file. For example,
```"content": "{\n  "name": "discord-supabase-bot",\n  "version": "1.0.0",\n  "description": "A Discord bot that saves messages to Supabase"\n}"```
Is wrong. It should be
```"content": "{\"name\": \"discord-supabase-bot\",\"version\": \"1.0.0\",\"description\": \"A Discord bot that saves messages to Supabase\"}"```
Note how the external quotes are not escaped, only the quotes inside the string. Also, there are no newlines or spaces in the string representation of the JSON object.

It won't fix the issue, but it will reduce its occurrence.

maxrevilo avatar Jun 05 '23 23:06 maxrevilo

Going through the same issue here.

6R15 avatar Jun 06 '23 08:06 6R15

image

This is the method (check_and_clean_json from json_cleaner.py) where the json should be parsed and clean.

And the issues happened here (output_parser.py): image

6R15 avatar Jun 06 '23 12:06 6R15

image

This is the method (check_and_clean_json from json_cleaner.py) where the json should be parsed and clean.

And the issues happened here (output_parser.py): image

However, the real input is the llm model response.

6R15 avatar Jun 06 '23 12:06 6R15

image This is the method (check_and_clean_json from json_cleaner.py) where the json should be parsed and clean. And the issues happened here (output_parser.py): image

However, the real input is the llm model response.

Did you fix it?

aslaii avatar Jun 08 '23 17:06 aslaii

This seems to be one of the major issues I run into as well. I love this project and hope this issue isn't too difficult to address. It seems to happen the most when I ask it to code something, even a simple python script, (other then "hello world") can generate this error.

sharpie12 avatar Jun 09 '23 22:06 sharpie12

This seems to be one of the major issues I run into as well. I love this project and hope this issue isn't too difficult to address. It seems to happen the most when I ask it to code something, even a simple python script, (other then "hello world") can generate this error.

It doesn't look that hard. AGI like auto-gpt also have a kind of method to fix json which works. I currently don't have enough time to really contribute. Maybe later :).

6R15 avatar Jun 09 '23 23:06 6R15

I've also been encountering this issue

RickyEsclapon avatar Jun 11 '23 12:06 RickyEsclapon

It's nearly unusable without this fixed.

brainshower avatar Jun 12 '23 18:06 brainshower

We have fixed this issue. Thus closing this.

neelayan7 avatar Jun 27 '23 11:06 neelayan7