QwenLM / Qwen

The official repo of Qwen (通义千问) chat & pretrained large language model proposed by Alibaba Cloud.
Apache License 2.0
13.59k stars 1.11k forks source link

JSON format error in create_pandas_dataframe_agent #919

Closed Haxeebraja closed 7 months ago

Haxeebraja commented 9 months ago

I am getting JSON format error:

agent = create_pandas_dataframe_agent( ChatOpenAI(model_name="Qwen", openai_api_base="http://localhost:8787/v1", openai_api_key="EMPTY", streaming=False), df, verbose=True, agent_type=AgentType.OPENAI_FUNCTIONS, agent_executor_kwargs={"handle_parsing_errors":True} )

agent.run("how many rows are there?")

Entering new AgentExecutor chain... Could not parse tool input: {'name': 'python_repl_ast', 'arguments': 'df.shape[0]'} because the arguments is not valid JSON.Invalid or incomplete response Please check that the tool input is correctly formatted and that all required fields are included.

Finished chain. ' Please check that the tool input is correctly formatted and that all required fields are included.'

jklj077 commented 9 months ago

Hi, which model were you using (esp. the size of the model)? For this error, it seems the model generated single quotes instead of double quotes for this prompt, which is invalid for JSON. However, the semantics of the generated content also seems erroneous. Bigger models may performer better.

请问使用的是多大的模型呀?只看这个错误的话,应该是模型本身不太稳定,JSON需要双信号,模型输出单引号了。但模型生成内容本身好像也有问题。更大的模型在这类问题上可能有改善。

JianxinMa commented 9 months ago

json5.loads can load {'name': 'python_repl_ast', 'arguments': 'df.shape[0]'} just fine. I'm not sure why langchain is using json.loads instead json5.

Normally this shouldn't happen, as Qwen usually outputs double quotes instead of single quotes. I wonder if there is any misleading context injected by langchain.

chuangzhidan commented 4 months ago

I am getting JSON format error:

agent = create_pandas_dataframe_agent( ChatOpenAI(model_name="Qwen", openai_api_base="http://localhost:8787/v1", openai_api_key="EMPTY", streaming=False), df, verbose=True, agent_type=AgentType.OPENAI_FUNCTIONS, agent_executor_kwargs={"handle_parsing_errors":True} )

agent.run("how many rows are there?")

Entering new AgentExecutor chain... Could not parse tool input: {'name': 'python_repl_ast', 'arguments': 'df.shape[0]'} because the arguments is not valid JSON.Invalid or incomplete response Please check that the tool input is correctly formatted and that all required fields are included.

Finished chain. ' Please check that the tool input is correctly formatted and that all required fields are included.'

可以请教下下你是怎么部署的api服务,用的哪个脚本,我用的自己的flask,完全不行