pandas dataframe agent 调用报错,提示Parsing LLM output produced both a final answer and a parse-able action #2463
-
尝试调用langchain 提供的 pandas dataframe agent, 输入到模型的提示词是这样的,希望chatglm3 能在action 中输出函数,但大模型输出的结果中包含action 和 final answer, 导致langchain报错。想问下原因是chatglm3 还需要微调,还是需要额外配置? debug 看了下输入模型的提示词是 """Human: python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer. Use the following format: Question: the input question you must answer This is the result of
Begin! 在qwen 模型上测试这个case,只会输出thought 和action, 不包含final answer |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
🤖 你好,@samosun! 我是Dosu,一个友好的机器人。我在这里以提供帮助,解决bug,回答问题,并帮助你成为一个贡献者。虽然我不是人类,但我会尽力为你提供帮助,在等待人类维护者的同时提供支持。希望我们能够一起愉快的进行问题解决! 根据您提供的信息,我认为这个问题可能是由于ChatGLM3模型的输出格式与Langchain-Chatchat的pandas dataframe agent预期的格式不匹配导致的。在Langchain-Chatchat中, 这种行为可能会导致错误,如果模型的输出不符合预期的格式,或者模型产生的输出同时包含工具调用和最终答案。 要解决这个问题,您可能需要微调ChatGLM3模型,以确保其输出符合预期的格式。或者,您可以修改 这是相关的代码片段: if "tool_call" in text:
tool_name_end = text.find("```")
tool_name = text[:tool_name_end].strip()
input_para = text.split("='")[-1].split("'")[0]
action_json = {
"action": tool_name,
"action_input": input_para
}
else:
action_json = {
"action": "Final Answer",
"action_input": text
} 您可以在这里找到完整的代码。 希望这个答案能帮助您解决问题。如果您有任何其他问题或需要进一步的澄清,请随时告诉我。 SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
@dosu-bot 可以给我一个 使用 ChatGLM3Agent 的例子吗? |
Beta Was this translation helpful? Give feedback.
-
@dosu-bot 提供一个ChatGLM3Agent 使用calculate 工具的例子, from server.agent.tools import calculate |
Beta Was this translation helpful? Give feedback.
-
langchain 默认还是适配GPT4的,glm3估计你很难控制输出 |
Beta Was this translation helpful? Give feedback.
langchain 默认还是适配GPT4的,glm3估计你很难控制输出