AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

Command Error Loop - 'dict' object

Open carterlasalle opened this issue 1 year ago • 12 comments

Duplicates

  • [X] I have searched the existing issues

Steps to reproduce 🕹

Run a bot on for a long time.

Current behavior 😯

EXT ACTION: COMMAND = Error: ARGUMENTS = 'dict' object has no attribute 'replace' SYSTEM: Command Error: threw the following error: 'dict' object has no attribute 'replace' Warning: Failed to parse AI output, attempting to fix. If you see this warning frequently, it's likely that your prompt is confusing the AI. Try changing it up slightly. Failed to fix AI output, telling the AI.
Error: Invalid JSON It seems like there's a persisting error with the system. I recommend initiating a fresh session by starting a new Jupyter notebook or terminal.

Once you've started a new session, start by researching profitable website ideas on Google using the google command. Attempting to fix JSON by finding outermost brackets Error: Invalid JSON, setting it to empty JSON now.

ENTREPRENEUR-GPT THOUGHTS: REASONING: CRITICISM: Attempting to fix JSON by finding outermost brackets Error: Invalid JSON, setting it to empty JSON now.

NEXT ACTION: COMMAND = Error: ARGUMENTS = 'dict' object has no attribute 'replace' SYSTEM: Command Error: threw the following error: 'dict' object has no attribute 'replace' Warning: Failed to parse AI output, attempting to fix. If you see this warning frequently, it's likely that your prompt is confusing the AI. Try changing it up slightly. Failed to fix AI output, telling the AI.

Expected behavior 🤔

Do not get stuck on command error and 'dict' object

Your prompt 📝

Name your AI:  For example, 'Entrepreneur-GPT'
AI Name: Entrepreneur-GPT
Entrepreneur-GPT here!  I am at your service.
Describe your AI's role:  For example, 'an AI designed to autonomously develop and run businesses with the sole goal of increasing your net worth.'
Entrepreneur-GPT is: an AI designed to autonomously create and run a new businesness through coding a website with the sole goal of creating profit.
Enter up to 5 goals for your AI:  For example: Increase net worth, Grow Twitter Account, Develop and manage multiple businesses autonomously'

carterlasalle avatar Apr 15 '23 01:04 carterlasalle

@RocketNinja15 strange error. Just to be sure, can you try pulling latest git changes and rerun the script?

git fetch
git reset --hard origin/master

Qoyyuum avatar Apr 15 '23 02:04 Qoyyuum

@RocketNinja15 strange error. Just to be sure, can you try pulling latest git changes and rerun the script?

git fetch
git reset --hard origin/master

I'm not the OP here, but are we all-in on the master branch and no longer expected to use stable?

joshfranzen avatar Apr 15 '23 02:04 joshfranzen

I get the same error multiple times as well just like RocketNinja15 stated.

I already pulled the master branch, but still the same issue....

AI-SCRIPTER THOUGHTS: None

REASONING: None

CRITICISM: None

Attempting to fix JSON by finding outermost brackets Error: Invalid JSON, setting it to empty JSON now.

NEXT ACTION: COMMAND = Error: ARGUMENTS = 'dict' object has no attribute 'replace'

renatokuipers avatar Apr 15 '23 02:04 renatokuipers

Thanks for testing @renatokuipers . If OP has done the same and gets the result as, can either of you run it with --debug please and share the result here?

Qoyyuum avatar Apr 15 '23 02:04 Qoyyuum

same error

Attempting to fix JSON by finding outermost brackets Error: Invalid JSON, setting it to empty JSON now.

GNS-GPT THOUGHTS: None REASONING: None CRITICISM: None Attempting to fix JSON by finding outermost brackets Error: Invalid JSON, setting it to empty JSON now.

NEXT ACTION: COMMAND = Error: ARGUMENTS = 'dict' object has no attribute 'replace'

codygao2020 avatar Apr 15 '23 02:04 codygao2020

@Qoyyuum Same error too

carterlasalle avatar Apr 15 '23 04:04 carterlasalle

Not able to reproduce. Are you using stable or from master branch? @codygao2020 @RocketNinja15

Qoyyuum avatar Apr 15 '23 05:04 Qoyyuum

Using the latest version of master, this error comes up almost constantly with no usable output from the app. At first, it seems to output a few useful prompts, but eventually it hits this dict error and will just continually produce the error until you stop the program. Restarting the program has the same result, producing a few useful results and then after 3,4,5 maybe it will produce this error continuously.

pretannikai avatar Apr 15 '23 05:04 pretannikai

Need to sleep in my timezone but the following two fixes fixed the issue for me (tested with y -10 prompts)

Issue Replication: ai_settings.yaml file:

ai_goals:
  - Gather all ondemand EC2 pricing
  - Find the difference between pricing between each region and us-east-1, for each instance type
  - Write a python script that does that and output the pricing differences to a csv
ai_name: EC2 Pricing AI
ai_role: an AI designed to find the ondemand EC2 pricing differences in each region compared to us-east-1 for each instance

Then in the 2nd, or the 3rd step, give feedback cli or run cli. This triggers the above error pretty quickly

Issue Source: https://github.com/Significant-Gravitas/Auto-GPT/blob/master/autogpt/llm_utils.py#L69

Issue Analysis: Sometimes 'content' is an empy dictionary instead of a string, which causes downstream assistant_reply to be of type dict. This object is propogated into fix_and_parse_json()

Proposed Fix:

  1. Replace line69 linked above with the following code:
    res = response.choices[0].message.get("content", '')
    try: 
        json.loads(res)
        return res
    except:
        from autogpt.json_parser import fix_and_parse_json # avoid circular import
        return json.dumps(fix_and_parse_json(res))

2 . Remove the () surrounding https://github.com/Significant-Gravitas/Auto-GPT/blob/master/autogpt/main.py#L92

This falls under a host of other JSON related issues. Ideally want a better JSON response handling system.

YifeiY avatar Apr 15 '23 05:04 YifeiY

Thanks for the idea, Yif.

Didn't seem to completely work. Can you provide a more complete fix for this? I think the "res" variable you are using is not defined in the existing code. JSON also needs to be imported, etc.

pretannikai avatar Apr 15 '23 07:04 pretannikai

Thanks for the idea, Yif.

Didn't seem to completely work. Can you provide a more complete fix for this? I think the "res" variable you are using is not defined in the existing code. JSON also needs to be imported, etc.

I have updated the reply above with the initialization of res. Please let me know if that works.

They pushed some JSON fix to release 0.2.0. Please take a look at that as well and see if your issue is fixed with that release.

YifeiY avatar Apr 15 '23 14:04 YifeiY

@YifeiY @Qoyyuum If it helps I'm using GPT-3.5-Turbo, so maybe it's the output format. I'm assuming that its also has to do with to community-wide JSON issue.

carterlasalle avatar Apr 15 '23 17:04 carterlasalle

Possible duplicate of #1335

lc0rp avatar Jun 13 '23 07:06 lc0rp