OpenBMB / OpenBMB/XAgent

Error in task_handler 和 NoneType 错误

Open
#391 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
8.5k
Forks
905
PR merge metrics
No merged PRs in 30d

Description

Issue Description / 问题描述

用GTP3.5 显示的事Erro in task....
用GPT4 则出现 NoneType错误。 / 请详细描述您遇到的错误或问题。

Steps to Reproduce / 复现步骤

在codebase, 严格按照示例走。 用的命令行,提示词是:
Search the rank of Tsinghua University in computer science field.

Please provide the specific steps to reproduce the error. / 请提供复现错误的具体步骤。

Expected Behavior / 预期行为

Describe the behavior you expected to see. / 请描述您期望的正确行为。

Environment / 环境信息

github上的 codespace
conda
docker compose

  • Operating System / 操作系统:
  • Python Version / Python 版本:
  • Other Relevant Information / 其他相关信息:

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

GPT 4:
-=-=-=-=-=-=-= GENERATE INITIAL_PLAN -=-=-=-=-=-=-=
Constructing an Agent: PlanGenerateAgent
chatcompletion: using gpt-4
Traceback (most recent call last):
File "/workspaces/XAgent/XAgentServer/server.py", line 104, in interact
task_handler.outer_loop()
File "/workspaces/XAgent/XAgent/workflow/task_handler.py", line 82, in outer_loop
self.plan_agent.initial_plan_generation(
File "/workspaces/XAgent/XAgent/workflow/plan_exec.py", line 164, in initial_plan_generation
new_message , _ = agent.parse(
^^^^^^^^^^^^
File "/workspaces/XAgent/XAgent/agent/plan_generate_agent/agent.py", line 49, in parse
return self.generate(
^^^^^^^^^^^^^^
File "/workspaces/XAgent/XAgent/agent/base_agent.py", line 121, in generate
response = objgenerator.chatcompletion(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/tenacity/init.py", line 289, in wrapped_f
return self(f, *args, **kw)
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/tenacity/init.py", line 379, in call
do = self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/tenacity/init.py", line 314, in iter
return fut.result()
^^^^^^^^^^^^
File "/opt/conda/envs/xagent/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/xagent/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/tenacity/init.py", line 382, in call
result = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/workspaces/XAgent/XAgent/ai_functions/request/obj_generator.py", line 72, in chatcompletion
response = self.function_call_refine(kwargs,response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/XAgent/XAgent/ai_functions/request/obj_generator.py", line 194, in function_call_refine
function_schema = list(filter(lambda x: x['name'] == response['choices'][0]['message']['function_call']['name'],req_kwargs['functions']))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/XAgent/XAgent/ai_functions/request/obj_generator.py", line 194, in
function_schema = list(filter(lambda x: x['name'] == response['choices'][0]['message']['function_call']['name'],req_kwargs['functions']))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/workspaces/XAgent/command.py", line 273, in task_handler
server.interact(interaction=interaction)
File "/workspaces/XAgent/XAgentServer/server.py", line 106, in interact
raise XAgentRunningError(str(e)) from e
XAgentServer.exts.exception_ext.XAgentRunningError: 'NoneType' object is not subscriptable
Error in task_handler of 1efc760dc4ea43c2a93b0f1a0bbda3b7: 'NoneType' object is not subscriptable

=================
GPT 3.5
-=-=-=-=-=-=-= GENERATE INITIAL_PLAN -=-=-=-=-=-=-=
Constructing an Agent: PlanGenerateAgent
chatcompletion: using gpt-3.5-turbo-16k
Traceback (most recent call last):
File "/workspaces/XAgent/XAgentServer/server.py", line 104, in interact
task_handler.outer_loop()
File "/workspaces/XAgent/XAgent/workflow/task_handler.py", line 82, in outer_loop
self.plan_agent.initial_plan_generation(
File "/workspaces/XAgent/XAgent/workflow/plan_exec.py", line 178, in initial_plan_generation
subtasks = json5.loads(new_message["function_call"]["arguments"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/lib.py", line 106, in loads
ast, err, _ = parser.parse()
^^^^^^^^^^^^^^
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 19, in parse
self.grammar()
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 160, in grammar
self._seq(
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 102, in _seq
rule()
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 172, in sp
self._star(self.ws)
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 93, in _star
rule()
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 175, in ws
self._choose(
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 109, in _choose
rule()
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 190, in ws__c0
self._ch(' ')
File "/opt/conda/envs/xagent/lib/python3.11/site-packages/json5/parser.py", line 117, in _ch
if p < self.end and self.msg[p] == ch:
~~~~~~~~^^^
KeyError: 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/workspaces/XAgent/command.py", line 273, in task_handler
server.interact(interaction=interaction)
File "/workspaces/XAgent/XAgentServer/server.py", line 106, in interact
raise XAgentRunningError(str(e)) from e
XAgentServer.exts.exception_ext.XAgentRunningError: 0
Error in task_handler of 5cd5ce8d237245ee8d67164618d20d18: 0

If possible, please provide relevant screenshots or logs of the error. / 如果可能,请提供相关的错误截图或日志文件。

Additional Notes / 其他备注

If you have any additional information or notes, please add them here. / 如果有其他补充信息,请在此处添加。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with XAgent/ai_functions/request/obj_generator.py, especially chatcompletion and function_call_refine, then trace the callers in XAgent/workflow/plan_exec.py and task_handler.py. Reproduce the prompt with GPT-3.5 and GPT-4 in the reported Codespace environment, comparing responses with missing function_call data or invalid arguments. Done should mean the task no longer fails with the reported NoneType or parsing errors, with the expected behavior confirmed.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker-compose, python
Domain
ai, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.