[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支持吧

相关推荐
Bellafu66639 分钟前
selenium常用的等待有哪些?
python·selenium·测试工具
小白学大数据1 小时前
Python爬虫常见陷阱:Ajax动态生成内容的URL去重与数据拼接
爬虫·python·ajax
2401_841495643 小时前
【计算机视觉】基于复杂环境下的车牌识别
人工智能·python·算法·计算机视觉·去噪·车牌识别·字符识别
大怪v3 小时前
【搞发🌸活】不信书上那套理论!亲测Javascript能卡浏览器Reader一辈子~
javascript·html·浏览器
Adorable老犀牛3 小时前
阿里云-ECS实例信息统计并发送统计报告到企业微信
python·阿里云·云计算·企业微信
西陵3 小时前
Nx带来极致的前端开发体验——任务缓存
前端·javascript·架构
倔强青铜三3 小时前
苦练Python第66天:文件操作终极武器!shutil模块完全指南
人工智能·python·面试
倔强青铜三3 小时前
苦练Python第65天:CPU密集型任务救星!多进程multiprocessing模块实战解析,攻破GIL限制!
人工智能·python·面试
Panda__Panda3 小时前
docker项目打包演示项目(数字排序服务)
运维·javascript·python·docker·容器·c#
Lris-KK4 小时前
力扣Hot100--94.二叉树的中序遍历、144.二叉树的前序遍历、145.二叉树的后序遍历
python·算法·leetcode