You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LangChain ConversationChain传递多参数触发ValueError的技术求助

问题:LangChain ConversationChain无法传入多参数(input+context)

我基于HuggingFace和LangChain开发内部LLM,尝试向ConversationChain对象同时传入问题(input)和上下文(context)参数,但该对象不支持多输入:仅传入单个input时功能完全正常,传入两个参数则触发错误。

报错场景

无论是直接传入参数:

conversation.run(input=input, context=context)

还是通过字典解包传入:

inputs = {
    'input': input,
    'context': context
}

conversation.run(**inputs)

都会收到以下错误:

ValueError: One input key expected got ['input', 'context']

其他尝试

尝试使用.generate()、.predict()方法,或是直接调用conversation(),均出现相同问题。我试过社区中的相关解决方法,但又引发了一系列新错误。

文档矛盾点

查阅LangChain官方文档时,发现示例代码中直接向.run()传入了context参数,但我使用最新版LangChain却无法复现该行为,不确定是文档未更新还是版本适配问题,寻求解决方案。

文档示例代码:

# 假设我们有一个多输入链,接收'question'字符串和'context'字符串:
question = "What's the temperature in Boise, Idaho?"
context = "Weather report for Boise, Idaho on 07/03/23..."
chain.run(question=question, context=context)

内容的提问来源于stack exchange,提问作者cooldude3139

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 02:23:24