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

使用LangChain的ainvoke异步调用链时出现错误的问题求助

使用LangChain的ainvoke异步调用链时出现错误的问题求助

我正在写一个异步函数,想结合LangChain的ainvoke方法来调用我的链,但运行时碰到了报错,想请教大家怎么解决。

我的代码如下:

async def get_result(template, user_question):
    prompt = ChatPromptTemplate.from_template(template)
    model = mixtral_llm
    sql_response = (
        RunnablePassthrough.assign(schema=get_schema)
        | prompt
        | model.bind(stop=["Question"])
        | StrOutputParser()
    )
    sql_query = await sql_response.ainvoke({"question":user_question})

收到的错误信息:

sql_query = await sql_response.ainvoke({"question":user_question})
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/runnables/base.py", line 2536, in ainvoke
    input = await step.ainvoke(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/langchain_core/runnables/base.py", line 4537, in ainvoke
    return await self.bo...

看起来是链的异步调用环节出了问题,有没有大佬能帮我排查下问题所在呀?

备注:内容来源于stack exchange,提问作者currently_into_ai

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.17 11:00:32