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
167.38k stars 44.21k forks source link

`Parsing attempt(s) failed` when continuing with agent's self-made settings #6575

Closed zac-thee-mac closed 4 months ago

zac-thee-mac commented 9 months ago

⚠️ Search for existing issues first ⚠️

Which Operating System are you using?

Linux

Which version of AutoGPT are you using?

Master (branch)

Do you use OpenAI GPT-3 or GPT-4?

GPT-4

Which area covers your issue best?

Commands

Describe your issue.

I approved my agent's plan and was met with these errors. I have replaced the specific question it was asking me with 'QUESTION_BEING_ASKED.'

Continue with these settings? [Y/n] y
2023-12-16 11:55:58,207 INFO  message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=22096 request_id=35fa8e447ef996b922dcaca08245c633 response_code=200
2023-12-16 11:55:58,216 WARNING  Parsing attempt #1 failed: Validation of response failed:
  'thoughts' is a required property

Failed validating 'required' in schema:
    {'properties': {'command': {'properties': {'args': {'type': 'object'},
                                               'name': {'type': 'string'}},
                                'required': ['name', 'args'],
                                'type': 'object'},
                    'thoughts': {'properties': {'observations': {'description': 'Relevant '
                                                                                'observations '
                                                                                'from '
                                                                                'your '
                                                                                'last '
                                                                                'action '
                                                                                '(if '
                                                                                'any)',
                                                                 'type': 'string'},
                                                'plan': {'description': 'Short '
                                                                        'markdown-style '
                                                                        'bullet '
                                                                        'list '
                                                                        'that '
                                                                        'conveys '
                                                                        'the '
                                                                        'long-term '
                                                                        'plan',
                                                         'type': 'string'},
                                                'reasoning': {'type': 'string'},
                                                'self_criticism': {'description': 'Constructive '
                                                                                  'self-criticism',
                                                                   'type': 'string'},
                                                'speak': {'description': 'Summary '
                                                                         'of '
                                                                         'thoughts, '
                                                                         'to '
                                                                         'say '
                                                                         'to '
                                                                         'user',
                                                          'type': 'string'},
                                                'text': {'description': 'Thoughts',
                                                         'type': 'string'}},
                                 'required': ['text',
                                              'reasoning',
                                              'self_criticism',
                                              'plan',
                                              'speak'],
                                 'type': 'object'}},
     'required': ['thoughts', 'command'],
     'type': 'object'}

On instance:
    {'question': 'QUESTION_BEING_ASKED'};
  'command' is a required property

Failed validating 'required' in schema:
    {'properties': {'command': {'properties': {'args': {'type': 'object'},
                                               'name': {'type': 'string'}},
                                'required': ['name', 'args'],
                                'type': 'object'},
                    'thoughts': {'properties': {'observations': {'description': 'Relevant '
                                                                                'observations '
                                                                                'from '
                                                                                'your '
                                                                                'last '
                                                                                'action '
                                                                                '(if '
                                                                                'any)',
                                                                 'type': 'string'},
                                                'plan': {'description': 'Short '
                                                                        'markdown-style '
                                                                        'bullet '
                                                                        'list '
                                                                        'that '
                                                                        'conveys '
                                                                        'the '
                                                                        'long-term '
                                                                        'plan',
                                                         'type': 'string'},
                                                'reasoning': {'type': 'string'},
                                                'self_criticism': {'description': 'Constructive '
                                                                                  'self-criticism',
                                                                   'type': 'string'},
                                                'speak': {'description': 'Summary '
                                                                         'of '
                                                                         'thoughts, '
                                                                         'to '
                                                                         'say '
                                                                         'to '
                                                                         'user',
                                                          'type': 'string'},
                                                'text': {'description': 'Thoughts',
                                                         'type': 'string'}},
                                 'required': ['text',
                                              'reasoning',
                                              'self_criticism',
                                              'plan',
                                              'speak'],
                                 'type': 'object'}},
     'required': ['thoughts', 'command'],
     'type': 'object'}

On instance:
    {'question': 'QUESTION_BEING_ASKED.'}
2023-12-16 11:56:22,272 INFO  message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=23382 request_id=6c5ab150ba58f0a2ce5deb827330625b response_code=200
2023-12-16 11:56:22,274 WARNING  Parsing attempt #2 failed: Action for current cycle already set
2023-12-16 11:56:44,595 INFO  message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=21788 request_id=a1c7ea2d533214c9d47c310eff164762 response_code=200
2023-12-16 11:56:44,596 WARNING  Parsing attempt #3 failed: unmatched '}' (<unknown>, line 1)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/zach/.cache/pypoetry/virtualenvs/agpt-DG8NZSYU-py3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/.cache/pypoetry/virtualenvs/agpt-DG8NZSYU-py3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/zach/.cache/pypoetry/virtualenvs/agpt-DG8NZSYU-py3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/.cache/pypoetry/virtualenvs/agpt-DG8NZSYU-py3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/.cache/pypoetry/virtualenvs/agpt-DG8NZSYU-py3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/app/cli.py", line 177, in run
    run_auto_gpt(
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/core/runner/client_lib/utils.py", line 60, in wrapper
    return asyncio.run(f(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/anaconda3/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/zach/anaconda3/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/anaconda3/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/app/main.py", line 292, in run_auto_gpt
    await run_interaction_loop(agent)
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/app/main.py", line 489, in run_interaction_loop
    ) = await agent.propose_action()
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/agents/features/watchdog.py", line 36, in propose_action
    command_name, command_args, thoughts = await super(
                                           ^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/agents/base.py", line 251, in propose_action
    response = await self.llm_provider.create_chat_completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py", line 389, in create_chat_completion
    parsed_response = completion_parser(response_message)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/agents/base.py", line 260, in <lambda>
    completion_parser=lambda r: self.parse_and_process_response(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/agents/agent.py", line 188, in parse_and_process_response
    ) = self.prompt_strategy.parse_response_content(llm_response)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py", line 394, in parse_response_content
    assistant_reply_dict = extract_dict_from_response(response["content"])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/Documents/AutoGPT/git/autogpts/autogpt/autogpt/json_utils/utilities.py", line 29, in extract_dict_from_response
    result = ast.literal_eval(response_content)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/anaconda3/lib/python3.11/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zach/anaconda3/lib/python3.11/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<unknown>", line 1
    {"question": "QUESTION_BEING_ASKED"}}}
                                                                                                                                                                                                                             ^
SyntaxError: unmatched '}'

Upload Activity Log Content

No response

Upload Error Log Content

No response

CryptVenture commented 9 months ago

Having this same issue. Any fix on this?

nightsky78 commented 9 months ago

I have the same issue. My understanding is that the openai interface is not answering in the JSON format autogpt is expecting. Here is what is specified in the prompt by autogpt.

_---------------- SYSTEM ----------------- Respond with pure JSON. The JSON object should be compatible with the TypeScript type Response from the following: interface Response { thoughts: { // Relevant observations from your last action (if any) observations: string; // Thoughts text: string; reasoning: string; // Constructive self-criticism selfcriticism: string; // Short markdown-style bullet list that conveys the long-term plan plan: string; // Summary of thoughts, to say to user speak: string; }; command: { name: string; args: Record<string, any>; }; }

_And here is a sample of the answer from openai. 2023-12-26 14:48:47,342 DEBUG Parsing failed on response: '''{'role': 'assistant', 'content': '{"thoughts": {\n"observations": "The user agreed to pursue \'AWS Certified Solutions Architect – Associate\' certification and he/she can dedicate ~10 hours per week for studying. A basic outline for the training plan has been created.",\n"text": "The user is receptive to the AWS Certified Solutions Architect – Associate certification and has a certain amount of time each week they can dedicate to it. We\'ve started off with a basic structure for the study plan, but it still needs to be fleshed out with the remaining topics and subtopics.",\n"reasoning": "Now that I have a rough duration per week (i.e., 10 hours), I can break down the syllabus and distribute it over multiple weeks to create a detailed training plan. Given the nature of AWS Certified Solutions Architect – Associate certification, the study materials should cover a blend of theoretical concepts, hands-on lab exercise, recommended reading materials and finally, mock tests for thorough exam preparation.",\n"self_criticism": "The initial study plan lacks sufficient details; It\'s much too generic. It needs to be enhanced with further necessary topics, their sub topics, suitable resources, and a well-distributed time table.",\n"plan": "- Analyze the syllabus of AWS Certified Solutions Architect – Associate certification.\n- Break down the syllabus into manageable parts based on the user\'s study hours.\n- Include an appropriate mix of study materials like theoretical content, practical lab exercises and mock tests into the study plan.\n- Create an equally distributed time table for the effective study across the weeks.",\n"speak": "I have drafted an initial outline for the study plan. I am now going to analyze the syllabus of the AWS Certified Solutions Architect – Associate certification in detail and finalize the training plan including necessary topics, time distribution, and resources. Please wait." },\n\n"command": {\n"name": "websearch",\n"args": { "query": "AWS Certified Solutions Architect – Associate syllabus"}\n}}'}'''

nightsky78 commented 9 months ago

I check the request and the response for a few examples. The answer from openai matches the JSON requirements in the prompt. Does not help to solve the issue, but the fault is not with openAI.

OSH212 commented 9 months ago

running on the same, consistent issue. On MacOS.

Anybody found a fix ?

majormer commented 7 months ago

Same issue on Windows.

majormer commented 7 months ago

2024-02-22 07:54:11,380 INFO HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK" 2024-02-22 07:54:11,383 WARNING Parsing attempt #1 failed: Action for current cycle already set 2024-02-22 07:54:43,062 INFO HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK" 2024-02-22 07:54:43,064 WARNING Parsing attempt #2 failed: Action for current cycle already set 2024-02-22 07:55:07,185 INFO HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK" 2024-02-22 07:55:07,190 WARNING Parsing attempt #3 failed: Action for current cycle already set Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\major\AppData\Local\pypoetry\Cache\virtualenvs\agpt-IGpLPcbj-py3.11\Lib\site-packages\click\core.py", line 1157, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\major\AppData\Local\pypoetry\Cache\virtualenvs\agpt-IGpLPcbj-py3.11\Lib\site-packages\click\core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "C:\Users\major\AppData\Local\pypoetry\Cache\virtualenvs\agpt-IGpLPcbj-py3.11\Lib\site-packages\click\core.py", line 1666, in invoke rv = super().invoke(ctx) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\major\AppData\Local\pypoetry\Cache\virtualenvs\agpt-IGpLPcbj-py3.11\Lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\major\AppData\Local\pypoetry\Cache\virtualenvs\agpt-IGpLPcbj-py3.11\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\major\AppData\Local\pypoetry\Cache\virtualenvs\agpt-IGpLPcbj-py3.11\Lib\site-packages\click\decorators.py", line 33, in new_func return f(get_current_context(), *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\app\cli.py", line 20, in cli ctx.invoke(run) File "C:\Users\major\AppData\Local\pypoetry\Cache\virtualenvs\agpt-IGpLPcbj-py3.11\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\app\cli.py", line 181, in run run_auto_gpt( File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\core\runner\client_lib\utils.py", line 60, in wrapper return asyncio.run(f(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\major\anaconda3\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\major\anaconda3\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\major\anaconda3\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\app\main.py", line 292, in run_auto_gpt await run_interaction_loop(agent) File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\app\main.py", line 495, in run_interaction_loop ) = await agent.propose_action() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\agents\features\watchdog.py", line 36, in propose_action command_name, command_args, thoughts = await super( ^^^^^^^^^^^^ File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\agents\base.py", line 251, in propose_action response = await self.llm_provider.create_chat_completion( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\core\resource\model_providers\openai.py", line 460, in create_chat_completion response.parsed_result = completion_parser(assistant_msg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\agents\base.py", line 260, in <lambda> completion_parser=lambda r: self.parse_and_process_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\agents\agent.py", line 198, in parse_and_process_response self.event_history.register_action( File "L:\ai\AutoGPT\autogpts\autogpt\autogpt\models\action_history.py", line 151, in register_action raise ValueError("Action for current cycle already set") ValueError: Action for current cycle already set Press any key to continue . . .

EffiSciencesResearch commented 7 months ago

Same issue here

wibimaster commented 7 months ago

Same here :(

github-actions[bot] commented 5 months ago

This issue has automatically been marked as stale because it has not had any activity in the last 50 days. You can unstale it by commenting or removing the label. Otherwise, this issue will be closed in 10 days.

github-actions[bot] commented 4 months ago

This issue was closed automatically because it has been stale for 10 days with no activity.