Significant-Gravitas / AutoGPT

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
https://agpt.co
Other
168.37k stars 44.41k forks source link

scripts/json_parser.py substring not found #793

Closed giovannimanzoni closed 1 year ago

giovannimanzoni commented 1 year ago

Duplicates

Steps to reproduce 🕹

From last update, ask a question and after thinking:

Error:
Traceback (most recent call last): File "/home/gpt1/Auto-GPT/scripts/main.py", line 76, in print_assistant_thoughts assistant_reply_json = fix_and_parse_json(assistant_reply) File "/home/gpt1/Auto-GPT/scripts/json_parser.py", line 51, in fix_and_parse_json brace_index = json_str.index("{") ValueError: substring not found

Current behavior 😯

error

Expected behavior 🤔

response without error

Your prompt 📝

# verwandelt den folgenden Text,in einem SEO Text von 200 Wörtern: bla mit „Marke „ oder „Brandzeichen“. bla...
richbeales commented 1 year ago

Dupe of https://github.com/Torantulino/Auto-GPT/issues/751 https://github.com/Torantulino/Auto-GPT/issues/726 https://github.com/Torantulino/Auto-GPT/issues/626 https://github.com/Torantulino/Auto-GPT/issues/601

etc.

carlucio7 commented 1 year ago

Is this really duplicated? I don't have a invalid json error. In my case it keeps returning this substring not found after providing feedback.

james431987 commented 1 year ago

it threw that error 10 times in a row for me. Eventually, it died and I couldn't continue. Any fix for this?

zajerao commented 1 year ago

same problem here, just tiny difference, error seems to be at line 78 instead, if that is helpful. 14:29:07,596 AutoGPT INFO Error: : Traceback (most recent call last): File "/Users/a/Auto-GPT/scripts/main.py", line 78, in print_assistant_thoughts assistant_reply_json = fix_and_parse_json(assistant_reply) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/a/Auto-GPT/scripts/json_parser.py", line 51, in fix_and_parse_json brace_index = json_str.index("{") ^^^^^^^^^^^^^^^^^^^ ValueError: substring not found

Is there a version or build number to check to know exactly what I am running?

zajerao commented 1 year ago

oh for what it's worth, ran this by Chat-GPT4 who said: It seems you have a ValueError: substring not found error in your Python script. This error is raised when you try to find a substring in a string using the index() method, but the substring is not found.

In your specific case, the error occurs in the json_parser.py file on line 51:

python Copy code brace_index = json_str.index("{") To help you resolve this issue, I recommend checking the value of json_str before calling the index() method. You can add a print statement to see what the content of json_str is:

python Copy code print("json_str:", json_str) brace_index = json_str.index("{") This will help you identify if there's an issue with the input to the function fix_and_parse_json() or if the problem is within the function itself. If the input is incorrect, you'll need to trace back to the calling function to find the root cause. If the issue is with the fix_and_parse_json() function, you can either add exception handling or modify the function to better handle the input.

james431987 commented 1 year ago

I found this #808 and did the code changes. I haven't gotten a JSON error since.

Now I have a different problem where it decides it's tired after a while and just do_nothing as the command repeatedly..

GoMightyAlgorythmGo commented 1 year ago

me too "substring not found" on every user input :(

Auto-GPT wont react to it. But the "do nothing sickness" from yesterday work again. (removed the do nothing command temporarily)

NEXT ACTION: COMMAND = list_agents ARGUMENTS = {} Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for AI_GPT_8... Input:Whenever i give userfeedback there is a error and you dont seem to react to it. Please fix. SYSTEM: Human feedback: Whenever i give userfeedback there is a error and you dont seem to react to it. Please fix. Error: Traceback (most recent call last): File "scripts/main.py", line 76, in print_assistant_thoughts assistant_reply_json = fix_and_parse_json(assistant_reply) File "C:\Programming\Auto-GPT_AI_8\scripts\json_parser.py", line 51, in fix_and_parse_json brace_index = json_str.index("{") ValueError: substring not found NEXT ACTION: COMMAND = Error: ARGUMENTS = substring not found

richbeales commented 1 year ago

closed as duplicate