OpenBMB / XAgent

An Autonomous LLM Agent for Complex Task Solving
https://blog.x-agent.net/blog/xagent/
Apache License 2.0
8.06k stars 827 forks source link

Error in task_handler 和 NoneType 错误 #391

Open Fishday17 opened 6 months ago

Fishday17 commented 6 months ago

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

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 newmessage , = 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. / 如果有其他补充信息,请在此处添加。
zhaichenhao1889 commented 6 months ago

the same error for me to XAgent Llama model