[bug]langchain agent报错Invalid Format: Missing ‘Action Input:‘ after ‘Action:‘

在学习langchain的agent时候,采用ollama调用本地的deepseek-r1:32b来做一个agent,代码如下:

csharp 复制代码
def create_custom_agent():
    llm = ChatOllama(model="deepseek-r1:32b", temperature=0.5)

    memory = ConversationBufferWindowMemory(
        memory_key="chat_history",
        k=3,
        return_messages=True
    )

    react_template = """
    尽你所能回答以下问题:{input}
    你可以使用以下工具:{tools}
    工具名称列表:{tool_names}

    使用以下格式:
    Question: 您必须回答的输入问题
    Thought: 你应该思考如何解决这个问题
    Action: 要采取的操作,例如 "convert_image"
    Action Input:工具的输入参数
    Observation: 工具的输出结果
    Final Answer:最终答案

    开始!

    Thought:{agent_scratchpad}
    """

    react_prompt = PromptTemplate(
        input_variables=['input', 'tools', 'tool_names', 'agent_scratchpad', 'chat_history'],
        template=react_template
    )

    react_agent = create_react_agent(llm=llm, tools=tools, prompt=react_prompt)
    agent_executor = AgentExecutor(
        agent=react_agent,
        tools=tools,
        memory=memory,
        verbose=True,
        handle_parsing_errors=True,
    )
    return agent_executor

模版参考了官方的https://python.langchain.com/api_reference/_modules/langchain/agents/react/agent.html#create_react_agent ReAct风格链写的,但是在调用的时候一直报错,我寻思32b的模型也不小了,后来果断换了qwen2.5:7b 就行了,哎,deepseek的function calling实在是太差了,希望后续deepseek支持吧

相关推荐
程序员的世界你不懂3 小时前
Appium+python自动化(八)- 认识Appium- 下章
python·appium·自动化
_r0bin_3 小时前
前端面试准备-7
开发语言·前端·javascript·fetch·跨域·class
IT瘾君3 小时前
JavaWeb:前端工程化-Vue
前端·javascript·vue.js
zhang98800003 小时前
JavaScript 核心原理深度解析-不停留于表面的VUE等的使用!
开发语言·javascript·vue.js
恸流失3 小时前
DJango项目
后端·python·django
Julyyyyyyyyyyy5 小时前
【软件测试】web自动化:Pycharm+Selenium+Firefox(一)
python·selenium·pycharm·自动化
蓝婷儿5 小时前
6个月Python学习计划 Day 15 - 函数式编程、高阶函数、生成器/迭代器
开发语言·python·学习
love530love5 小时前
【笔记】在 MSYS2(MINGW64)中正确安装 Rust
运维·开发语言·人工智能·windows·笔记·python·rust
水银嘻嘻6 小时前
05 APP 自动化- Appium 单点触控& 多点触控
python·appium·自动化
狐凄6 小时前
Python实例题:Python计算二元二次方程组
开发语言·python