AutoGPT: i keep getting an error saying invalid json pls help

Duplicates

  • I have searched the existing issues

Steps to reproduce πŸ•Ή

No response

Current behavior 😯

No response

Expected behavior πŸ€”

No response

Your prompt πŸ“

# Paste your prompt here

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 18 (3 by maintainers)

Most upvoted comments

Same here. It seems the assistant doesn’t respond in the correct format. Maybe due to a change on the main prompt.

The assistant should respond only in JSON. Instead, it prepends the JSON with an explanation.

Example:

I would like to browse the website from one of the search results to gain a deeper understanding of the current economic situation. I will use the "browse_website" command and retrieve information about the impact of the current economic climate on different industries. Here is my response:

{
    "thoughts":{
        "text": "Based on the search results, I believe it would be useful to browse a website to gain more information on the impact of the current economic situation on various industries. I will use the 'browse_website' command to extract this information.",
        "reasoning": "Browsing the website will provide me with a more in-depth understanding of the current economic climate and the impact it has had on various industries.",
        "plan": "- Browse a website to gain more specific information on the current economic situation.\n- Analyze the impact of the current economic climate on different industries.\n- Use this information to identify profitable markets to invest in.",
        "criticism": "I need to ensure that the website I browse is reputable and unbiased. It's also important to evaluate the information critically and consider the potential implications of the economic situation on different industries.",
        "speak": "I am browsing a website to gain a more detailed understanding of how the current economic situation has impacted different industries."
    },
    "command": {
        "name": "browse_website",
        "args": {
            "url": "https://www.thebalance.com/how-does-the-economy-affect-the-stock-market-4172872",
            "question": "How has the current economic climate impacted different industries?"
        }
    }
}

yeah, above is for an old version. what worked for me is replacing the response_json = fix_and_parse_json(response with response_json = regex.search(r'\{(?:[^{}]|((?R)))*\}', response, regex.DOTALL).group() response_json = fix_and_parse_json(response_json)

this is in the scripts/commands.py file at line 31 note that you need to import regex at the top instead of re. This is still giving me an invalid json error, however, the command is actually parsed just fine. I am not sure how to get rid of the error.