爱站网关键词查询系统沈阳男科医院好排行

张小明 2025/12/30 21:43:04
爱站网关键词查询系统,沈阳男科医院好排行,做虚拟货币交易网站,wordpress 近期文章 修改day29#xff1a;理解Agent 结构#xff08;LLM Tool Executor#xff09; 一、Agent定义 简单介绍 Agent 能“思考 → 决策 → 调用工具 → 再思考”的 LLM 程序 公式化一点就是#xff1a; Agent LLM Tools Executor它和「问 → 答」最大的区别是#xff1a; LLM …day29理解Agent 结构LLM Tool Executor一、Agent定义 简单介绍Agent 能“思考 → 决策 → 调用工具 → 再思考”的 LLM 程序公式化一点就是Agent LLM Tools Executor它和「问 → 答」最大的区别是LLM 不再只是生成文本而是在“做事”二、Agent 结构总览┌─────────────────────┐ │ User │ └─────────┬───────────┘ │ ┌─────────▼───────────┐ │ Agent │ │ │ │ ┌──────────────┐ │ │ │ LLM │ │ ← 决策中枢大脑 │ └──────┬───────┘ │ │ │ Thought │ │ ┌──────▼───────┐ │ │ │ Tools │ │ ← 外部能力 │ └──────┬───────┘ │ │ │ Action │ │ ┌──────▼───────┐ │ │ │ Executor │ │ ← 执行与控制循环 │ └──────────────┘ │ └─────────────────────┘三、Agent 的三个核心组件重点1️⃣ LLM大脑在 Agent 中LLM 不只是“回答问题”它负责 思考Thought 决策是否用工具 规划先做什么再做什么典型提示词结构你不写LangChain 会自动帮你写Thought: 我需要查询时间 Action: get_current_time Action Input: {} Observation: 2025-12-13 Thought: 我可以回答了 Final Answer: 现在是 2025-12-13 Agent 的本质是让 LLM 输出“结构化思考过程”2️⃣ Tool工具Tool 是什么Tool Agent 能调用的 Python 函数例如- 搜索 - 计算 - 查数据库 - 调 API - 查文件 - 调你写的业务函数在 LangChain 中一个 Tool 至少包含name descriptioncallablefunctionLLM 通过 description 来判断“该不该用这个工具”3️⃣ Executor执行器Executor 是 Agent 的“循环控制器”它负责把 LLM 输出解析成ThoughtActionAction Input调用 Tool把结果塞回给 LLM再让 LLM 思考直到得到 Final Answer可以理解为Executor Agent 的 runtime四、LangChain 中的 Agent 类型认识不分✅ ReAct Agent最重要ReAct Reason ActThought → Action → Observation → Thought → Final 这是 LangChain 默认 最稳定 最好理解 的 Agent 结构后面你学的基本都是它的变体。五、从 0 到 1一个最小 LangChain Agent DemoQwen-PlusStep 0安装依赖langchain0.1.0langchain-openai langchain_classic pip install-r requirements.txtimportdatetimefromlangchain_classic.agentsimportinitialize_agent,AgentTypefromlangchain_core.toolsimporttoolfromlangchain_openaiimportChatOpenAI llmChatOpenAI(modelqwen-plus-latest,temperature0,api_keysk-YOUR-API-KEY,base_urlhttps://dashscope.aliyuncs.com/compatible-mode/v1,)tooldefget_current_time(query:str)-str:获取当前时间returnstr(datetime.datetime.now())tools[get_current_time]agentinitialize_agent(tools,llm,agentAgentType.ZERO_SHOT_REACT_DESCRIPTION,verboseTrue,handle_parsing_errorsTrue)defmain():resagent.invoke({现在是什么时间?})print(res[output])if__name____main__:main()# (day29venv) PS E:\code\xsun_ai_study\week5\day29 python main.py# E:\code\xsun_ai_study\week5\day29\main.py:23: LangChainDeprecationWarning: LangChain agents will continue to be supported, but it is recommended for new use cases to be built with LangGraph. LangGraph offers a more flexible and full-featured framework for building agents, including support for tool-calling, persistence of state, and human-in-the-loop workflows. For details, refer to the [LangGraph documentation](https://langchain-ai.github.io/langgraph/) as well as guides for [Migrating from AgentExecutor](https://python.langchain.com/docs/how_to/migrate_agent/) and LangGraphs [Pre-built ReAct agent](https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/).# agent initialize_agent(tools,### Entering new AgentExecutor chain...# 需要获取当前时间# Action: get_current_time# Action Input: {query: current time}# Observation: 2025-12-14 14:52:24.744312# Thought:Final Answer: 现在是2025年12月14日14点52分24秒。## Finished chain.# 现在是2025年12月14日14点52分24秒。你会看到完整的 Agent 思考链Thought: 我需要知道当前时间 Action: get_current_time Action Input: {} Observation: 2025-12-13 10:32:11 Thought: 我已经知道时间了 Final Answer: 现在是 2025-12-13 10:32:11六、这个 Demo 背后发生了什么非常重要组件做了什么LLMQwen-PlusToolPython 函数AgentReAct 推理模板Executor控制调用循环 这是 90% LangChain Agent 的通用骨架七、Agent 和你之前 RAG 的关系RAGAgent查资料 → 回答思考 → 决策 → 行动单次生成多轮内部循环被动主动无状态或弱状态可引入 Memory Agent 可以“用 RAG 作为工具”
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

h5网站制作平台中文网址

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 创建一个基于Dify离线部署的快速原型开发平台,功能包括:1. 模板项目库 2. 一键环境隔离 3. 原型版本管理 4. 性能基准测试 5. 协作分享功能。要求支持主流AI…

张小明 2025/12/30 21:42:29 网站建设

哪个网站教做公众号北京海淀科技有限公司

篇幅所限,本文只提供部分资料内容,完整资料请看下面链接 https://download.csdn.net/download/AI_data_cloud/89533857 资料解读:《(82页)中国某著名企业智慧企业办公OA系统》 详细资料请看本解读文章的最后内容。 …

张小明 2025/12/30 21:41:55 网站建设

it网站开发公司荆州建设局网站

NVIDIA显卡隐藏性能深度挖掘:从入门到精通的实战宝典 【免费下载链接】nvidiaProfileInspector 项目地址: https://gitcode.com/gh_mirrors/nv/nvidiaProfileInspector 你是否曾经疑惑,为什么同样的显卡配置,别人的游戏画面总是更加流…

张小明 2025/12/30 21:41:21 网站建设

网站建设对接视频如何制作微网站

3步搞定语音转文字:PaddlePaddle语音识别终极指南 【免费下载链接】Paddle Parallel Distributed Deep Learning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨…

张小明 2025/12/30 21:40:48 网站建设

网站的图片水印怎么做用vs2015做网站

Subversion 工具与配置全解析 1. svnserve 选项说明 svnserve 有一些实用的选项,以下是详细介绍: | 选项 | 说明 | | — | — | | –tunnel-user NAME | 与 –tunnel 选项结合使用,让 svnserve 假定 NAME 是经过身份验证的用户,而非 svnserve 进程的 UID。适用于通过 …

张小明 2025/12/30 21:40:14 网站建设

新网站的建设方案八亿免费wap自助建站

告警规则设定:何时该扩容TensorRT推理集群? 在智能推荐、视频分析和语音识别等AI服务日益普及的今天,用户对响应速度的要求已经从“秒级”迈向“毫秒级”。一个看似简单的图像分类请求背后,可能正运行着经过千次优化的深度学习模型…

张小明 2025/12/30 21:39:39 网站建设