|
| 1 | +<br /> |
| 2 | +<div align="center"> |
| 3 | + <a href="https://zenml.io"> |
| 4 | + <img src="../../docs/book/.gitbook/assets/header.png" alt="ZenML Logo" width="600"> |
| 5 | + </a> |
| 6 | + |
| 7 | +<h3 align="center">Agent Frameworks Integration Examples</h3> |
| 8 | + |
| 9 | + <p align="center"> |
| 10 | + Production-ready agent orchestration with ZenML |
| 11 | + <br /> |
| 12 | + <a href="https://zenml.io/features">Features</a> |
| 13 | + · |
| 14 | + <a href="https://zenml.io/roadmap">Roadmap</a> |
| 15 | + · |
| 16 | + <a href="https://github.com/zenml-io/zenml/issues">Report Bug</a> |
| 17 | + · |
| 18 | + <a href="https://zenml.io/discussion">Vote New Features</a> |
| 19 | + · |
| 20 | + <a href="https://blog.zenml.io/">Read Blog</a> |
| 21 | + <br /> |
| 22 | + <br /> |
| 23 | + <a href="https://zenml.io/slack"> |
| 24 | + <img src="https://img.shields.io/badge/JOIN US ON SLACK-4A154B?style=for-the-badge&logo=slack&logoColor=white" alt="Slack"> |
| 25 | + </a> |
| 26 | + <a href="https://www.linkedin.com/company/zenml/"> |
| 27 | + <img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" alt="LinkedIn"> |
| 28 | + </a> |
| 29 | + <a href="https://twitter.com/zenml_io"> |
| 30 | + <img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" alt="Twitter"> |
| 31 | + </a> |
| 32 | + </p> |
| 33 | +</div> |
| 34 | + |
| 35 | +# 🤖 Agent Frameworks + ZenML |
| 36 | + |
| 37 | +This collection demonstrates how to integrate popular agent frameworks with ZenML for production-grade AI agent orchestration. Each example follows consistent patterns and best practices, making it easy to adapt any framework for your specific use case. |
| 38 | + |
| 39 | +## 🚀 Quick Start |
| 40 | + |
| 41 | +Choose any framework and get started in minutes: |
| 42 | + |
| 43 | +```bash |
| 44 | +export OPENAI_API_KEY="your-api-key-here" |
| 45 | +cd framework-name/ |
| 46 | +uv venv --python 3.11 |
| 47 | +source .venv/bin/activate |
| 48 | +uv pip install -r requirements.txt |
| 49 | +python run.py |
| 50 | +``` |
| 51 | + |
| 52 | +## 📊 Frameworks Overview |
| 53 | + |
| 54 | +| Framework | Type | Key Features | Technologies | |
| 55 | +|-----------|------|-------------|-------------| |
| 56 | +| [Autogen](autogen/) | 🤝 Multi-Agent | Multi-agent conversations, Role-based collaboration | autogen, openai | |
| 57 | +| [AWS Strands](aws-strands/) | ⚡ Simple | Direct agent calls, Built-in tools | aws-agents, bedrock | |
| 58 | +| [CrewAI](crewai/) | 👥 Crews | Agent crews, Task delegation | crewai, openai | |
| 59 | +| [Google ADK](google-adk/) | 🧠 Gemini | Google AI agents, Gemini models | google-adk, gemini | |
| 60 | +| [Haystack](haystack/) | 🔍 RAG | Retrieval pipelines, Document processing | haystack, openai | |
| 61 | +| [LangChain](langchain/) | 🔗 Chains | Runnable chains, Tool composition | langchain, openai | |
| 62 | +| [LangGraph](langgraph/) | 🕸️ Graphs | ReAct agents, Graph workflows | langgraph, openai | |
| 63 | +| [LlamaIndex](llama_index/) | 📚 Functions | Function agents, Async execution | llama-index, openai | |
| 64 | +| [OpenAI Agents SDK](openai_agents_sdk/) | 🏗️ Structured | Official OpenAI agents, Structured execution | openai-agents, openai | |
| 65 | +| [PydanticAI](pydanticai/) | ✅ Type-Safe | Type-safe agents, Validation | pydantic-ai, openai | |
| 66 | +| [Semantic Kernel](semantic-kernel/) | 🧩 Plugins | Plugin architecture, Microsoft ecosystem | semantic-kernel, openai | |
| 67 | + |
| 68 | +## 🎯 Core Patterns |
| 69 | + |
| 70 | +All examples follow these established patterns: |
| 71 | + |
| 72 | +### 🔧 Environment Setup |
| 73 | +- **uv for environments**: `uv venv --python 3.11` |
| 74 | +- **Fast installs**: `uv pip install -r requirements.txt` |
| 75 | +- **Consistent Python version**: 3.11 across all frameworks |
| 76 | + |
| 77 | +### 📦 Pipeline Architecture |
| 78 | +```python |
| 79 | +@pipeline |
| 80 | +def agent_pipeline() -> str: |
| 81 | + # 1. External artifact input |
| 82 | + query = ExternalArtifact(value="Your query") |
| 83 | + |
| 84 | + # 2. Agent execution |
| 85 | + results = run_agent(query) |
| 86 | + |
| 87 | + # 3. Response formatting |
| 88 | + summary = format_response(results) |
| 89 | + |
| 90 | + return summary |
| 91 | +``` |
| 92 | + |
| 93 | +### 🛡️ Error Handling |
| 94 | +- Comprehensive try-catch blocks |
| 95 | +- Status tracking with success/error states |
| 96 | +- Graceful degradation for agent failures |
| 97 | + |
| 98 | +### 📊 Artifact Management |
| 99 | +- **Annotated outputs**: `Annotated[Type, "artifact_name"]` |
| 100 | +- **ZenML integration**: Full pipeline orchestration |
| 101 | +- **Artifact storage**: S3-backed artifact management |
| 102 | + |
| 103 | +## 🏗️ Framework-Specific Features |
| 104 | + |
| 105 | +### Multi-Agent Systems |
| 106 | +- **Autogen**: Conversational multi-agent workflows |
| 107 | +- **CrewAI**: Role-based agent crews with task delegation |
| 108 | + |
| 109 | +### Simple Execution |
| 110 | +- **AWS Strands**: Direct callable interface with `agent(query)` |
| 111 | +- **PydanticAI**: Clean `agent.run_sync(query)` API |
| 112 | +- **Google ADK**: Gemini-powered agents with simple calls |
| 113 | + |
| 114 | +### Advanced Orchestration |
| 115 | +- **LangChain**: Composable chains with tool integration |
| 116 | +- **LangGraph**: ReAct pattern with graph-based workflows |
| 117 | +- **Semantic Kernel**: Plugin-based architecture |
| 118 | + |
| 119 | +### Specialized Use Cases |
| 120 | +- **Haystack**: RAG pipelines with retrieval components |
| 121 | +- **LlamaIndex**: Function agents with async capabilities |
| 122 | +- **OpenAI Agents SDK**: Structured execution with OpenAI |
| 123 | + |
| 124 | +## 🔄 Implementation Notes |
| 125 | + |
| 126 | +### Production vs. Demos |
| 127 | +**These examples demonstrate single-query execution for simplicity.** In production, ZenML's value comes from: |
| 128 | +- **Batch processing**: Process hundreds/thousands of queries overnight |
| 129 | +- **Agent evaluation**: Compare different frameworks on test datasets |
| 130 | +- **Data pipelines**: Use agents to process document collections |
| 131 | +- **A/B testing**: Systematic comparison of agent configurations |
| 132 | + |
| 133 | +For real-time serving, use FastAPI/Flask directly. Use ZenML for the operational layer. |
| 134 | + |
| 135 | +### Async Frameworks |
| 136 | +Some frameworks require async handling within ZenML steps: |
| 137 | +- **LlamaIndex**: `asyncio.run(agent.run(query))` |
| 138 | +- **Semantic Kernel**: Event loop management for chat completion |
| 139 | + |
| 140 | +### Tool Integration |
| 141 | +Different frameworks have varying tool patterns: |
| 142 | +- **Decorators**: `@tool`, `@function_tool`, `@kernel_function` |
| 143 | +- **Functions**: Regular Python functions as tools |
| 144 | +- **Classes**: Tool classes with specific interfaces |
| 145 | + |
| 146 | +### Response Extraction |
| 147 | +Each framework returns different response types: |
| 148 | +- **String responses**: Direct text output |
| 149 | +- **Object responses**: `.output`, `.content`, `.final_output` attributes |
| 150 | +- **Complex responses**: Nested structures requiring extraction |
| 151 | + |
| 152 | +## 📋 Requirements |
| 153 | + |
| 154 | +- **Python**: 3.11+ |
| 155 | +- **ZenML**: Latest version |
| 156 | +- **UV**: For fast package management |
| 157 | +- **OpenAI API Key**: Most examples use OpenAI (set `OPENAI_API_KEY`) |
| 158 | + |
| 159 | +## 🆘 Getting Help |
| 160 | + |
| 161 | +- 💬 [Join our Slack community](https://zenml.io/slack) |
| 162 | +- 📖 [Check our documentation](https://docs.zenml.io/) |
| 163 | +- 🐛 [Report issues](https://github.com/zenml-io/zenml/issues) |
| 164 | +- 💡 [Request features](https://zenml.io/discussion) |
| 165 | + |
| 166 | +## 🌟 About ZenML |
| 167 | + |
| 168 | +ZenML is an extensible, open-source MLOps framework for creating production-ready ML pipelines. These agent framework integrations showcase ZenML's flexibility in orchestrating AI workflows beyond traditional ML use cases. |
| 169 | + |
| 170 | +**Why ZenML for Agent Orchestration?** |
| 171 | +- 🔄 **Reproducible workflows**: Version and track agent executions |
| 172 | +- 📊 **Artifact management**: Store and version agent inputs/outputs |
| 173 | +- 🎯 **Production ready**: Built-in monitoring, logging, and error handling |
| 174 | +- 🔧 **Tool agnostic**: Works with any agent framework |
| 175 | +- ☁️ **Cloud native**: Deploy anywhere with consistent behavior |
| 176 | + |
| 177 | +## 📖 Learn More |
| 178 | + |
| 179 | +| Resource | Description | |
| 180 | +|----------|-------------| |
| 181 | +| 🧘 **[ZenML 101]** | New to ZenML? Start here! | |
| 182 | +| ⚛ **[Core Concepts]** | Understand ZenML fundamentals | |
| 183 | +| 🤖 **[LLMOps Guide]** | Complete guide to LLMOps with ZenML | |
| 184 | +| 📓 **[Documentation]** | Full ZenML documentation | |
| 185 | +| 📒 **[API Reference]** | Detailed API documentation | |
| 186 | +| ⚽ **[Examples]** | More ZenML examples | |
| 187 | + |
| 188 | +[ZenML 101]: https://docs.zenml.io/user-guides/starter-guide |
| 189 | +[Core Concepts]: https://docs.zenml.io/getting-started/core-concepts |
| 190 | +[LLMOps Guide]: https://docs.zenml.io/user-guides/llmops-guide |
| 191 | +[Documentation]: https://docs.zenml.io/ |
| 192 | +[SDK Reference]: https://sdkdocs.zenml.io/ |
| 193 | +[Examples]: https://github.com/zenml-io/zenml/tree/main/examples |
| 194 | + |
| 195 | +--- |
| 196 | + |
| 197 | +*This collection demonstrates the power and flexibility of ZenML for orchestrating diverse agent frameworks in production environments.* |
0 commit comments