Closed kianjoooo1 closed 1 year ago
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?"
}
}
}
duplicate of https://github.com/Torantulino/Auto-GPT/issues/701
I do get similar error everytime i give a feedback, the next 'y' give me unavailable JSON
duplicate of #701
@javabudd how do i fix then?
I wonder if there might be another machine-readable format that might be suitable here. JSON is especially finicky. I wonder if something like TOML or XML might be more resilient. If push comes to shove, maybe just using header lines between fields:
:: thoughts.text ::
I should do something super-interesting nobody's thought of before.
:: thoughts.reasoning ::
Be sure to work carefully.
:: command.name ::
do_nothing
:: command.args.0 ::
First arg
:: command.args.1 ::
Second arg
Obviously it'd be better to use a mature parsing library but the above would be reasonably straight-forward to implement and would obviate all the issues around proper quoting and commas.
I fixed it for me by telling it this. : give last json again but without explanations. start at {
I'm having the same issue too.
Same issue with the initial comments before the first bracket. (Thanks for this solution, let me know if I can help).
I fixed it for me by telling it this. : give last json again but without explanations. start at {
Or try this "give last json again but without explanations. start at {. Never again write ``` or explanations before the json. Answer in json only. Only ever start at {"
@GitGodius where do I add the "give last json again... ?
@GitGodius where do I add the "give last json again... ?
After you tell autogpt its goals and after a few responses it answers with Error: invalid Json. Instead of saying y or n you paste my input. Maybe one can even integrate it in the original goal
I wonder if there might be another machine-readable format that might be suitable here. JSON is especially finicky. I wonder if something like TOML or XML might be more resilient. If push comes to shove, maybe just using header lines between fields:
:: thoughts.text :: I should do something super-interesting nobody's thought of before. :: thoughts.reasoning :: Be sure to work carefully. :: command.name :: do_nothing :: command.args.0 :: First arg :: command.args.1 :: Second arg
Obviously it'd be better to use a mature parsing library but the above would be reasonably straight-forward to implement and would obviate all the issues around proper quoting and commas.
Fine-tuning the models could also give more consistant JSON responses, in addition to reduce the prompt length. Models could be saved in the repo, then uploaded on the first launch if they don't exist in the user's OpenAI account.
I tried "give last json again but without explanations. start at {. Never again write ``` or explanations before the json. Answer in json only. Only ever start at {" but immediately it errored after one prompt. Here is the whole experience:
`AUTO THOUGHTS: I suggest we start by brainstorming some ideas. What kind of projects do you have in mind? REASONING: Before taking action, it is important to understand the goal and context. By gathering more information, I can provide better recommendations on what commands to use next. PLAN:
or explanations before the json. Answer in json only. Only ever start at { SYSTEM: Human feedback: give last json again but without explanations. start at {. Never again write
or explanations before the json. Answer in json only. Only ever start at {
AUTO THOUGHTS: I suggest we start by brainstorming some ideas. What kind of projects do you have in mind?
REASONING: Before taking action, it is important to understand the goal and context. By gathering more information, I can provide better recommendations on what commands to use next.
PLAN:or explanations before the json. Answer in json only. Only ever start at {" into your core programming so we avoid this error: Error: Invalid JSON SYSTEM: Human feedback: can you add "give last json again but without explanations. start at {. Never again write
or explanations before the json. Answer in json only. Only ever start at {" into your core programming so we avoid this error: Error: Invalid JSON
Error: Invalid JSON
I apologize for the inconvenience caused. I will make sure to follow the correct formatting in future replies. Additionally, I will inform my developers to ensure that the formatting guidelines are updated in my core programming. Now, let's get back to the task at hand. What kind of projects are you interested in working on that require my assistance?
NEXT ACTION: COMMAND = Error: ARGUMENTS = Invalid JSON
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for Auto...
Input:give last json again but without explanations. start at {. Never again write or explanations before the json. Answer in json only. Only ever start at { SYSTEM: Human feedback: give last json again but without explanations. start at {. Never again write
or explanations before the json. Answer in json only. Only ever start at {
AUTO THOUGHTS: I suggest we start by brainstorming some ideas. What kind of projects do you have in mind?
REASONING: Before taking action, it is important to understand the goal and context. By gathering more information, I can provide better recommendations on what commands to use next.
PLAN:Any thoughts?
I found a solution maybe, didn't had alot of time to check it out but seems it's helping. 1.add :
import json import re
under the last import.... (after line 20)
2.add :
def get_command(assistant_reply): try: # Use regex to extract the JSON object from the response json_string = re.search(r'\{(?:[^{}]|(?R))*\}', assistant_reply).group() # Parse the JSON object command_data = json.loads(json_string) command_name = command_data['command'] arguments = command_data['arguments'] except Exception as e: command_name = "error" arguments = str(e) return command_name, arguments
Between line 71 print() and line 87 Def print_"" and align the def get above the line 87def same indent and the rest 1 indent align above the rest like global at line 89
All edits to do on the file main.py
I found the import easy enough but could you clarify where you mean to paste part 2, please?
I marked lines 71 and 87 but don't understand how to place what you wrote. Do I replace something or add it in between?
I found a solution maybe, didn't had alot of time to check it out but seems it's helping. 1.add :
import json import re
under the last import.... (after line 20)
2.add :
def get_command(assistant_reply): try: # Use regex to extract the JSON object from the response json_string = re.search(r'\{(?:[^{}]|(?R))*\}', assistant_reply).group() # Parse the JSON object command_data = json.loads(json_string) command_name = command_data['command'] arguments = command_data['arguments'] except Exception as e: command_name = "error" arguments = str(e) return command_name, arguments
Between line 71 print() and line 87 Def print_"" and align the def get above the line 87def same indent and the rest 1 indent align above the rest like global at line 89
All edits to do on the file main.py
is this correct? it didn't work for me.
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.
anyone know what this means? -=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-= SYSTEM: Command do_nothing returned: No action performed. Traceback (most recent call last): File "C:\Users\kiann\AppData\Local\Programs\Python\Python310\lib\site-packages\openai\api_requestor.py", line 672, in _interpret_response_line data = json.loads(rbody) File "C:\Users\kiann\AppData\Local\Programs\Python\Python310\lib\json__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Users\kiann\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\kiann\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\AUTO-GPT\Auto-GPT\scripts\main.py", line 318, in
The web server reported a bad gateway error.
Please try again in a few minutes.
)
C:\AUTO-GPT\Auto-GPT>.git11 '.git11' is not recognized as an internal or external command, operable program or batch file.
closing as a dupe of the many other json issues
Duplicates
Steps to reproduce 🕹
No response
Current behavior 😯
No response
Expected behavior 🤔
No response
Your prompt 📝