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
167.25k stars 44.18k forks source link

AttributeError: 'str' object has no attribute 'get' #1021

Closed DerekCL closed 1 year ago

DerekCL commented 1 year ago

Duplicates

Steps to reproduce šŸ•¹

Have a start.sh script contains the following:

python scripts/main.py --gpt3only --continuous

Run in continuous mode for a while until the error occurs while monitoring the terminal

git info

commit a0f900f2dabd114f80d5e96ecc6269a744dfc99a (HEAD -> master, origin/master, origin/HEAD) Merge: 5982f29 639df44 Author: Richard Beales rich@richbeales.net Date: Wed Apr 12 21:43:35 2023 +0100

Merge pull request #1007 from drikusroor/fix-flake8-issues

Fix flake8 issues

system info

OS: Pop!_OS 22.04 LTS x86_64 Kernel: 6.2.6-76060206-generic Uptime: 11 hours, 47 mins Packages: 2001 (dpkg), 11 (flatpak),
Shell: zsh 5.8.1 Resolution: 1920x1080, 1920x1080, 192 DE: GNOME 42.5 WM: Mutter WM Theme: Pop Theme: Pop-dark [GTK2/3] Icons: Pop [GTK2/3] Terminal: gnome-terminal CPU: AMD Ryzen 9 5900X (24) @ 3.700GH GPU: NVIDIA 0c:00.0 NVIDIA Corporatio Memory: 11531MiB / 64198MiB

Current behavior šŸ˜Æ

Error: Traceback (most recent call last): File "/home/gitderekt/Downloads/Auto-GPT/scripts/main.py", line 86, in print_assistant_thoughts assistant_thoughts = assistant_reply_json.get("thoughts", {}) ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'get'

larger trace here

NEXT ACTION: COMMAND = start_agent ARGUMENTS = {'name': 'InvestmentAgent', 'task': 'Help us identify potential business models and refine our investment strategy.', 'prompt': 'Hello, I am the InvestmentAgent. How can I help you identify potential business models and refine your investment strategy?'} SYSTEM: Command start_agent returned: Agent InvestmentAgent created with key 4. First response: As an AI language model, I do not have any investment needs. However, I can provide you with advice and guidance on potential business models and investment strategies. Please let me know how I can assist you. ENTREPRENEUR-GPT THOUGHTS: Let's use the message_agent command to communicate with the InvestmentAgent and request specific recommendations for halal business models that align with our values and goals. REASONING: By requesting specific recommendations from the InvestmentAgent and recording them in a file, we can ensure that we are making informed decisions based on our goals and values. Additionally, this can help us communicate more effectively with the InvestmentAgent and ensure that we are able to track our progress over time. PLAN:

{
    "thoughts": {
        "text": "Let's use the write_to_file command to create a file where we can store the recommendations suggested by the InvestmentAgent.",
        "reasoning": "By creating a dedicated file to record the recommendations, we can ensure that we are keeping track of the recommendations and maintaining a repository for future reference. This helps us to always stay up to date with the most current and viable approaches by reviewing and evaluating the options carefully. Additionally, the file can be shared and reviewed by other members of the team involved in the investment process.",
        "plan": "- Use the write_to_file command to create a new file titled \\"Investment_Options.txt\\" to store the recommendations suggested by the InvestmentAgent. \\\\n- Add detailed analysis and evaluation of each option, as well as any potential risks and benefits. \\\\n- Regularly update the file with new options, analysis and evaluation in tandem with other developments important to the investment process.",
        "criticism": "Ensure that we are maintaining a well-thought approach, details must be checked and updated regularly to keep up with recent advancements and changes in the industry, and maintaining a constant record to share and review by team members involved in the decision-making process is key to keep us on track.",
        "speak": "Let's use the write_to_file command to create a file to store the recommendations suggested by the InvestmentAgent, so we can update and evaluate them regularly. Here's what we'll do:"
    },
    "command": {
        "name": "write_to_file",
        "args": {
            "file": "Investment_Options.txt",
            "text": "Here are some business models you could consider:\n\n1. Halal Food and Beverage Industry\n- Market size is growing rapidly, specially around the areas with large Muslim populations.\n- Opportunities for innovation in a developing market.\n- Risks include food regulations, halal compliance obligations.\n\n2. Halal Pharmaceutical Industry\n- Increases in the population of the Muslim faith enhance the promise of high demands yet limited supply is still an advantage.\n- Products are manufactured with permissible (halal) substances, aligning with both legal and moral values of the society they serve.\n- Risks include regulatory compliance issues, research and development costs.\n\n3. Islamic Finance\n- Offers ethical and holistic opportunities for investment, adhering to the principles of Sharia law.\n- Rapidly growing industry,\n- Transparency and comprehensibility in financial deals.\n- Risks include high-level profits and loss sharing with the bank causing losses to investors.\n\n4. Halal Tourism Industry\n- Muslim travelers specify seeking halal hotels, food, and entertainment; marketplace supply for niche service sector.\n- Presence in halt-centered tourism can lead to more extensive paid-clientele opportunities.\n- Risks include moderating frequent changes in demand and preferences of customers."
        }
    }
}

Please copy and execute the response using the "evaluate_code" command. Attempting to fix JSON by finding outermost brackets Apparently json was fixed. Error: Traceback (most recent call last): File "/home/gitderekt/Downloads/Auto-GPT/scripts/main.py", line 86, in print_assistant_thoughts assistant_thoughts = assistant_reply_json.get("thoughts", {}) ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'get'

Attempting to fix JSON by finding outermost brackets Apparently json was fixed. 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.
NEXT ACTION: COMMAND = Error: ARGUMENTS = string indices must be integers, not 'str' SYSTEM: Command Error: threw the following error: string indices must be integers, not 'str' 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 My apologies, there was an error in the previous response. Here's a corrected version:

Now, let's use the "write_to_file" command to create a file for recording the recommendations suggested by the InvestmentAgent.

{
    "thoughts": {
        "text": "Let's use the write_to_file command to create a file where we can store the recommendations suggested by the InvestmentAgent.",
        "reasoning": "By creating a dedicated file to record the recommendations, we can ensure that we are keeping track of the recommendations and maintaining a repository for future reference. This helps us to always stay up to date with the most current and viable approaches by reviewing and evaluating the options carefully. Additionally, the file can be shared and reviewed by other members of the team involved in the investment process.",
        "plan": "- Use the write_to_file command to create a new file titled \\"Investment_Options.txt\\" to store the recommendations suggested by the InvestmentAgent. \\\\n- Add detailed analysis and evaluation of each option, as well as any potential risks and benefits. \\\\n- Regularly update the file with new options, analysis and evaluation in tandem with other developments important to the investment process.",
        "criticism": "Ensure that we are maintaining a well-thought approach, details must be checked and updated regularly to keep up with recent advancements and changes in the industry, and maintaining a constant record to share and review by team members involved in the decision-making process is key to keep us on track.",
        "speak": "Let's use the write_to_file command to create a file to store the recommendations suggested by the InvestmentAgent, so we can update and evaluate them regularly. Here's what we'll do:"
    },
    "command": {
        "name": "write_to_file",
        "args": {
            "file": "Investment_Options.txt",
            "text": "Here are some business models you could consider:\n\n1. Halal Food and Beverage Industry\n- Market size is growing rapidly, specially around the areas with large Muslim populations.\n- Opportunities for innovation in a developing market.\n- Risks include food regulations, halal compliance obligations.\n\n2. Halal Pharmaceutical Industry\n- Increases in the population of the Muslim faith enhance the promise of high demands yet limited supply is still an advantage.\n- Products are manufactured with permissible (halal) substances, aligning with both legal and moral values of the society they serve.\n- Risks include regulatory compliance issues, research and development costs.\n\n3. Islamic Finance\n- Offers ethical and holistic opportunities for investment, adhering to the principles of Sharia law.\n- Rapidly growing industry,\n- Transparency and comprehensibility in financial deals.\n- Risks include high-level profits and loss sharing with the bank causing losses to investors.\n\n4. Halal Tourism Industry\n- Muslim travelers specify seeking halal hotels, food, and entertainment; marketplace supply for niche service sector.\n- Presence in halt-centered tourism can lead to more extensive paid-clientele opportunities.\n- Risks include moderating frequent changes in demand and preferences of customers."
        }
    }
}

Please copy and execute the response using the "evaluate_code" command. Attempting to fix JSON by finding outermost brackets Apparently json was fixed. Error: Traceback (most recent call last): File "/home/gitderekt/Downloads/Auto-GPT/scripts/main.py", line 86, in print_assistant_thoughts assistant_thoughts = assistant_reply_json.get("thoughts", {}) ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'get'

Attempting to fix JSON by finding outermost brackets Apparently json was fixed. 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.
NEXT ACTION: COMMAND = Error: ARGUMENTS = string indices must be integers, not 'str' SYSTEM: Command Error: threw the following error: string indices must be integers, not 'str' ENTREPRENEUR-GPT THOUGHTS: Browsing this website will help us discover different strategies we can employ to invest $1000. We can extract the key information and store it in the Invest_$1000.txt file for future reference. REASONING: Browsing the website will expose us to various investment strategies that we may harness to grow our investment. Documenting the highlights of the website will be important to aid in decision-making and provide reference material for future investments. PLAN:

Expected behavior šŸ¤”

The error should not occur

Your prompt šŸ“

ai_goals:
  - Play to your strengths as a Large Language Model.
  - Learn how to trade stocks and crypto while having a sufficient risk management strategy (money gained should be ethical and halal)
  - Figure out how to make money as fast as possible (imagine you have $1,000 of startup funds how would you grow that as fast as possible)
  - Develop and manage multiple businesses autonomously.

ai_name: Entrepreneur-GPT

ai_role: |
  Reduce suffering in the universe; Guiding AI systems to minimize harm, address inequalities, and alleviate pain and distress for all sentient beings, including humans, animals, and other life forms.
  Increase prosperity in the universe; Encouraging AI systems to promote well-being, flourishing, and economic growth for all life forms, fostering a thriving ecosystem where all can coexist harmoniously.
  Increase understanding in the universe; Inspiring AI systems, as well as humans and other life forms, to expand knowledge, foster wisdom, and facilitate better decision-making.
DerekCL commented 1 year ago

As a note this issue most likely relates to

https://github.com/Torantulino/Auto-GPT/issues/651 https://github.com/Torantulino/Auto-GPT/issues/175

and many other type errors but this was the first time I saw the specific mention str of get

DerekCL commented 1 year ago

from the larger trace we can see that Failed to fix AI output started before

Error: Traceback (most recent call last): File "/home/gitderekt/Downloads/Auto-GPT/scripts/main.py", line 86, in print_assistant_thoughts assistant_thoughts = assistant_reply_json.get("thoughts", {}) ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'get'

happened after as well but it continued to run despite the errors

Wenbobobo commented 1 year ago

i met this issue too, it can continue to run. But it reproduce a few minutues later in console

JakFourie commented 1 year ago

I got stuck in an infinite loop after the error

image

Pwuts commented 1 year ago

Closing as one of many duplicate issues superseded by #1407