代理设计模式
该存储库包含一个关于构建智能AI系统的基本代理设计模式的交互式单文件教程。
概述
包括 index.html file是一个自包含的网页,为现代人工智能开发中使用的各种模式提供了全面的指南。它旨在通过简单的视觉表示、详细的解释和现实世界的例子,使复杂的建筑概念变得易于理解。
在线使用
打开https://zeljkoavramovic.github.io/agentic-design-patterns/在您的浏览器中。
离线使用
只需下载 index.html 文件并在任何现代网络浏览器中打开。首次下载后不需要互联网连接。
模式关系
下图说明了不同的代理模式通常是如何相互连接和依赖的。这提供了生态系统的高层次视图。
graph LR
subgraph "Core Patterns"
P1("Prompt Chaining")
P2("Routing")
P5("Tool Use")
P3("Parallelization")
P28("Dynamic Scaffolding")
P27("Code-Then-Execute")
end
subgraph "Reasoning & Strategy Patterns"
P4("Reflection")
P6("Planning")
P18("Reasoning Techniques")
P22("Exploration & Discovery")
P24("Parallel Fusion")
P21("Prioritization")
end
subgraph "Orchestration Patterns"
P11("Goal Setting & Monitoring")
P7("Multi-Agent Collaboration")
P15("Inter-Agent Communication")
P17("Resource-Aware Optimization")
P16("Awareness")
end
subgraph "Reliability & Control Patterns"
P19("Guardrails & Safety")
P13("Human-in-the-Loop")
P12("Exception Handling & Recovery")
P23("The Stop Hook")
P25("The Ralph Wiggum Loop")
P29("Spec-First Agent")
end
subgraph "Infrastructure & State Patterns"
P14("Knowledge Retrieval RAG")
P20("Evaluation & Monitoring")
P8("Memory Management")
P10("MCP")
P26("Session Isolation")
P9("Learning and Adaptation")
end
P7 -- "requires" --> P15
P7 -. "uses" .-> P6
P7 -. "uses" .-> P8
P6 -- "can be composed of" --> P1
P6 -- "often requires" --> P5
P14 -- "is a form of" --> P5
P2 -- "is used by" --> P17
P4 -- "is a form of" --> P20
P9 -- "is enabled by" --> P13
P13 -- "is triggered by" --> P19
P13 -- "is triggered by" --> P12
P18 -- "can be improved by" --> P4
P22 -- "is a form of" --> P6
P1 -- "often needs" --> P12
P6 -- "detects" --> P16
P17 -- "detects" --> P16
P7 -- "detects" --> P16
P16 -- "provides facts for" --> P6
P16 -- "provides facts for" --> P17
%% New Connections
P23 -- "is a form of" --> P19
P25 -- "relies on" --> P23
P25 -- "requires" --> P26
P24 -- "requires" --> P26
P24 -- "is an evolution of" --> P3
P5 -- "is used by" --> P23
%% Connections for New Patterns
P26 -- "supports" --> P27
P26 -- "supports" --> P28
P5 -- "evolves to" --> P27
P23 -- "validates" --> P29
P18 -- "is a form of" --> P27
P5 -- "extended by" --> P28
P19 -- "enforces" --> P29
图案包括
本教程涵盖了以下29种模式,分为不同类别:
核心模式
- 快速链接
- 路由
- 并行化
- 工具使用
- 代码然后执行
- 动态脚手架
推理与策略模式
- 反思
- 规划
- 推理技术
- 并融合
- 优先级排序
- 探索与发现
编排模式
- 多Agent协作
- 目标设定与监控
- 代理间通信
- 意识
- 资源感知优化
基础设施和状态模式
- 内存管理
- 学习与适应
- 模型上下文协议(MCP)
- 知识检索(RAG)
- 评估和监测
- 会话隔离
可靠性和控制模式
- 停止钩
- 异常处理和恢复
- 循环中的人类
- 拉尔夫·威格古姆循环
- 护栏和安全
- 规格第一代理
许可证
MIT许可证-相应地使用本教程!
支持项目
如果这个项目对您有所帮助,我们非常欢迎您的支持:
- ⭐ 为存储库添加星号 表达你的感激之情。
- 💬 传话 关于这个仓库。
学分
这些模式和图表是从对代理人工智能系统的广泛研究中提炼出来的。有关更多信息,请访问以下链接:
- https://github.com/promptadvisers/agentic-design-patterns-docs
- https://www.amazon.com/Agentic-Design-Patterns-Hands-Intelligent/dp/3032014018
- https://www.researchgate.net/publication/238675575_Brahms_A_multi-agent_modelling_environment_for_simulating_work_processes_and_practices
- https://agentic-patterns.com
- https://ghuntley.com/ralph/
- https://x.com/bcherny/status/2007179832300581177
- https://github.com/guardrails-ai/guardrails
- https://medium.com/@dtunai/掌握git-worktrees-带代码并行开发工作流-41dc91e645fe
- https://www.youtube.com/watch?v=-WBHNFAB0OE&t=685秒
- https://arxiv.org/abs/2406.00832
- https://arxiv.org/pdf/2203.11171v4.pdf
- https://arxiv.org/pdf/2410.09342.pdf
特别感谢Lazarus论坛的用户Thaddy指出勃拉姆斯的研究。
