MetaGPT icon indicating copy to clipboard operation
MetaGPT copied to clipboard

raised JSONDecodeError

Open HuZixia opened this issue 2 years ago • 1 comments

Bug description

Executing python code:python startup.py "写个类似今日头条的推荐系统"

Error reported as follows:raised JSONDecodeError image

So, the error caused by incorrect json format. At the same time, I find the json format is different elsewhere, as follows: image

Now, there are two questions, one is how to fix the bug, the other is why json format annotations are different? Is it random?

Bug solved method

The first question can fix by setting "REPAIR_LLM_OUTPUT: true" in key.yaml. The program runs normally after modification.

image

The Second question, why json format annotations are different? Is it random? I don't know the answer. Please tell me if you know anything.

Environment information

  • LLM type and model name: gpt-4-1106-preview
  • System version: macOS Sonoma Version 14.2.1
  • Python version: Python 3.11

HuZixia avatar Jan 14 '24 12:01 HuZixia

json is from LLM, so it is random. We have to handle it to make it more standardized.

voidking avatar Jan 16 '24 02:01 voidking

Add the second way to fix bug about raised JSONDecodeError: Add prompt "Delete comments in json" of FORMAT_CONSTRAINT in action_node.py, as follows:

raised JSONDecodeError as follows: image

add "Delete comments in json", solve the problem: WechatIMG2169

HuZixia avatar Jan 25 '24 14:01 HuZixia