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
MIT License
166.67k stars 44.11k forks source link

No feedback to AI possible #863

Closed Loremima closed 1 year ago

Loremima commented 1 year ago

Duplicates

Steps to reproduce 🕹

Anytime I try to write something else than y y -N or n, it will throw an error.

Current behavior 😯

Issue while parsing the json file.

I investigated a bit the fix_and_parse_json function, and it appear that in that case (when user does enter feedback to AI) the function doesn't receive a Json object.

def fix_and_parse_json(    
    json_str: str,
    try_to_fix_with_gpt: bool = True
) -> Union[str, Dict[Any, Any]]:
    """Fix and parse JSON string"""
    try:
        json_str = json_str.replace('\t', '')
        return json.loads(json_str)
    except json.JSONDecodeError as e:
        print(f"Initial JSON parsing failed: {e}")  # Added this line
        print('Helllo')
        print(json_str) # --> Contain the AI answer but in <class 'str'> format, not json object
        json_str = correct_json(json_str)
        try:
            return json.loads(json_str)
        except json.JSONDecodeError as e:
            print(f"Corrected JSON parsing failed: {e}")  # Added this line
            pass
    try:
        if "{" in json_str:
            brace_index = json_str.index("{")
            json_str = json_str[brace_index:]
            last_brace_index = json_str.rindex("}")
            json_str = json_str[:last_brace_index+1]
            return json.loads(json_str)
        else:
            print("No JSON object found in input string.") # Added this line
            return {"error": "No JSON object found in input string."}  # Added this line

Error exemple BEFORE my added lines:

Input:Why the do_nothing command keeps coming?
SYSTEM:  Human feedback: Why the do_nothing command keeps coming?
Error:        
 Traceback (most recent call last): File "C:\Users\Lorenzo\Documents\code\projects\auto_gpt\Auto-GPT\scripts\main.py", line 76, in print_assistant_thoughts assistant_reply_json = fix_and_parse_json(assistant_reply) File "C:\Users\Lorenzo\Documents\code\projects\auto_gpt\Auto-GPT\scripts\json_parser.py", line 51, in fix_and_parse_json # of the string ValueError: substring not found
NEXT ACTION:  COMMAND = Error: ARGUMENTS = substring not found
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for Jarvis...

Error exemple AFTER my added lines:

Input:where was the file saved?
SYSTEM:  Human feedback: where was the file saved?
Initial JSON parsing failed: Expecting value: line 1 column 1 (char 0)
Helllo
I have not yet saved any files. I only executed a 'google' command to search for best-selling items online. Once I have the search results, I will analyze them to identify potential high selling items.
<class 'str'>
Corrected JSON parsing failed: Expecting value: line 1 column 1 (char 0)
No JSON object found in input string.
JARVIS THOUGHTS:
REASONING:
CRITICISM:
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for Jarvis...

Expected behavior 🤔

The AI should reply to my feedback, like it used to be.

Your prompt 📝

ai_goals:
- Find ideal product(s).
- Save the result in a .txt file.
- Shut down.
ai_name: Jarvis
ai_role: An AI designed to autonomously scrap the web, identifying products with high sales potential for use on e-commerce websites.
Artemonim commented 1 year ago

Welcome to the duplicate creators club, buddy.

Loremima commented 1 year ago

Welcome to the duplicate creators club, buddy.

Thanks, where is the similar issue?

Slowly-Grokking commented 1 year ago

Welcome to the duplicate creators club, buddy.

Thanks, where is the similar issue?

https://github.com/Torantulino/Auto-GPT/issues?q=JSON https://github.com/Torantulino/Auto-GPT/issues?q=substring