NirDiamant/agents-towards-production · 上手攻略
- 仓库:NirDiamant/agents-towards-production
- 链接:https://github.com/NirDiamant/agents-towards-production
- 分类:ai
- 作者:Tom
- 更新:2026-07-13
这是什么
NirDiamant/agents-towards-production 是一个端到端、代码优先的 GenAI Agent 生产化教程仓库,由 AI 教育博主 Nir Diamant 维护(LinkedIn 粉丝众多,RAG Techniques Newsletter 作者)。目前收录 28 个生产级教程,覆盖从原型到企业级部署的完整链路。
每个教程都是独立文件夹,包含可运行的 Notebook 或代码文件,涵盖:状态化工作流、向量记忆、实时网络搜索、Docker 部署、FastAPI 接口、安全护栏、GPU 扩缩容、多 Agent 协作、可观测性、评估、UI 开发等全栈主题。
解决什么问题
把 GenAI Agent 从「能跑 demo」变成「能上生产」——这是业界最普遍的痛点。具体解决了:
- 不知从何入手:网上多数教程停在 Prompt 层面,没有完整链路
- 缺安全护栏:生产环境需要防 Prompt 注入、OAuth2 鉴权、人在回路审批
- 缺可观测性:Agent 行为不透明,出了 Bug 无法追踪
- 缺多框架经验:LangGraph、LangChain、Koai(Kotlin)等各自怎么选
快速安装
# 克隆仓库
git clone https://github.com/NirDiamant/agents-towards-production.git
cd agents-towards-production
# 进入具体教程目录,例如多工具 Agent
cd tutorials/agentic-applications-by-xpander.ai
pip install -r requirements.txt
# 运行 Notebook 探索
jupyter notebook tutorial.ipynb
# 或直接跑生产脚本
python app.py
依赖说明:不同教程依赖不同(Python 生态为主),建议使用虚拟环境:
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# 或 .venv\Scripts\activate # Windows
核心用法
1. 按主题选教程
仓库按能力模块组织,选自己需要的即可,无需全量安装:
| 教程 | 用途 |
|---|---|
tutorials/LangGraph-agent |
用 LangGraph 构建状态化多步 Agent |
tutorials/fastapi-agent |
把 Agent 部署为 FastAPI 接口 |
tutorials/agent-memory-with-redis |
Redis 实现双内存(短期+长期) |
tutorials/agent-with-tavily-web-access |
接入 Tavily 实时网络搜索 |
tutorials/docker-intro |
Docker 容器化 Agent |
tutorials/tracing-with-langsmith |
LangSmith 全链路追踪 |
tutorials/agent-security-with-llamafirewall |
安全护栏配置 |
tutorials/a2a |
多 Agent 通信(A2A 协议) |
tutorials/agent-with-mcp |
用 MCP 协议集成外部工具 |
tutorials/kotlin-agent-with-koog |
Kotlin 版 Agent(JetBrains Koog) |
tutorials/runpod-gpu-deploy |
Runpod GPU 扩缩容部署 |
tutorials/fine-tuning-agents |
微调 Agent 专用模型 |
tutorials/agent-RAG-with-Contextual |
Contextual AI 企业级 RAG |
tutorials/agent-evaluation-intellagent |
自动化 Agent 评估 |
2. 典型代码片段
LangGraph 状态化 Agent(tutorials/LangGraph-agent):
from langgraph.graph import StateGraph, END
from typing import TypedDict
class AgentState(TypedDict):
messages: list
next_action: str
def agent_node(state):
# 处理消息,决策下一步
return {"messages": [...], "next_action": "search"}
graph = StateGraph(AgentState)
graph.add_node("agent", agent_node)
graph.set_entry_point("agent")
graph.add_edge("agent", END)
app = graph.compile()
FastAPI 部署(tutorials/fastapi-agent):
from fastapi import FastAPI
app = FastAPI()
@app.post("/agent/run")
async def run_agent(prompt: str):
result = await agent.run(prompt)
return {"result": result}
3. 企业级合作伙伴教程
仓库还收录了多家企业贡献的实战教程,包括: - Arcade:OAuth2 安全工具调用(Gmail、Slack、Notion) - Bright Data:企业级网页数据采集(代理网络、CAPTCHA 处理) - Contextual AI:15 分钟企业 RAG(LMUnit 自动化评估) - Runpod:GPU 弹性扩缩容 - AWS Bedrock AgentCore:托管 Agent 部署
典型适用场景
- 从零构建生产 Agent:不知道需要哪些组件 → 跟着 Architecture Diagram 走
- 企业安全合规:需要 OAuth2 鉴权、人在回路 → Arcade 教程
- 给 Agent 接入记忆:Redis/Mem0 双内存 → 对应教程
- 多 Agent 协作:A2A 协议 + LangGraph →
a2a+LangGraph-agent教程 - GPU 部署:Runpod 部署 →
runpod-gpu-deploy教程 - 可观测性:LangSmith 追踪 →
tracing-with-langsmith教程 - Kotlin 生态:JetBrains 生态内嵌 Agent →
kotlin-agent-with-koog教程
坑与注意
| 坑 | 说明 |
|---|---|
| 非标准许可证 | 仓库使用自定义非商业许可证(见 LICENSE),企业商用需注意 |
| 教程质量参差 | 部分教程依赖第三方付费服务(Arcade、Bright Data),白嫖有局限 |
| Jupyter Notebook 为主 | 很多教程是 .ipynb,不是生产级代码,直接拷贝需改造 |
| Notion 生态锁 | 安全工具调用教程以 Notion 为例,熟悉 Notion 才能充分利用 |
| 版本更新快 | LLM API 版本、框架版本变化可能导致代码失效,建议对版本加锁 |
| 无中文 | 所有内容为英文,中文团队使用有一定门槛 |
⚠️ 特别提醒:该仓库明确声明「Educational use only」,作者不对第三方工具的安全性和合规性负责。生产环境使用前请自行审计。
与同类对比
| 维度 | agents-towards-production | LangChain 官方文档 | LangGraph 官方示例 |
|---|---|---|---|
| 定位 | 教程集(学习用) | 框架文档(参考用) | 框架示例(上手用) |
| 覆盖广度 | 28 个主题,覆盖全链路 | 只覆盖 LangChain | 只覆盖 LangGraph |
| 生产导向 | ✅ 强(含安全/监控/部署) | ⚠️ 一般 | ⚠️ 一般 |
| 代码可直接用 | ⚠️ Notebook 需改写 | ✅ API 文档 | ✅ 代码可直接跑 |
| 许可证 | 自定义非商业 | Apache-2.0 | Apache-2.0 |
| 维护活跃度 | 🔄 活跃(持续更新) | 🔄 非常活跃 | 🔄 活跃 |
结论:如果你想系统学习 Agent 全栈、参考多种框架组合的最佳实践,这是目前最完整的免费教程集。但如果要找「直接拷贝到生产」的代码,建议配合官方文档使用。
一句话推荐结论
覆盖最全的生产级 GenAI Agent 百科全书式教程库,适合想系统打通从 Prompt 到部署全链路的工程师;注意其自定义非商业许可证,企业商用需确认合规。