Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行python run.py 的时候报错KeyError: 0,错误定位在plan_exec.py line 178 #396

Open
PowerQi opened this issue Apr 16, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@PowerQi
Copy link

PowerQi commented Apr 16, 2024

Issue Description / 问题描述

执行python run.py 的时候报错KeyError: 0,错误定位在plan_exec.py line 178

Steps to Reproduce / 复现步骤

在XAgent-server容器的实例,控制台执行python run.py --task "- I want to play game of 24, which use +, -, *, / to get 24 using 4 numbers. Each number can be used only once. Please give me 5 example combinations of numbers that can get 24. Write codes and show me!" --config-file "assets/config.yml"

Expected Behavior / 预期行为

按要求返回5个24游戏的示例

Environment / 环境信息

image

Error Screenshots or Logs / 错误截图或日志

image

Additional Notes / 其他备注

GPT4接口调用成功,有调用记录

@PowerQi PowerQi added the bug Something isn't working label Apr 16, 2024
@LostQuant
Copy link

Same error, suspecting this is something to do with the "TODO" label ?

line 163: "# TODO: not robust. dispatcher generated prompt may not contain these specified placeholders?"

BTW, this is my env (tho its probably not relevant at all :)

Name Version Build Channel

json5 0.9.25 pypi_0 pypi
python 3.11.7 he1021f5_0
pycparser 2.22 pypi_0 pypi

@LostQuant
Copy link

LostQuant commented May 1, 2024

After a few rounds of trial and error, this error is because, somehow, the new_message["function_call"]["arguments"] in line 178 of plan_exec.py is already an python object, causing the `json5.loads function fail to parse it.

subtasks = json5.loads(new_message["function_call"]["arguments"])

A quickfix is bypassing the json5.loads and simply assign the object to subtasks, unless it is indeed a STR or BYTES e.g.:

        subtasks = new_message["function_call"]["arguments"] 

        # To preserve the original flow in case `subtasks` is a string or bytes
        if isinstance(subtasks, (str, bytes)):
            subtasks = json5.loads(subtasks)

@LostQuant
Copy link

It turns out that everytime when its trying to parse serialized objects using JSON5.loads, the objects may NOT be serialized (but a simple DICT). So has to do the check everywhere when JSON5.loads is called. (at least under the OPENAI mode)

Raised the PR above hopefully the maintainer will approve and checkin the main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants