Langchain-Chatchat
Langchain-Chatchat copied to clipboard
task = asyncio.create_task(wrap_done( chain.acall({"context": context, "question": query}), callback.done), )添加历史信息参数
你好,我想请问下,我在prompt里添加了chat_history变量, 然后在: task = asyncio.create_task(wrap_done( chain.acall({"context": context, "question": query,“chat_history”:history}), callback.done), ) 里边也添加了chat_hostory参数,但是他为什么报错,说是输入变量只能有一个。
提示模板是:chat_prompt = PromptTemplate(template=prompt_template, input_variables=["question", "context", "chat_history"])
请问是哪里需要修改?
It seems like the issue you're encountering with the chain.acall method and the chat_history parameter is due to how chain.acall is designed to accept its arguments. Typically, chain.acall expects a dictionary with specific keys, and based on your description, it looks like it's expecting a single input, possibly under a key like "input".
If chain.acall is not designed to accept a "chat_history" parameter directly, adding it as you did would indeed cause an error. The method's expected parameters need to align with how you're calling it. Since you've added "chat_history" to your PromptTemplate as an input variable, you'll need to ensure that chain.acall or any method it delegates to is capable of handling this additional parameter.
To resolve this, you should:
- Verify the expected parameters of
chain.acalland adjust your call accordingly. Ifchain.acallis designed to work with a specific structure, your dictionary keys and values must match this expectation. - If
chain.acallcannot be modified to accept"chat_history", consider how this data can be incorporated into the existing parameters in a way that the method can process.
Without more details on the error message or the implementation of chain.acall, this is a general direction to investigate. Ensuring that the parameters you pass match the method's expectations is key to resolving the issue.
Details
Sources
- server/chat/agent_chat.py
- server/chat/chat.py
- webui_pages/dialogue/dialogue.py
- server/agent/custom_agent/ChatGLM3Agent.py
- server/agent/custom_template.py
- server/utils.py
About Dosu This 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.
To continue the conversation, mention @dosu.