Merge branch 'agents-loader' of https://github.com/harshalmore31/swarms into agents-loader

pull/1022/head
harshalmore31 2 weeks ago
commit ef1a4d7388

@ -17,7 +17,7 @@ jobs:
&& ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Install poetry
run: pipx install poetry==$POETRY_VERSION
- name: Set up Python 3.9

@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@562ee3e92b8e92df8b67e0a5ff8aa8e261919c08

@ -16,7 +16,7 @@ jobs:
steps:
# Step 1: Check out the repository
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
# Step 2: Set up Python
- name: Set up Python ${{ matrix.python-version }}

@ -28,7 +28,7 @@ jobs:
language: ["python"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:

@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
# Commonly enabled options, see https://github.com/actions/dependency-review-action#configuration-options for all available options.

@ -9,7 +9,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: 3.11

@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5

@ -33,7 +33,7 @@ jobs:
security-events: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
submodules: true

@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
submodules: true

@ -21,7 +21,7 @@ jobs:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:

@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Python 3.10
uses: actions/setup-python@v5

@ -27,7 +27,7 @@ jobs:
runs-on: "ubuntu-20.04"
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Build an image from Dockerfile
run: |

1
.gitignore vendored

@ -12,6 +12,7 @@ dataframe/
target/
Cargo.lock
.pytest_cache
databases
static/generated
conversations/
next_swarms_update.txt

@ -8,92 +8,115 @@
</p>
<p align="center">
<a href="https://pypi.org/project/swarms/" target="_blank">
<img alt="Python" src="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54" />
<img alt="Version" src="https://img.shields.io/pypi/v/swarms?style=for-the-badge&color=3670A0">
</a>
</p>
<p align="center">
<a href="https://twitter.com/swarms_corp/">🐦 Twitter</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://discord.gg/EamjgSaEQf">📢 Discord</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://swarms.ai">Swarms Website</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://docs.swarms.world">📙 Documentation</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://swarms.world"> Swarms Marketplace</a>
<a href="https://pypi.org/project/swarms/" target="_blank">
<picture>
<source srcset="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54" media="(prefers-color-scheme: dark)">
<img alt="Python" src="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54" />
</picture>
<picture>
<source srcset="https://img.shields.io/pypi/v/swarms?style=for-the-badge&color=3670A0" media="(prefers-color-scheme: dark)">
<img alt="Version" src="https://img.shields.io/pypi/v/swarms?style=for-the-badge&color=3670A0">
</picture>
</a>
</p>
<p align="center">
<!-- Social Media -->
<a href="https://discord.gg/jHnrkH5y">
<img src="https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord">
</a>
<a href="https://www.youtube.com/@kyegomez3242">
<img src="https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white" alt="YouTube">
</a>
<a href="https://www.linkedin.com/in/kye-g-38759a207/">
<img src="https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white" alt="LinkedIn">
</a>
<a href="https://x.com/swarms_corp">
<img src="https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white" alt="X.com">
</a>
<!-- Project Stats - Most Important First -->
<a href="https://github.com/kyegomez/swarms/stargazers">
<picture>
<source srcset="https://img.shields.io/github/stars/kyegomez/swarms?style=for-the-badge" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/github/stars/kyegomez/swarms?style=for-the-badge" alt="GitHub stars">
</picture>
</a>
<a href="https://github.com/kyegomez/swarms/network">
<picture>
<source srcset="https://img.shields.io/github/forks/kyegomez/swarms?style=for-the-badge" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/github/forks/kyegomez/swarms?style=for-the-badge" alt="GitHub forks">
</picture>
</a>
<a href="https://github.com/kyegomez/swarms/issues">
<picture>
<source srcset="https://img.shields.io/github/issues/kyegomez/swarms?style=for-the-badge" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/github/issues/kyegomez/swarms?style=for-the-badge" alt="GitHub issues">
</picture>
</a>
<a href="https://github.com/kyegomez/swarms/blob/main/LICENSE">
<picture>
<source srcset="https://img.shields.io/github/license/kyegomez/swarms?style=for-the-badge" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/github/license/kyegomez/swarms?style=for-the-badge" alt="GitHub license">
</picture>
</a>
<a href="https://pepy.tech/project/swarms">
<picture>
<source srcset="https://static.pepy.tech/badge/swarms/month" media="(prefers-color-scheme: dark)">
<img src="https://static.pepy.tech/badge/swarms/month" alt="Downloads">
</picture>
</a>
<a href="https://libraries.io/github/kyegomez/swarms">
<picture>
<source srcset="https://img.shields.io/librariesio/github/kyegomez/swarms?style=for-the-badge" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/librariesio/github/kyegomez/swarms?style=for-the-badge" alt="Dependency Status">
</picture>
</a>
</p>
<p align="center">
<!-- Project Stats -->
<a href="https://github.com/kyegomez/swarms/issues">
<img src="https://img.shields.io/github/issues/kyegomez/swarms" alt="GitHub issues">
</a>
<a href="https://github.com/kyegomez/swarms/network">
<img src="https://img.shields.io/github/forks/kyegomez/swarms" alt="GitHub forks">
</a>
<a href="https://github.com/kyegomez/swarms/stargazers">
<img src="https://img.shields.io/github/stars/kyegomez/swarms" alt="GitHub stars">
</a>
<a href="https://github.com/kyegomez/swarms/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/kyegomez/swarms" alt="GitHub license">
</a>
<a href="https://star-history.com/#kyegomez/swarms">
<img src="https://img.shields.io/github/stars/kyegomez/swarms?style=social" alt="GitHub star chart">
</a>
<a href="https://libraries.io/github/kyegomez/swarms">
<img src="https://img.shields.io/librariesio/github/kyegomez/swarms" alt="Dependency Status">
</a>
<a href="https://pepy.tech/project/swarms">
<img src="https://static.pepy.tech/badge/swarms/month" alt="Downloads">
</a>
<!-- Social Media -->
<a href="https://twitter.com/swarms_corp/">
<picture>
<source srcset="https://img.shields.io/badge/Twitter-Follow-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/badge/Twitter-Follow-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" alt="Twitter">
</picture>
</a>
<a href="https://discord.gg/EamjgSaEQf">
<picture>
<source srcset="https://img.shields.io/badge/Discord-Join-5865F2?style=for-the-badge&logo=discord&logoColor=white" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/badge/Discord-Join-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord">
</picture>
</a>
<a href="https://www.youtube.com/@kyegomez3242">
<picture>
<source srcset="https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white" alt="YouTube">
</picture>
</a>
<a href="https://www.linkedin.com/in/kye-g-38759a207/">
<picture>
<source srcset="https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white" alt="LinkedIn">
</picture>
</a>
<a href="https://x.com/swarms_corp">
<picture>
<source srcset="https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white" alt="X.com">
</picture>
</a>
</p>
<p align="center">
<!-- Share Buttons -->
<a href="https://twitter.com/intent/tweet?text=Check%20out%20this%20amazing%20AI%20project:%20&url=https%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms">
<img src="https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Share%20%40kyegomez/swarms" alt="Share on Twitter">
</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms">
<img src="https://img.shields.io/badge/Share-%20facebook-blue" alt="Share on Facebook">
</a>
<a href="https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms&title=&summary=&source=">
<img src="https://img.shields.io/badge/Share-%20linkedin-blue" alt="Share on LinkedIn">
</a>
<!-- Main Navigation Links -->
<a href="https://swarms.ai">🏠 Swarms Website</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://docs.swarms.world">📙 Documentation</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://swarms.world">🛒 Swarms Marketplace</a>
</p>
<p align="center">
<!-- Additional Share Buttons -->
<a href="https://www.reddit.com/submit?url=https%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms&title=Swarms%20-%20the%20future%20of%20AI">
<img src="https://img.shields.io/badge/-Share%20on%20Reddit-orange" alt="Share on Reddit">
</a>
<a href="https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms&t=Swarms%20-%20the%20future%20of%20AI">
<img src="https://img.shields.io/badge/-Share%20on%20Hacker%20News-orange" alt="Share on Hacker News">
</a>
<a href="https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms&media=https%3A%2F%2Fexample.com%2Fimage.jpg&description=Swarms%20-%20the%20future%20of%20AI">
<img src="https://img.shields.io/badge/-Share%20on%20Pinterest-red" alt="Share on Pinterest">
</a>
<a href="https://api.whatsapp.com/send?text=Check%20out%20Swarms%20-%20the%20future%20of%20AI%20%23swarms%20%23AI%0A%0Ahttps%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms">
<img src="https://img.shields.io/badge/-Share%20on%20WhatsApp-green" alt="Share on WhatsApp">
</a>
<!-- Share Buttons -->
<a href="https://twitter.com/intent/tweet?text=Check%20out%20this%20amazing%20AI%20project:%20&url=https%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms">
<picture>
<source srcset="https://img.shields.io/badge/Share%20on%20Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/badge/Share%20on%20Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" alt="Share on Twitter">
</picture>
</a>
<a href="https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fgithub.com%2Fkyegomez%2Fswarms&title=&summary=&source=">
<picture>
<source srcset="https://img.shields.io/badge/Share%20on%20LinkedIn-blue?style=for-the-badge" media="(prefers-color-scheme: dark)">
<img src="https://img.shields.io/badge/Share%20on%20LinkedIn-blue?style=for-the-badge" alt="Share on LinkedIn">
</picture>
</a>
</p>
## ✨ Features
@ -112,31 +135,27 @@ Swarms delivers a comprehensive, enterprise-grade multi-agent infrastructure pla
## Install 💻
### Using pip
```bash
$ pip3 install -U swarms
```
### Using uv (Recommended)
[uv](https://github.com/astral-sh/uv) is a fast Python package installer and resolver, written in Rust.
```bash
# Install uv
$ curl -LsSf https://astral.sh/uv/install.sh | sh
# Install swarms using uv
$ uv pip install swarms
```
### Using poetry
```bash
# Install poetry if you haven't already
$ curl -sSL https://install.python-poetry.org | python3 -
# Add swarms to your project
```bash
$ poetry add swarms
```
### From source
```bash
# Clone the repository
$ git clone https://github.com/kyegomez/swarms.git
@ -146,6 +165,24 @@ $ cd swarms
$ pip install -e .
```
### Using Docker
The easiest way to get started with Swarms is using our pre-built Docker image:
```bash
# Pull and run the latest image
$ docker pull kyegomez/swarms:latest
$ docker run --rm kyegomez/swarms:latest python -c "import swarms; print('Swarms is ready!')"
# Run interactively for development
$ docker run -it --rm -v $(pwd):/app kyegomez/swarms:latest bash
# Using docker-compose (recommended for development)
$ docker-compose up -d
```
For more Docker options and advanced usage, see our [Docker documentation](/scripts/docker/DOCKER.md).
---
## Environment Configuration
@ -171,7 +208,7 @@ from swarms import Agent
# Initialize a new agent
agent = Agent(
model_name="gpt-4o-mini", # Specify the LLM
max_loops=1, # Set the number of interactions
max_loops="auto", # Set the number of interactions
interactive=True, # Enable interactive mode for real-time feedback
)
@ -351,7 +388,7 @@ print(results)
### AgentRearrange
Inspired by `einsum`, `AgentRearrange` lets you define complex, non-linear relationships between agents using a simple string-based syntax. [Learn more](https://docs.swarms.world/en/latest/swarms/structs/agent_rearrange/). This architecture is Perfect for orchestrating dynamic workflows where agents might work in parallel, sequence, or a combination of both.
Inspired by `einsum`, `AgentRearrange` lets you define complex, non-linear relationships between agents using a simple string-based syntax. [Learn more](https://docs.swarms.world/en/latest/swarms/structs/agent_rearrange/). This architecture is perfect for orchestrating dynamic workflows where agents might work in parallel, in sequence, or in any combination you choose.
```python
from swarms import Agent, AgentRearrange
@ -695,6 +732,7 @@ Explore comprehensive examples and tutorials to learn how to use Swarms effectiv
| Application | Description | Link |
|-------------|-------------|------|
| Advanced Research System | Multi-agent research system inspired by Anthropic's research methodology | [AdvancedResearch](https://github.com/The-Swarm-Corporation/AdvancedResearch) |
| Swarms DAO | Decentralized autonomous organization | [Swarms DAO](https://docs.swarms.world/en/latest/swarms/examples/swarms_dao/) |
| Browser Agents | Web automation with agents | [Browser Agents](https://docs.swarms.world/en/latest/swarms/examples/swarms_of_browser_agents/) |
| VLLM Agents | High-performance model serving | [VLLM Agents](https://docs.swarms.world/en/latest/swarms/examples/vllm/) |
@ -724,7 +762,7 @@ By joining us, you have the opportunity to:
* **Work on the Frontier of Agents:** Shape the future of autonomous agent technology and help build a production-grade, open-source framework.
* **Join a Vibrant Community:** Collaborate with a passionate and growing group of agent developers, researchers, and AI enthusiasts.
* **Join a Vibrant Community:** Collaborate with a passionate and growing group of agent developers, researchers, and agent enthusasits.
* **Make a Tangible Impact:** Whether you're fixing a bug, adding a new feature, or improving documentation, your work will be used in real-world applications.

@ -318,7 +318,7 @@ Schedule quarterly audits to refine structure and content across all repositorie
Promote your contributions via:
- **Swarms Discord**: https://discord.gg/jM3Z6M9uMq
- **Swarms Discord**: https://discord.gg/EamjgSaEQf
- **Swarms Telegram**: https://t.me/swarmsgroupchat

@ -623,7 +623,7 @@ If you encounter issues:
1. **Check the FAQ** in the main documentation
2. **Search existing issues** on GitHub
3. **Ask in the Discord community**: [discord.gg/jM3Z6M9uMq](https://discord.gg/jM3Z6M9uMq)
3. **Ask in the Discord community**: [discord.gg/jM3Z6M9uMq](https://discord.gg/EamjgSaEQf)
4. **Create a GitHub issue** with:
- Your operating system
- Python version

@ -54,7 +54,7 @@ If you'd like technical support, join our Discord below and stay updated on our
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |

@ -0,0 +1,42 @@
# Community Resources
Welcome to the Community Resources page! Here you'll find a curated collection of articles, tutorials, and guides created by the Swarms community and core contributors.
These resources cover a wide range of topics, including building your first agent, advanced multi-agent architectures, API integrations, and using Swarms with both Python and Rust. Whether you're a beginner or an experienced developer, these links will help you deepen your understanding and accelerate your development with the Swarms framework.
## Swarms Python
| Title | Description | Link |
|-------|-------------|------|
| **Build Your First Swarms Agent in Under 10 Minutes** | Step-by-step beginner guide to creating your first Swarms agent quickly. | [Read Article](https://medium.com/@devangvashistha/build-your-first-swarms-agent-in-under-10-minutes-ddff23b6c703) |
| **Building Multi-Agent Systems with GPT-5 and The Swarms Framework** | Learn how to leverage GPT-5 with Swarms for advanced multi-agent system design. | [Read Article](https://medium.com/@kyeg/building-multi-agent-systems-with-gpt-5-and-the-swarms-framework-e52ffaf0fa4f) |
| **Learn How to Build Production-Grade Agents with OpenAIs Latest Model: GPT-OSS Locally and in the Cloud** | Guide to building robust agents using OpenAIs GPT-OSS, both locally and in cloud environments. | [Read Article](https://medium.com/@kyeg/learn-how-to-build-production-grade-agents-with-openais-latest-model-gpt-oss-locally-and-in-the-c5826c7cca7c) |
| **Building Gemini 2.5 Agents with Swarms Framework** | Tutorial on integrating Gemini 2.5 models into Swarms agents for enhanced capabilities. | [Read Article](https://medium.com/@kyeg/building-gemini-2-5-agents-with-swarms-framework-20abdcf82cac) |
| **Enterprise Developer Guide: Leveraging OpenAIs o3 and o4-mini Models with The Swarms Framework** | Enterprise-focused guide to using OpenAIs o3 and o4-mini models within Swarms. | [Read Article](https://medium.com/@kyeg/enterprise-developer-guide-leveraging-openais-o3-and-o4-mini-models-with-the-swarms-framework-89490c57820a) |
| **Enneagram of Thoughts Using the Swarms Framework: A Multi-Agent Approach to Holistic Problem Solving** | Explores using Swarms for holistic, multi-perspective problem solving via the Enneagram model. | [Read Article](https://medium.com/@kyeg/enneagram-of-thoughts-using-the-swarms-framework-a-multi-agent-approach-to-holistic-problem-c26c7df5e7eb) |
| **Building Production-Grade Financial Agents with tickr-agent: An Enterprise Solution for Comprehensive Stock Analysis** | How to build advanced financial analysis agents using tickr-agent and Swarms. | [Read Article](https://medium.com/@kyeg/building-production-grade-financial-agents-with-tickr-agent-an-enterprise-solution-for-db867ec93193) |
| **Automating Your Startups Financial Analysis Using AI Agents: A Comprehensive Guide** | Comprehensive guide to automating your startups financial analysis with AI agents using Swarms. | [Read Article](https://medium.com/@kyeg/automating-your-startups-financial-analysis-using-ai-agents-a-comprehensive-guide-b2fa0e2c09d5) |
| **Managing Thousands of Agent Outputs at Scale with The Spreadsheet Swarm: All-New Multi-Agent Architecture** | Learn how to manage and scale thousands of agent outputs efficiently using the Spreadsheet Swarm architecture. | [Read Article](https://medium.com/@kyeg/managing-thousands-of-agent-outputs-at-scale-with-the-spreadsheet-swarm-all-new-multi-agent-f16f5f40fd5a) |
| **Introducing GPT-4o Mini: The Future of Cost-Efficient AI Intelligence** | Discover the capabilities and advantages of GPT-4o Mini for building cost-effective, intelligent agents. | [Read Article](https://medium.com/@kyeg/introducing-gpt-4o-mini-the-future-of-cost-efficient-ai-intelligence-a3e3fe78d939) |
| **Introducing Swarm's GraphWorkflow: A Faster, Simpler, and Superior Alternative to LangGraph** | Learn about Swarms' GraphWorkflow, a powerful alternative to LangGraph that offers improved performance and simplicity for building complex agent workflows. | [Read Article](https://medium.com/@kyeg/introducing-swarms-graphworkflow-a-faster-simpler-and-superior-alternative-to-langgraph-5c040225a4f1) |
### Swarms API
| Title | Description | Link |
|-------|-------------|------|
| **Specialized Healthcare Agents with Swarms Agent Completions API** | Guide to building healthcare-focused agents using the Swarms API. | [Read Article](https://medium.com/@kyeg/specialized-healthcare-agents-with-swarms-agent-completions-api-b56d067e3b11) |
| **Building Multi-Agent Systems for Finance & Accounting with the Swarms API: A Technical Guide** | Technical walkthrough for creating finance and accounting multi-agent systems with the Swarms API. | [Read Article](https://medium.com/@kyeg/building-multi-agent-systems-for-finance-accounting-with-the-swarms-api-a-technical-guide-bf6f7005b708) |
### Swarms Rust
| Title | Description | Link |
|-------|-------------|------|
| **Building Medical Multi-Agent Systems with Swarms Rust: A Comprehensive Tutorial** | Comprehensive tutorial for developing medical multi-agent systems using Swarms Rust. | [Read Article](https://medium.com/@kyeg/building-medical-multi-agent-systems-with-swarms-rust-a-comprehensive-tutorial-1e8e060601f9) |
| **Building Production-Grade Agentic Applications with Swarms Rust: A Comprehensive Tutorial** | Learn to build robust, production-ready agentic applications with Swarms Rust. | [Read Article](https://medium.com/@kyeg/building-production-grade-agentic-applications-with-swarms-rust-a-comprehensive-tutorial-bb567c02340f) |
### Youtube Videos
- [Swarms Playlist by Swarms Founder Kye Gomez](https://www.youtube.com/watch?v=FzbBRbaqsG8&list=PLphplB7PcU1atnmrUl7lJ5bmGXR7R4lhA)

@ -43,7 +43,7 @@ This index provides a categorized list of examples and tutorials for using the S
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |

@ -171,6 +171,7 @@ This index organizes **100+ production-ready examples** from our [Swarms Example
### Research and Deep Analysis
| Category | Example | Description |
|----------|---------|-------------|
| Advanced Research | [Advanced Research System](https://github.com/The-Swarm-Corporation/AdvancedResearch) | Multi-agent research system inspired by Anthropic's research methodology with orchestrator-worker architecture |
| Deep Research | [Deep Research Example](https://github.com/kyegomez/swarms/blob/master/examples/multi_agent/deep_research_examples/deep_research_example.py) | Comprehensive research system with multiple specialized agents |
| Deep Research Swarm | [Deep Research Swarm](https://github.com/kyegomez/swarms/blob/master/examples/multi_agent/deep_research_examples/deep_research_swarm_example.py) | Swarm-based deep research with collaborative analysis |
| Scientific Agents | [Deep Research Swarm Example](https://github.com/kyegomez/swarms/blob/master/examples/demos/scient_agents/deep_research_swarm_example.py) | Scientific research swarm for academic and research applications |

@ -1,6 +1,8 @@
# Multi-Agent Paper Implementations
At Swarms, we are passionate about democratizing access to cutting-edge multi-agent research and making advanced AI collaboration accessible to everyone. Our mission is to bridge the gap between academic research and practical implementation by providing production-ready, open-source implementations of the most impactful multi-agent research papers.
At Swarms, we are passionate about democratizing access to cutting-edge multi-agent research and making advanced agent collaboration accessible to everyone.
Our mission is to bridge the gap between academic research and practical implementation by providing production-ready, open-source implementations of the most impactful multi-agent research papers.
### Why Multi-Agent Research Matters
@ -38,10 +40,6 @@ This documentation showcases our comprehensive collection of multi-agent researc
Whether you're a researcher looking to validate findings, a developer building production systems, or a student learning about multi-agent AI, you'll find valuable resources here to advance your work.
### Join the Multi-Agent Revolution
We invite you to explore these implementations, contribute to our research efforts, and help shape the future of collaborative AI. Together, we can unlock the full potential of multi-agent systems and create AI that truly works as a team.
## Implemented Research Papers
| Paper Name | Description | Original Paper | Implementation | Status | Key Features |
@ -52,79 +50,12 @@ We invite you to explore these implementations, contribute to our research effor
| **[Mixture of Agents (MoA)](https://arxiv.org/abs/2406.04692)** | A sophisticated multi-agent architecture that implements parallel processing with iterative refinement, combining diverse expert agents for comprehensive analysis. | Multi-agent collaboration concepts | [`swarms.structs.moa`](https://docs.swarms.world/en/latest/swarms/structs/moa/) | ✅ Complete | Parallel processing, expert agent combination, iterative refinement, state-of-the-art performance |
| **Deep Research Swarm** | A production-grade research system that conducts comprehensive analysis across multiple domains using parallel processing and advanced AI agents. | Research methodology | [`swarms.structs.deep_research_swarm`](https://docs.swarms.world/en/latest/swarms/structs/deep_research_swarm/) | ✅ Complete | Parallel search processing, multi-agent coordination, information synthesis, concurrent execution |
| **Agent-as-a-Judge** | An evaluation framework that uses agents to evaluate other agents, implementing the "Agent-as-a-Judge: Evaluate Agents with Agents" methodology. | [arXiv:2410.10934](https://arxiv.org/abs/2410.10934) | [`swarms.agents.agent_judge`](https://docs.swarms.world/en/latest/swarms/agents/agent_judge/) | ✅ Complete | Agent evaluation, quality assessment, automated judging, performance metrics |
## Additional Research Resources
| **Advanced Research System** | An enhanced implementation of the orchestrator-worker pattern from Anthropic's paper "How we built our multi-agent research system", featuring parallel execution, LLM-as-judge evaluation, and professional report generation. | [Anthropic Paper](https://www.anthropic.com/engineering/built-multi-agent-research-system) | [GitHub Repository](https://github.com/The-Swarm-Corporation/AdvancedResearch) | ✅ Complete | Orchestrator-worker architecture, parallel execution, Exa API integration, export capabilities |
### Multi-Agent Papers Compilation
We maintain a comprehensive list of multi-agent research papers at: [awesome-multi-agent-papers](https://github.com/kyegomez/awesome-multi-agent-papers)
### Research Lists
Our research compilation includes:
- **Projects**: ModelScope-Agent, Gorilla, BMTools, LMQL, Langchain, MetaGPT, AutoGPT, and more
- **Research Papers**: BOLAA, ToolLLM, Communicative Agents, Mind2Web, Voyager, Tree of Thoughts, and many others
- **Blog Articles**: Latest insights and developments in autonomous agents
- **Talks**: Presentations from leading researchers like Geoffrey Hinton and Andrej Karpathy
## Implementation Details
### MALT Framework
The MALT implementation provides:
- **Three-Agent Architecture**: Creator, Verifier, and Refiner agents
- **Structured Workflow**: Coordinated task execution with conversation history
- **Reliability Features**: Error handling, validation, and quality assurance
- **Extensibility**: Custom agent integration and configuration options
### MAI-DxO System
The MAI Diagnostic Orchestrator features:
- **Virtual Physician Panel**: Multiple specialized medical agents
- **Cost Optimization**: Efficient diagnostic workflows
- **Iterative Refinement**: Continuous improvement of diagnoses
- **Medical Expertise**: Domain-specific knowledge and reasoning
### AI-CoScientist Framework
The AI-CoScientist implementation includes:
- **Tournament-Based Selection**: Elo rating system for hypothesis ranking
- **Peer Review System**: Comprehensive evaluation of scientific proposals
- **Hypothesis Evolution**: Iterative refinement based on feedback
- **Diversity Control**: Proximity analysis to maintain hypothesis variety
### Mixture of Agents (MoA)
The MoA architecture provides:
- **Parallel Processing**: Multiple agents working simultaneously
- **Expert Specialization**: Domain-specific agent capabilities
- **Iterative Refinement**: Continuous improvement through collaboration
- **State-of-the-Art Performance**: Achieving superior results through collective intelligence
## Contributing
@ -156,7 +87,7 @@ If you use any of these implementations in your research, please cite the origin
Join our community to stay updated on the latest multi-agent research implementations:
- **Discord**: [Join our community](https://discord.gg/jM3Z6M9uMq)
- **Discord**: [Join our community](https://discord.gg/EamjgSaEQf)
- **Documentation**: [docs.swarms.world](https://docs.swarms.world)

File diff suppressed because it is too large Load Diff

@ -192,7 +192,7 @@ Join our community of agent engineers and researchers for technical support, cut
| 🌐 Website | Official project website | [swarms.ai](https://swarms.ai) |
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |

@ -43,7 +43,7 @@ To ensure high-quality contributions and streamline the process, please adhere t
## Get Involved
1. **Join the Community**:
- Become an active member of the Swarms community by joining our Discord server: [Join Now](https://discord.gg/jM3Z6M9uMq). The Discord server serves as a hub for discussions, updates, and support.
- Become an active member of the Swarms community by joining our Discord server: [Join Now](https://discord.gg/EamjgSaEQf). The Discord server serves as a hub for discussions, updates, and support.
2. **Stay Updated**:
- Keep track of the latest updates, announcements, and bounty opportunities by regularly checking the Discord channel and the GitHub repository.

@ -45,7 +45,7 @@ Welcome to the Swarms ecosystem. Click any tile below to explore our products, c
<a class="resource-card" href="https://github.com/The-Swarm-Corporation/swarms-rs" target="_blank">🦀 GitHub: Swarms (Rust)</a>
<a class="resource-card" href="https://discord.gg/jM3Z6M9uMq" target="_blank">💬 Join Our Discord</a>
<a class="resource-card" href="https://discord.gg/EamjgSaEQf" target="_blank">💬 Join Our Discord</a>
<a class="resource-card" href="https://t.me/swarmsgroupchat" target="_blank">📱 Telegram Group</a>
@ -67,7 +67,7 @@ Welcome to the Swarms ecosystem. Click any tile below to explore our products, c
| Chat UI | [swarms.world/platform/chat](https://swarms.world/platform/chat) |
| Marketplace | [swarms.world](https://swarms.world) |
| Startup App | [Apply Here](https://www.swarms.xyz/programs/startups) |
| Discord | [Join Now](https://discord.gg/jM3Z6M9uMq) |
| Discord | [Join Now](https://discord.gg/EamjgSaEQf) |
| Telegram | [Group Chat](https://t.me/swarmsgroupchat) |
| Twitter/X | [@swarms_corp](https://x.com/swarms_corp) |
| Blog | [medium.com/@kyeg](https://medium.com/@kyeg) |

@ -7,7 +7,7 @@ Before we dive into the code, let's briefly introduce the Swarms framework. Swar
For more information and to contribute to the project, visit the [Swarms GitHub repository](https://github.com/kyegomez/swarms). We highly recommend exploring the documentation for a deeper understanding of Swarms' capabilities.
Additional resources:
- [Swarms Discord](https://discord.gg/jM3Z6M9uMq) for community discussions
- [Swarms Discord](https://discord.gg/EamjgSaEQf) for community discussions
- [Swarms Twitter](https://x.com/swarms_corp) for updates
- [Swarms Spotify](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994) for podcasts
- [Swarms Blog](https://medium.com/@kyeg) for in-depth articles
@ -460,7 +460,7 @@ This system provides a powerful foundation for financial analysis, but there's a
Remember, the Swarms framework is a powerful and flexible tool that can be adapted to a wide range of complex tasks beyond just financial analysis. We encourage you to explore the [Swarms GitHub repository](https://github.com/kyegomez/swarms) for more examples and inspiration.
For more in-depth discussions and community support, consider joining the [Swarms Discord](https://discord.gg/jM3Z6M9uMq). You can also stay updated with the latest developments by following [Swarms on Twitter](https://x.com/swarms_corp).
For more in-depth discussions and community support, consider joining the [Swarms Discord](https://discord.gg/EamjgSaEQf). You can also stay updated with the latest developments by following [Swarms on Twitter](https://x.com/swarms_corp).
If you're interested in learning more about AI and its applications in various fields, check out the [Swarms Spotify podcast](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994) and the [Swarms Blog](https://medium.com/@kyeg) for insightful articles and discussions.
@ -474,7 +474,7 @@ By leveraging the power of multi-agent AI systems, you're well-equipped to navig
* [Swarms Github](https://github.com/kyegomez/swarms)
* [Swarms Discord](https://discord.gg/jM3Z6M9uMq)
* [Swarms Discord](https://discord.gg/EamjgSaEQf)
* [Swarms Twitter](https://x.com/swarms_corp)
* [Swarms Spotify](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994)
* [Swarms Blog](https://medium.com/@kyeg)

@ -261,7 +261,7 @@ The table below summarizes the estimated savings for each use case:
- [book a call](https://cal.com/swarms)
- Swarms Discord: https://discord.gg/jM3Z6M9uMq
- Swarms Discord: https://discord.gg/EamjgSaEQf
- Swarms Twitter: https://x.com/swarms_corp

@ -1,6 +1,6 @@
# Welcome to Swarms Docs Home
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/jM3Z6M9uMq) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/swarms_corp)
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/EamjgSaEQf) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/swarms_corp)
## What is Swarms?
@ -79,7 +79,7 @@ Here you'll find references about the Swarms framework, marketplace, community,
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |

@ -503,7 +503,7 @@ Schedule quarterly audits to refine structure and content across all repositorie
Promote your contributions via:
- **Swarms Discord**: https://discord.gg/jM3Z6M9uMq
- **Swarms Discord**: https://discord.gg/EamjgSaEQf
- **Swarms Telegram**: https://t.me/swarmsgroupchat
@ -1180,7 +1180,7 @@ If you encounter issues:
1. **Check the FAQ** in the main documentation
2. **Search existing issues** on GitHub
3. **Ask in the Discord community**: [discord.gg/jM3Z6M9uMq](https://discord.gg/jM3Z6M9uMq)
3. **Ask in the Discord community**: [discord.gg/jM3Z6M9uMq](https://discord.gg/EamjgSaEQf)
4. **Create a GitHub issue** with:
- Your operating system
- Python version
@ -1804,7 +1804,7 @@ If you'd like technical support, join our Discord below and stay updated on our
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |
@ -1861,7 +1861,7 @@ This index provides a categorized list of examples and tutorials for using the S
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |
@ -2294,7 +2294,7 @@ If you use any of these implementations in your research, please cite the origin
Join our community to stay updated on the latest multi-agent research implementations:
- **Discord**: [Join our community](https://discord.gg/jM3Z6M9uMq)
- **Discord**: [Join our community](https://discord.gg/EamjgSaEQf)
- **Documentation**: [docs.swarms.world](https://docs.swarms.world)
@ -2503,7 +2503,7 @@ Join our community of agent engineers and researchers for technical support, cut
| 🌐 Website | Official project website | [swarms.ai](https://swarms.ai) |
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |
@ -2575,7 +2575,7 @@ To ensure high-quality contributions and streamline the process, please adhere t
## Get Involved
1. **Join the Community**:
- Become an active member of the Swarms community by joining our Discord server: [Join Now](https://discord.gg/jM3Z6M9uMq). The Discord server serves as a hub for discussions, updates, and support.
- Become an active member of the Swarms community by joining our Discord server: [Join Now](https://discord.gg/EamjgSaEQf). The Discord server serves as a hub for discussions, updates, and support.
2. **Stay Updated**:
- Keep track of the latest updates, announcements, and bounty opportunities by regularly checking the Discord channel and the GitHub repository.
@ -2657,7 +2657,7 @@ Welcome to the Swarms ecosystem. Click any tile below to explore our products, c
<a class="resource-card" href="https://github.com/The-Swarm-Corporation/swarms-rs" target="_blank">🦀 GitHub: Swarms (Rust)</a>
<a class="resource-card" href="https://discord.gg/jM3Z6M9uMq" target="_blank">💬 Join Our Discord</a>
<a class="resource-card" href="https://discord.gg/EamjgSaEQf" target="_blank">💬 Join Our Discord</a>
<a class="resource-card" href="https://t.me/swarmsgroupchat" target="_blank">📱 Telegram Group</a>
@ -2679,7 +2679,7 @@ Welcome to the Swarms ecosystem. Click any tile below to explore our products, c
| Chat UI | [swarms.world/platform/chat](https://swarms.world/platform/chat) |
| Marketplace | [swarms.world](https://swarms.world) |
| Startup App | [Apply Here](https://www.swarms.xyz/programs/startups) |
| Discord | [Join Now](https://discord.gg/jM3Z6M9uMq) |
| Discord | [Join Now](https://discord.gg/EamjgSaEQf) |
| Telegram | [Group Chat](https://t.me/swarmsgroupchat) |
| Twitter/X | [@swarms_corp](https://x.com/swarms_corp) |
| Blog | [medium.com/@kyeg](https://medium.com/@kyeg) |
@ -2961,7 +2961,7 @@ Before we dive into the code, let's briefly introduce the Swarms framework. Swar
For more information and to contribute to the project, visit the [Swarms GitHub repository](https://github.com/kyegomez/swarms). We highly recommend exploring the documentation for a deeper understanding of Swarms' capabilities.
Additional resources:
- [Swarms Discord](https://discord.gg/jM3Z6M9uMq) for community discussions
- [Swarms Discord](https://discord.gg/EamjgSaEQf) for community discussions
- [Swarms Twitter](https://x.com/swarms_corp) for updates
- [Swarms Spotify](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994) for podcasts
- [Swarms Blog](https://medium.com/@kyeg) for in-depth articles
@ -3414,7 +3414,7 @@ This system provides a powerful foundation for financial analysis, but there's a
Remember, the Swarms framework is a powerful and flexible tool that can be adapted to a wide range of complex tasks beyond just financial analysis. We encourage you to explore the [Swarms GitHub repository](https://github.com/kyegomez/swarms) for more examples and inspiration.
For more in-depth discussions and community support, consider joining the [Swarms Discord](https://discord.gg/jM3Z6M9uMq). You can also stay updated with the latest developments by following [Swarms on Twitter](https://x.com/swarms_corp).
For more in-depth discussions and community support, consider joining the [Swarms Discord](https://discord.gg/EamjgSaEQf). You can also stay updated with the latest developments by following [Swarms on Twitter](https://x.com/swarms_corp).
If you're interested in learning more about AI and its applications in various fields, check out the [Swarms Spotify podcast](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994) and the [Swarms Blog](https://medium.com/@kyeg) for insightful articles and discussions.
@ -3428,7 +3428,7 @@ By leveraging the power of multi-agent AI systems, you're well-equipped to navig
* [Swarms Github](https://github.com/kyegomez/swarms)
* [Swarms Discord](https://discord.gg/jM3Z6M9uMq)
* [Swarms Discord](https://discord.gg/EamjgSaEQf)
* [Swarms Twitter](https://x.com/swarms_corp)
* [Swarms Spotify](https://open.spotify.com/show/2HLiswhmUaMdjHC8AUHcCF?si=c831ef10c5ef4994)
* [Swarms Blog](https://medium.com/@kyeg)
@ -4457,7 +4457,7 @@ The table below summarizes the estimated savings for each use case:
- [book a call](https://cal.com/swarms)
- Swarms Discord: https://discord.gg/jM3Z6M9uMq
- Swarms Discord: https://discord.gg/EamjgSaEQf
- Swarms Twitter: https://x.com/swarms_corp
@ -5349,7 +5349,7 @@ By leveraging expert guidance and peer insights, you can position your organizat
# Welcome to Swarms Docs Home
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/jM3Z6M9uMq) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/swarms_corp)
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/EamjgSaEQf) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/swarms_corp)
## What is Swarms?
@ -5428,7 +5428,7 @@ Here you'll find references about the Swarms framework, marketplace, community,
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |
@ -6056,7 +6056,7 @@ When creating your SIP, copy this template:
# Welcome to Swarms Docs Home
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/jM3Z6M9uMq) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/swarms_corp)
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/EamjgSaEQf) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/swarms_corp)
## What is Swarms?
@ -8804,7 +8804,7 @@ Join our community of agent engineers and researchers for technical support, cut
|----------|-------------|------|
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |
@ -12747,7 +12747,7 @@ By understanding the purpose and role of each folder in the Swarms framework, us
- **Community Support**
- URL: [Submit issue](https://discord.gg/jM3Z6M9uMq)
- URL: [Submit issue](https://discord.gg/EamjgSaEQf)
- Ask the community for support in real-time and or admin support
--------------------------------------------------
@ -14643,7 +14643,7 @@ The following example showcases how to use the `AgentRearrange` class to manage
```python
from swarms.structs.agent import Agent
from swarms.structs.rearrange import AgentRearrange
from swarms.structs.agent_rearrange import AgentRearrange
# Initialize the Director agent using Anthropic model via model_name
director = Agent(
@ -15569,7 +15569,7 @@ If you have any questions or need assistance, please feel free to open an issue
| **Platform** | **Purpose** | **Join Link** | **Benefits** |
|--------------|-------------|---------------|--------------|
| **Discord Community** | Real-time support & discussions | [Join Discord](https://discord.gg/jM3Z6M9uMq) | • 24/7 developer support<br/>• Weekly community events<br/>• Direct access to core team<br/>• Beta feature previews |
| **Discord Community** | Real-time support & discussions | [Join Discord](https://discord.gg/EamjgSaEQf) | • 24/7 developer support<br/>• Weekly community events<br/>• Direct access to core team<br/>• Beta feature previews |
| **Twitter/X** | Latest updates & announcements | [Follow @swarms_corp](https://x.com/swarms_corp) | • Breaking news & updates<br/>• Community highlights<br/>• Technical insights<br/>• Industry partnerships |
| **LinkedIn** | Professional network & updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | • Professional networking<br/>• Career opportunities<br/>• Enterprise partnerships<br/>• Industry insights |
| **YouTube** | Tutorials & technical content | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | • In-depth tutorials<br/>• Live coding sessions<br/>• Architecture deep dives<br/>• Community showcases |
@ -15629,7 +15629,7 @@ If you have any questions or need assistance, please feel free to open an issue
| **1** | [Install Swarms Python Framework](https://docs.swarms.world/en/latest/swarms/install/install/) | 5 minutes |
| **2** | [Run Your First Agent](https://docs.swarms.world/en/latest/swarms/examples/basic_agent/) | 10 minutes |
| **3** | [Try Multi-Agent Workflows](https://docs.swarms.world/en/latest/swarms/examples/sequential_example/) | 15 minutes |
| **4** | [Join Our Discord Community](https://discord.gg/jM3Z6M9uMq) | 2 minutes |
| **4** | [Join Our Discord Community](https://discord.gg/EamjgSaEQf) | 2 minutes |
| **5** | [Explore Enterprise Features](https://docs.swarms.world/en/latest/swarms_cloud/swarms_api/) | 20 minutes |
---
@ -18820,7 +18820,7 @@ Join our community of agent engineers and researchers for technical support, cut
|----------|-------------|------|
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |
@ -19611,7 +19611,7 @@ If you're facing issues or want to learn more, check out the following resources
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |
@ -19915,7 +19915,7 @@ If you're facing issues or want to learn more, check out the following resources
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |
@ -22379,7 +22379,7 @@ If you're facing issues or want to learn more, check out the following resources
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |
@ -27453,7 +27453,7 @@ Stay tuned for updates on the Swarm Exchange launch.
- **Documentation:** [Swarms Documentation](https://docs.swarms.world)
- **Support:** Contact us via our [Discord Community](https://discord.gg/jM3Z6M9uMq).
- **Support:** Contact us via our [Discord Community](https://discord.gg/EamjgSaEQf).
---
@ -30381,7 +30381,7 @@ graph TD
- [Tutorials](https://docs.swarms.world/tutorials)
=== "💬 Community"
- [Discord Server](https://discord.gg/jM3Z6M9uMq)
- [Discord Server](https://discord.gg/EamjgSaEQf)
- [GitHub Discussions](https://github.com/kyegomez/swarms/discussions)
=== "🔧 Development"
@ -30425,7 +30425,7 @@ The MCP integration brings powerful external tool connectivity to Swarms agents,
!!! tip "Stay Updated"
Join our [Discord community](https://discord.gg/jM3Z6M9uMq) to stay informed about new MCP features and connect with other developers building amazing agent applications.
Join our [Discord community](https://discord.gg/EamjgSaEQf) to stay informed about new MCP features and connect with other developers building amazing agent applications.
---
@ -38385,7 +38385,7 @@ Join our community of agent engineers and researchers for technical support, cut
|----------|-------------|------|
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |
@ -44327,7 +44327,7 @@ The flow pattern uses arrow notation (`->`) to define execution order:
### Basic Sequential Flow
```python
from swarms.structs.swarm_arange import SwarmRearrange
from swarms.structs.swarm_rearrange import SwarmRearrange
import os
from swarms import Agent, AgentRearrange
from swarm_models import OpenAIChat
@ -46084,7 +46084,7 @@ The Swarms team is committed to providing exceptional technical support to help
| **Major Features (SIPs)** | New agent types, core changes, integrations | 1-2 weeks | [SIP Guidelines](protocol/sip.md) |
| **Minor Features** | Small enhancements, straightforward additions | < 48 hours | [GitHub Issues](https://github.com/kyegomez/swarms/issues) |
| **Private Issues** | Security concerns, enterprise consulting | < 4 hours | [Book Support Call](https://cal.com/swarms/swarms-technical-support?overlayCalendar=true) |
| **Real-time Help** | Quick questions, community discussions | Immediate | [Discord Community](https://discord.gg/jM3Z6M9uMq) |
| **Real-time Help** | Quick questions, community discussions | Immediate | [Discord Community](https://discord.gg/EamjgSaEQf) |
| **Documentation** | Usage guides, examples, tutorials | Self-service | [docs.swarms.world](https://docs.swarms.world) |
---
@ -46263,7 +46263,7 @@ Get instant help from our active community of developers and core team members.
### **Getting Help on Discord**
1. **Join here**: [https://discord.gg/jM3Z6M9uMq](https://discord.gg/jM3Z6M9uMq)
1. **Join here**: [https://discord.gg/EamjgSaEQf](https://discord.gg/EamjgSaEQf)
2. **Read the rules** and introduce yourself in #general
@ -46434,7 +46434,7 @@ Help improve support for everyone:
| Urgency | Best Channel |
|---------|-------------|
| **Emergency** | [Book Immediate Call](https://cal.com/swarms/swarms-technical-support?overlayCalendar=true) |
| **Urgent** | [Discord #technical-support](https://discord.gg/jM3Z6M9uMq) |
| **Urgent** | [Discord #technical-support](https://discord.gg/EamjgSaEQf) |
| **Standard** | [GitHub Issues](https://github.com/kyegomez/swarms/issues) |
| **Major Features** | [SIP Guidelines](protocol/sip.md) |
| **Minor Features** | [GitHub Issues](https://github.com/kyegomez/swarms/issues) |
@ -50226,7 +50226,7 @@ agent_config = {
[:material-file-document: Swarms.ai Documentation](https://docs.swarms.world){ .md-button }
[:material-application: Swarms.ai Platform](https://swarms.world/platform){ .md-button }
[:material-key: API Key Management](https://swarms.world/platform/api-keys){ .md-button }
[:material-forum: Swarms.ai Community](https://discord.gg/jM3Z6M9uMq){ .md-button }
[:material-forum: Swarms.ai Community](https://discord.gg/EamjgSaEQf){ .md-button }
--------------------------------------------------
@ -50379,7 +50379,7 @@ SWARMS_LOG_LEVEL=INFO
| Community Channel | Description | Link |
|-----------------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| Discord Community | Join our active developer community for real-time support and discussions | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| Discord Community | Join our active developer community for real-time support and discussions | [Join Discord](https://discord.gg/EamjgSaEQf) |
| GitHub Discussions | Ask questions and share ideas | [GitHub Discussions](https://github.com/The-Swarm-Corporation/swarms/discussions) |
| Twitter/X | Follow for updates and announcements | [Twitter/X](https://x.com/swarms_corp) |
@ -55111,7 +55111,7 @@ Join our community of agent engineers and researchers for technical support, cut
|----------|-------------|------|
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |
@ -57475,7 +57475,7 @@ Error responses include a detailed message explaining the issue:
|--------------|---------------------|
| Documentation | [https://docs.swarms.world](https://docs.swarms.world) |
| Email | kye@swarms.world |
| Community | [https://discord.gg/jM3Z6M9uMq](https://discord.gg/jM3Z6M9uMq) |
| Community | [https://discord.gg/EamjgSaEQf](https://discord.gg/EamjgSaEQf) |
| Marketplace | [https://swarms.world](https://swarms.world) |
| Website | [https://swarms.ai](https://swarms.ai) |
@ -58440,7 +58440,7 @@ print(result)
We're excited to see how you leverage Swarms-Memory in your projects! Join our community on Discord to share your experiences, ask questions, and stay updated on the latest developments.
- **🐦 Twitter**: [Follow us on Twitter](https://twitter.com/swarms_platform)
- **📢 Discord**: [Join the Agora Discord](https://discord.gg/jM3Z6M9uMq)
- **📢 Discord**: [Join the Agora Discord](https://discord.gg/EamjgSaEQf)
- **Swarms Platform**: [Visit our website](https://swarms.ai)
- **📙 Documentation**: [Read the Docs](https://docs.swarms.ai)
@ -60129,9 +60129,9 @@ To further enhance your understanding and usage of the Swarms Platform, explore
### Links
- [API Documentation](https://docs.swarms.world)
- [Community Forums](https://discord.gg/jM3Z6M9uMq)
- [Community Forums](https://discord.gg/EamjgSaEQf)
- [Tutorials and Guides](https://docs.swarms.world))
- [Support](https://discord.gg/jM3Z6M9uMq)
- [Support](https://discord.gg/EamjgSaEQf)
## Conclusion

@ -48,7 +48,7 @@ extra:
- icon: fontawesome/brands/github
link: https://github.com/kyegomez/swarms
- icon: fontawesome/brands/discord
link: https://discord.gg/jM3Z6M9uMq
link: https://discord.gg/EamjgSaEQf
- icon: fontawesome/brands/youtube
link: https://www.youtube.com/@kyegomez3242
- icon: fontawesome/brands/linkedin
@ -354,6 +354,7 @@ nav:
- CookBook Index: "examples/cookbook_index.md"
- Paper Implementations: "examples/paper_implementations.md"
- Templates & Applications: "examples/templates.md"
- Community Resources: "examples/community_resources.md"
- Basic Examples:
- Individual Agents:
- Basic Agent: "swarms/examples/basic_agent.md"
@ -414,6 +415,9 @@ nav:
- Swarms of Browser Agents: "swarms/examples/swarms_of_browser_agents.md"
- ConcurrentWorkflow with VLLM Agents: "swarms/examples/vllm.md"
- Apps:
- Smart Database: "examples/smart_database.md"
# - Swarm Models:
# - Overview: "swarms/models/index.md"

@ -1,7 +1,7 @@
# Welcome to Swarms Docs Home
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/jM3Z6M9uMq) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/swarms_corp)
[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/EamjgSaEQf) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/swarms_corp)
## What is Swarms?

@ -848,7 +848,7 @@ Join our community of agent engineers and researchers for technical support, cut
|----------|-------------|------|
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |

@ -155,5 +155,5 @@ By understanding the purpose and role of each folder in the Swarms framework, us
- **Community Support**
- URL: [Submit issue](https://discord.gg/jM3Z6M9uMq)
- URL: [Submit issue](https://discord.gg/EamjgSaEQf)
- Ask the community for support in real-time and or admin support

@ -49,7 +49,7 @@ The following example showcases how to use the `AgentRearrange` class to manage
```python
from swarms.structs.agent import Agent
from swarms.structs.rearrange import AgentRearrange
from swarms.structs.agent_rearrange import AgentRearrange
# Initialize the Director agent using Anthropic model via model_name
director = Agent(

@ -68,7 +68,7 @@
| **Platform** | **Purpose** | **Join Link** | **Benefits** |
|--------------|-------------|---------------|--------------|
| **Discord Community** | Real-time support & discussions | [Join Discord](https://discord.gg/jM3Z6M9uMq) | • 24/7 developer support<br/>• Weekly community events<br/>• Direct access to core team<br/>• Beta feature previews |
| **Discord Community** | Real-time support & discussions | [Join Discord](https://discord.gg/EamjgSaEQf) | • 24/7 developer support<br/>• Weekly community events<br/>• Direct access to core team<br/>• Beta feature previews |
| **Twitter/X** | Latest updates & announcements | [Follow @swarms_corp](https://x.com/swarms_corp) | • Breaking news & updates<br/>• Community highlights<br/>• Technical insights<br/>• Industry partnerships |
| **LinkedIn** | Professional network & updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | • Professional networking<br/>• Career opportunities<br/>• Enterprise partnerships<br/>• Industry insights |
| **YouTube** | Tutorials & technical content | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | • In-depth tutorials<br/>• Live coding sessions<br/>• Architecture deep dives<br/>• Community showcases |
@ -128,7 +128,7 @@
| **1** | [Install Swarms Python Framework](https://docs.swarms.world/en/latest/swarms/install/install/) | 5 minutes |
| **2** | [Run Your First Agent](https://docs.swarms.world/en/latest/swarms/examples/basic_agent/) | 10 minutes |
| **3** | [Try Multi-Agent Workflows](https://docs.swarms.world/en/latest/swarms/examples/sequential_example/) | 15 minutes |
| **4** | [Join Our Discord Community](https://discord.gg/jM3Z6M9uMq) | 2 minutes |
| **4** | [Join Our Discord Community](https://discord.gg/EamjgSaEQf) | 2 minutes |
| **5** | [Explore Enterprise Features](https://docs.swarms.world/en/latest/swarms_cloud/swarms_api/) | 20 minutes |
---

@ -127,7 +127,7 @@ Join our community of agent engineers and researchers for technical support, cut
|----------|-------------|------|
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |

@ -124,7 +124,7 @@ If you're facing issues or want to learn more, check out the following resources
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |

@ -69,7 +69,7 @@ If you're facing issues or want to learn more, check out the following resources
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |

@ -130,7 +130,7 @@ If you're facing issues or want to learn more, check out the following resources
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
| 💬 Discord | [Join Discord](https://discord.gg/EamjgSaEQf) | Live chat and community support |
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |

@ -26,9 +26,9 @@ Before you begin, ensure you have the following installed:
=== "pip (Recommended)"
#### Headless Installation
#### Simple Installation
The headless installation of `swarms` is designed for environments where graphical user interfaces (GUI) are not needed, making it more lightweight and suitable for server-side applications.
Simplest manner of installing swarms leverages using PIP. For faster installs and build times, we recommend using UV
```bash
pip install swarms
@ -65,6 +65,49 @@ Before you begin, ensure you have the following installed:
uv pip install -e .[desktop]
```
=== "Poetry Installation"
Poetry is a modern dependency management and packaging tool for Python. It provides a more robust way to manage project dependencies and virtual environments.
=== "Basic Installation"
```bash
# Install Poetry first
curl -sSL https://install.python-poetry.org | python3 -
# Install swarms using Poetry
poetry add swarms
```
=== "Development Installation"
```bash
# Clone the repository
git clone https://github.com/kyegomez/swarms.git
cd swarms
# Install in editable mode
poetry install
```
For desktop installation with extras:
```bash
poetry install --extras "desktop"
```
=== "Using Poetry with existing projects"
If you have an existing project with a `pyproject.toml` file:
```bash
# Add swarms to your project dependencies
poetry add swarms
# Or add with specific extras
poetry add "swarms[desktop]"
```
=== "Development Installation"
=== "Using virtualenv"

@ -152,7 +152,7 @@ Stay tuned for updates on the Swarm Exchange launch.
- **Documentation:** [Swarms Documentation](https://docs.swarms.world)
- **Support:** Contact us via our [Discord Community](https://discord.gg/jM3Z6M9uMq).
- **Support:** Contact us via our [Discord Community](https://discord.gg/EamjgSaEQf).
---

@ -723,7 +723,7 @@ graph TD
- [Tutorials](https://docs.swarms.world/tutorials)
=== "💬 Community"
- [Discord Server](https://discord.gg/jM3Z6M9uMq)
- [Discord Server](https://discord.gg/EamjgSaEQf)
- [GitHub Discussions](https://github.com/kyegomez/swarms/discussions)
=== "🔧 Development"
@ -767,7 +767,7 @@ The MCP integration brings powerful external tool connectivity to Swarms agents,
!!! tip "Stay Updated"
Join our [Discord community](https://discord.gg/jM3Z6M9uMq) to stay informed about new MCP features and connect with other developers building amazing agent applications.
Join our [Discord community](https://discord.gg/EamjgSaEQf) to stay informed about new MCP features and connect with other developers building amazing agent applications.
---

@ -294,7 +294,7 @@ Join our community of agent engineers and researchers for technical support, cut
|----------|-------------|------|
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |

@ -46,7 +46,7 @@ The flow pattern uses arrow notation (`->`) to define execution order:
### Basic Sequential Flow
```python
from swarms.structs.swarm_arange import SwarmRearrange
from swarms.structs.swarm_rearrange import SwarmRearrange
import os
from swarms import Agent, AgentRearrange
from swarm_models import OpenAIChat

@ -18,7 +18,7 @@ The Swarms team is committed to providing exceptional technical support to help
| **Major Features (SIPs)** | New agent types, core changes, integrations | 1-2 weeks | [SIP Guidelines](protocol/sip.md) |
| **Minor Features** | Small enhancements, straightforward additions | < 48 hours | [GitHub Issues](https://github.com/kyegomez/swarms/issues) |
| **Private Issues** | Security concerns, enterprise consulting | < 4 hours | [Book Support Call](https://cal.com/swarms/swarms-technical-support?overlayCalendar=true) |
| **Real-time Help** | Quick questions, community discussions | Immediate | [Discord Community](https://discord.gg/jM3Z6M9uMq) |
| **Real-time Help** | Quick questions, community discussions | Immediate | [Discord Community](https://discord.gg/EamjgSaEQf) |
| **Documentation** | Usage guides, examples, tutorials | Self-service | [docs.swarms.world](https://docs.swarms.world) |
---
@ -197,7 +197,7 @@ Get instant help from our active community of developers and core team members.
### **Getting Help on Discord**
1. **Join here**: [https://discord.gg/jM3Z6M9uMq](https://discord.gg/jM3Z6M9uMq)
1. **Join here**: [https://discord.gg/EamjgSaEQf](https://discord.gg/EamjgSaEQf)
2. **Read the rules** and introduce yourself in #general
@ -368,7 +368,7 @@ Help improve support for everyone:
| Urgency | Best Channel |
|---------|-------------|
| **Emergency** | [Book Immediate Call](https://cal.com/swarms/swarms-technical-support?overlayCalendar=true) |
| **Urgent** | [Discord #technical-support](https://discord.gg/jM3Z6M9uMq) |
| **Urgent** | [Discord #technical-support](https://discord.gg/EamjgSaEQf) |
| **Standard** | [GitHub Issues](https://github.com/kyegomez/swarms/issues) |
| **Major Features** | [SIP Guidelines](protocol/sip.md) |
| **Minor Features** | [GitHub Issues](https://github.com/kyegomez/swarms/issues) |

@ -605,4 +605,4 @@ agent_config = {
[:material-file-document: Swarms.ai Documentation](https://docs.swarms.world){ .md-button }
[:material-application: Swarms.ai Platform](https://swarms.world/platform){ .md-button }
[:material-key: API Key Management](https://swarms.world/platform/api-keys){ .md-button }
[:material-forum: Swarms.ai Community](https://discord.gg/jM3Z6M9uMq){ .md-button }
[:material-forum: Swarms.ai Community](https://discord.gg/EamjgSaEQf){ .md-button }

@ -145,7 +145,7 @@ SWARMS_LOG_LEVEL=INFO
| Community Channel | Description | Link |
|-----------------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| Discord Community | Join our active developer community for real-time support and discussions | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| Discord Community | Join our active developer community for real-time support and discussions | [Join Discord](https://discord.gg/EamjgSaEQf) |
| GitHub Discussions | Ask questions and share ideas | [GitHub Discussions](https://github.com/The-Swarm-Corporation/swarms/discussions) |
| Twitter/X | Follow for updates and announcements | [Twitter/X](https://x.com/swarms_corp) |

@ -1157,7 +1157,7 @@ Join our community of agent engineers and researchers for technical support, cut
|----------|-------------|------|
| 📚 Documentation | Official documentation and guides | [docs.swarms.world](https://docs.swarms.world) |
| 📝 Blog | Latest updates and technical articles | [Medium](https://medium.com/@kyeg) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/jM3Z6M9uMq) |
| 💬 Discord | Live chat and community support | [Join Discord](https://discord.gg/EamjgSaEQf) |
| 🐦 Twitter | Latest news and announcements | [@kyegomez](https://twitter.com/kyegomez) |
| 👥 LinkedIn | Professional network and updates | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) |
| 📺 YouTube | Tutorials and demos | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) |

@ -1242,7 +1242,7 @@ Error responses include a detailed message explaining the issue:
|--------------|---------------------|
| Documentation | [https://docs.swarms.world](https://docs.swarms.world) |
| Email | kye@swarms.world |
| Community | [https://discord.gg/jM3Z6M9uMq](https://discord.gg/jM3Z6M9uMq) |
| Community | [https://discord.gg/EamjgSaEQf](https://discord.gg/EamjgSaEQf) |
| Marketplace | [https://swarms.world](https://swarms.world) |
| Website | [https://swarms.ai](https://swarms.ai) |

@ -161,7 +161,7 @@ print(result)
We're excited to see how you leverage Swarms-Memory in your projects! Join our community on Discord to share your experiences, ask questions, and stay updated on the latest developments.
- **🐦 Twitter**: [Follow us on Twitter](https://twitter.com/swarms_platform)
- **📢 Discord**: [Join the Agora Discord](https://discord.gg/jM3Z6M9uMq)
- **📢 Discord**: [Join the Agora Discord](https://discord.gg/EamjgSaEQf)
- **Swarms Platform**: [Visit our website](https://swarms.ai)
- **📙 Documentation**: [Read the Docs](https://docs.swarms.ai)

@ -113,9 +113,9 @@ To further enhance your understanding and usage of the Swarms Platform, explore
### Links
- [API Documentation](https://docs.swarms.world)
- [Community Forums](https://discord.gg/jM3Z6M9uMq)
- [Community Forums](https://discord.gg/EamjgSaEQf)
- [Tutorials and Guides](https://docs.swarms.world))
- [Support](https://discord.gg/jM3Z6M9uMq)
- [Support](https://discord.gg/EamjgSaEQf)
## Conclusion

@ -1,5 +1,10 @@
from swarms import Agent
import litellm
litellm._turn_on_debug() # 👈 this is the 1-line change you need to make
# Initialize the agent
agent = Agent(
agent_name="Quantitative-Trading-Agent",
@ -40,8 +45,6 @@ agent = Agent(
interactive=True,
no_reasoning_prompt=True,
streaming_on=True,
# dashboard=True
llm_base_url="https://api.openai.com/v1",
)
out = agent.run(

File diff suppressed because it is too large Load Diff

@ -0,0 +1,258 @@
# Getting Started with GraphWorkflow
Welcome to **GraphWorkflow** - The LangGraph Killer! 🚀
This guide will get you up and running with Swarms' GraphWorkflow system in minutes.
## 🚀 Quick Installation
```bash
# Install Swarms with all dependencies
uv pip install swarms
# Optional: Install visualization dependencies
uv pip install graphviz
# Verify installation
python -c "from swarms.structs.graph_workflow import GraphWorkflow; print('✅ GraphWorkflow ready')"
```
## 🎯 Choose Your Starting Point
### 📚 New to GraphWorkflow?
Start here: **[Quick Start Guide](quick_start_guide.py)**
```bash
python quick_start_guide.py
```
Learn GraphWorkflow in 5 easy steps:
- ✅ Create your first workflow
- ✅ Connect agents in sequence
- ✅ Set up parallel processing
- ✅ Use advanced patterns
- ✅ Monitor performance
### 🔬 Want to See Everything?
Run the comprehensive demo: **[Comprehensive Demo](comprehensive_demo.py)**
```bash
# See all features
python comprehensive_demo.py
# Focus on specific areas
python comprehensive_demo.py --demo healthcare
python comprehensive_demo.py --demo finance
python comprehensive_demo.py --demo parallel
```
### 🛠️ Need Setup Help?
Use the setup script: **[Setup and Test](setup_and_test.py)**
```bash
# Check your environment
python setup_and_test.py --check-only
# Install dependencies and run tests
python setup_and_test.py
```
## 📖 Documentation
### 📋 Quick Reference
```python
from swarms import Agent
from swarms.structs.graph_workflow import GraphWorkflow
# 1. Create agents
agent1 = Agent(agent_name="Researcher", model_name="gpt-4o-mini", max_loops=1)
agent2 = Agent(agent_name="Writer", model_name="gpt-4o-mini", max_loops=1)
# 2. Create workflow
workflow = GraphWorkflow(name="MyWorkflow", auto_compile=True)
# 3. Add agents and connections
workflow.add_node(agent1)
workflow.add_node(agent2)
workflow.add_edge("Researcher", "Writer")
# 4. Execute
results = workflow.run(task="Write about AI trends")
```
### 📚 Complete Documentation
- **[Technical Guide](graph_workflow_technical_guide.md)**: 4,000-word comprehensive guide
- **[Examples README](README.md)**: Complete examples overview
- **[API Reference](../../../docs/swarms/structs/)**: Detailed API documentation
## 🎨 Key Features Overview
### ⚡ Parallel Processing
```python
# Fan-out: One agent to multiple agents
workflow.add_edges_from_source("DataCollector", ["AnalystA", "AnalystB"])
# Fan-in: Multiple agents to one agent
workflow.add_edges_to_target(["SpecialistX", "SpecialistY"], "Synthesizer")
# Parallel chain: Many-to-many mesh
workflow.add_parallel_chain(["DataA", "DataB"], ["ProcessorX", "ProcessorY"])
```
### 🚀 Performance Optimization
```python
# Automatic compilation for 40-60% speedup
workflow = GraphWorkflow(auto_compile=True)
# Monitor performance
status = workflow.get_compilation_status()
print(f"Workers: {status['max_workers']}")
print(f"Layers: {status['cached_layers_count']}")
```
### 🎨 Professional Visualization
```python
# Generate beautiful workflow diagrams
workflow.visualize(
format="png", # png, svg, pdf, dot
show_summary=True, # Show parallel processing stats
engine="dot" # Layout algorithm
)
```
### 💾 Enterprise Features
```python
# Complete workflow serialization
json_data = workflow.to_json(include_conversation=True)
restored = GraphWorkflow.from_json(json_data)
# File persistence
workflow.save_to_file("my_workflow.json")
loaded = GraphWorkflow.load_from_file("my_workflow.json")
# Validation and monitoring
validation = workflow.validate(auto_fix=True)
summary = workflow.export_summary()
```
## 🏥 Real-World Examples
### Healthcare: Clinical Decision Support
```python
# Multi-specialist clinical workflow
workflow.add_edges_from_source("PatientData", [
"PrimaryCare", "Cardiologist", "Pharmacist"
])
workflow.add_edges_to_target([
"PrimaryCare", "Cardiologist", "Pharmacist"
], "CaseManager")
results = workflow.run(task="Analyze patient with chest pain...")
```
### Finance: Investment Analysis
```python
# Parallel financial analysis
workflow.add_parallel_chain(
["MarketData", "FundamentalData"],
["TechnicalAnalyst", "FundamentalAnalyst", "RiskManager"]
)
workflow.add_edges_to_target([
"TechnicalAnalyst", "FundamentalAnalyst", "RiskManager"
], "PortfolioManager")
results = workflow.run(task="Analyze tech sector allocation...")
```
## 🏃‍♂️ Performance Benchmarks
GraphWorkflow delivers **40-60% better performance** than sequential execution:
| Agents | Sequential | GraphWorkflow | Speedup |
|--------|------------|---------------|---------|
| 5 | 15.2s | 8.7s | 1.75x |
| 10 | 28.5s | 16.1s | 1.77x |
| 15 | 42.8s | 24.3s | 1.76x |
*Benchmarks run on 8-core CPU with gpt-4o-mini*
## 🆚 Why GraphWorkflow > LangGraph?
| Feature | GraphWorkflow | LangGraph |
|---------|---------------|-----------|
| **Parallel Processing** | ✅ Native fan-out/fan-in | ❌ Limited |
| **Performance** | ✅ 40-60% faster | ❌ Sequential bottlenecks |
| **Compilation** | ✅ Intelligent caching | ❌ No optimization |
| **Visualization** | ✅ Professional Graphviz | ❌ Basic diagrams |
| **Enterprise Features** | ✅ Full serialization | ❌ Limited persistence |
| **Error Handling** | ✅ Comprehensive validation | ❌ Basic checks |
| **Monitoring** | ✅ Rich metrics | ❌ Limited insights |
## 🛠️ Troubleshooting
### Common Issues
**Problem**: Import error
```bash
# Solution: Install dependencies
uv pip install swarms
python setup_and_test.py --install-deps
```
**Problem**: Slow execution
```python
# Solution: Enable compilation
workflow = GraphWorkflow(auto_compile=True)
workflow.compile() # Manual compilation
```
**Problem**: Memory issues
```python
# Solution: Clear conversation history
workflow.conversation = Conversation()
```
**Problem**: Graph validation errors
```python
# Solution: Use auto-fix
validation = workflow.validate(auto_fix=True)
if not validation['is_valid']:
print("Errors:", validation['errors'])
```
### Get Help
- 📖 **Read the docs**: [Technical Guide](graph_workflow_technical_guide.md)
- 🔍 **Check examples**: Browse this guide directory
- 🧪 **Run tests**: Use `python setup_and_test.py`
- 🐛 **Report bugs**: Open an issue on GitHub
## 🎯 Next Steps
1. **🎓 Learn**: Complete the [Quick Start Guide](quick_start_guide.py)
2. **🔬 Explore**: Try the [Comprehensive Demo](comprehensive_demo.py)
3. **🏥 Apply**: Adapt healthcare or finance examples
4. **📚 Study**: Read the [Technical Guide](graph_workflow_technical_guide.md)
5. **🚀 Deploy**: Build your production workflows
## 🎉 Ready to Build?
GraphWorkflow is **production-ready** and **enterprise-grade**. Join the revolution in multi-agent orchestration!
```bash
# Start your GraphWorkflow journey
python quick_start_guide.py
```
**The LangGraph Killer is here. Welcome to the future of multi-agent systems!** 🌟

@ -0,0 +1,322 @@
# GraphWorkflow Guide
Welcome to the comprehensive GraphWorkflow guide! This collection demonstrates the power and flexibility of Swarms' GraphWorkflow system - the LangGraph killer that provides superior multi-agent orchestration capabilities.
## 🚀 Quick Start
### Installation
```bash
# Install Swarms with all dependencies
uv pip install swarms
# Optional: Install visualization dependencies
uv pip install graphviz
# Verify installation
python -c "from swarms.structs.graph_workflow import GraphWorkflow; print('✅ GraphWorkflow ready')"
```
### Run Your First Example
```bash
# Start with the quick start guide
python quick_start_guide.py
# Or run the comprehensive demo
python comprehensive_demo.py
# For specific examples
python comprehensive_demo.py --demo healthcare
python comprehensive_demo.py --demo finance
```
## 📁 Example Files
### 🎓 Learning Examples
| File | Description | Complexity |
|------|-------------|------------|
| `quick_start_guide.py` | **START HERE** - Step-by-step introduction to GraphWorkflow | ⭐ Beginner |
| `graph_workflow_example.py` | Basic two-agent workflow example | ⭐ Beginner |
| `comprehensive_demo.py` | Complete feature demonstration with multiple use cases | ⭐⭐⭐ Advanced |
### 🏥 Healthcare Examples
| File | Description | Complexity |
|------|-------------|------------|
| `comprehensive_demo.py --demo healthcare` | Clinical decision support workflow | ⭐⭐⭐ Advanced |
**Healthcare Workflow Features:**
- Multi-disciplinary clinical team simulation
- Parallel specialist consultations
- Drug interaction checking
- Risk assessment and quality assurance
- Evidence-based clinical decision support
### 💰 Finance Examples
| File | Description | Complexity |
|------|-------------|------------|
| `advanced_graph_workflow.py` | Sophisticated investment analysis workflow | ⭐⭐⭐ Advanced |
| `comprehensive_demo.py --demo finance` | Quantitative trading strategy development | ⭐⭐⭐ Advanced |
**Finance Workflow Features:**
- Multi-source market data analysis
- Parallel quantitative analysis (Technical, Fundamental, Sentiment)
- Risk management and portfolio optimization
- Strategy backtesting and validation
- Execution planning and monitoring
### 🔧 Technical Examples
| File | Description | Complexity |
|------|-------------|------------|
| `test_parallel_processing_example.py` | Comprehensive parallel processing patterns | ⭐⭐ Intermediate |
| `test_graphviz_visualization.py` | Visualization capabilities and layouts | ⭐⭐ Intermediate |
| `test_graph_workflow_caching.py` | Performance optimization and caching | ⭐⭐ Intermediate |
| `test_enhanced_json_export.py` | Serialization and persistence features | ⭐⭐ Intermediate |
| `test_graphworlfolw_validation.py` | Workflow validation and error handling | ⭐⭐ Intermediate |
## 🎯 Key Features Demonstrated
### ⚡ Parallel Processing Patterns
- **Fan-out**: One agent distributes to multiple agents
- **Fan-in**: Multiple agents converge to one agent
- **Parallel chains**: Many-to-many mesh processing
- **Complex hybrid**: Sophisticated multi-stage patterns
### 🚀 Performance Optimization
- **Intelligent Compilation**: Pre-computed execution layers
- **Advanced Caching**: Persistent state across runs
- **Worker Pool Optimization**: CPU-optimized parallel execution
- **Memory Management**: Efficient resource utilization
### 🎨 Visualization & Monitoring
- **Professional Graphviz Diagrams**: Multiple layouts and formats
- **Real-time Performance Metrics**: Execution monitoring
- **Workflow Validation**: Comprehensive error checking
- **Rich Logging**: Detailed execution insights
### 💾 Enterprise Features
- **JSON Serialization**: Complete workflow persistence
- **Runtime State Management**: Compilation caching
- **Error Handling**: Robust failure recovery
- **Scalability**: Support for large agent networks
## 🏃‍♂️ Running Examples
### Basic Usage
```python
from swarms import Agent
from swarms.structs.graph_workflow import GraphWorkflow
# Create agents
agent1 = Agent(agent_name="Researcher", model_name="gpt-4o-mini", max_loops=1)
agent2 = Agent(agent_name="Writer", model_name="gpt-4o-mini", max_loops=1)
# Create workflow
workflow = GraphWorkflow(name="SimpleWorkflow", auto_compile=True)
workflow.add_node(agent1)
workflow.add_node(agent2)
workflow.add_edge("Researcher", "Writer")
# Execute
results = workflow.run(task="Research and write about AI trends")
```
### Parallel Processing
```python
# Fan-out pattern: One agent to multiple agents
workflow.add_edges_from_source("DataCollector", ["AnalystA", "AnalystB", "AnalystC"])
# Fan-in pattern: Multiple agents to one agent
workflow.add_edges_to_target(["SpecialistX", "SpecialistY"], "Synthesizer")
# Parallel chain: Many-to-many processing
workflow.add_parallel_chain(
sources=["DataA", "DataB"],
targets=["ProcessorX", "ProcessorY"]
)
```
### Performance Monitoring
```python
# Get compilation status
status = workflow.get_compilation_status()
print(f"Compiled: {status['is_compiled']}")
print(f"Workers: {status['max_workers']}")
# Monitor execution
import time
start = time.time()
results = workflow.run(task="Analyze market conditions")
print(f"Execution time: {time.time() - start:.2f}s")
print(f"Throughput: {len(results)/(time.time() - start):.1f} agents/second")
```
## 🔬 Use Case Examples
### 📊 Enterprise Data Processing
```python
# Multi-stage data pipeline
workflow.add_parallel_chain(
["APIIngester", "DatabaseExtractor", "FileProcessor"],
["DataValidator", "DataTransformer", "DataEnricher"]
)
workflow.add_edges_to_target(
["DataValidator", "DataTransformer", "DataEnricher"],
"ReportGenerator"
)
```
### 🏥 Clinical Decision Support
```python
# Multi-specialist consultation
workflow.add_edges_from_source("PatientDataCollector", [
"PrimaryCarePhysician", "Cardiologist", "Pharmacist"
])
workflow.add_edges_to_target([
"PrimaryCarePhysician", "Cardiologist", "Pharmacist"
], "CaseManager")
```
### 💼 Investment Analysis
```python
# Parallel financial analysis
workflow.add_parallel_chain(
["MarketDataCollector", "FundamentalDataCollector"],
["TechnicalAnalyst", "FundamentalAnalyst", "SentimentAnalyst"]
)
workflow.add_edges_to_target([
"TechnicalAnalyst", "FundamentalAnalyst", "SentimentAnalyst"
], "PortfolioManager")
```
## 🎨 Visualization Examples
### Generate Workflow Diagrams
```python
# Professional Graphviz visualization
workflow.visualize(
format="png", # png, svg, pdf, dot
engine="dot", # dot, neato, fdp, sfdp, circo
show_summary=True, # Display parallel processing stats
view=True # Open diagram automatically
)
# Text-based visualization (always available)
workflow.visualize_simple()
```
### Example Output
```
📊 GRAPHVIZ WORKFLOW VISUALIZATION
====================================
📁 Saved to: MyWorkflow_visualization.png
🤖 Total Agents: 8
🔗 Total Connections: 12
📚 Execution Layers: 4
⚡ Parallel Processing Patterns:
🔀 Fan-out patterns: 2
🔀 Fan-in patterns: 1
⚡ Parallel execution nodes: 6
🎯 Parallel efficiency: 75.0%
```
## 🛠️ Troubleshooting
### Common Issues
1. **Compilation Errors**
```python
# Check for cycles in workflow
validation = workflow.validate(auto_fix=True)
if not validation['is_valid']:
print("Validation errors:", validation['errors'])
```
2. **Performance Issues**
```python
# Ensure compilation before execution
workflow.compile()
# Check worker count
status = workflow.get_compilation_status()
print(f"Workers: {status['max_workers']}")
```
3. **Memory Issues**
```python
# Clear conversation history if not needed
workflow.conversation = Conversation()
# Monitor memory usage
import psutil
process = psutil.Process()
memory_mb = process.memory_info().rss / 1024 / 1024
print(f"Memory: {memory_mb:.1f} MB")
```
### Debug Mode
```python
# Enable detailed logging
workflow = GraphWorkflow(
name="DebugWorkflow",
verbose=True, # Detailed execution logs
auto_compile=True, # Automatic optimization
)
# Validate workflow structure
validation = workflow.validate(auto_fix=True)
print("Validation result:", validation)
```
## 📚 Documentation
- **[Technical Guide](graph_workflow_technical_guide.md)**: Comprehensive 4,000-word technical documentation
- **[API Reference](../../../docs/swarms/structs/)**: Complete API documentation
- **[Multi-Agent Examples](../../multi_agent/)**: Other multi-agent examples
## 🤝 Contributing
Found a bug or want to add an example?
1. **Report Issues**: Open an issue with detailed reproduction steps
2. **Add Examples**: Submit PRs with new use case examples
3. **Improve Documentation**: Help expand the guides and tutorials
4. **Performance Optimization**: Share benchmarks and optimizations
## 🎯 Next Steps
1. **Start Learning**: Run `python quick_start_guide.py`
2. **Explore Examples**: Try healthcare and finance use cases
3. **Build Your Workflow**: Adapt examples to your domain
4. **Deploy to Production**: Use monitoring and optimization features
5. **Join Community**: Share your workflows and get help
## 🏆 Why GraphWorkflow?
GraphWorkflow is the **LangGraph killer** because it provides:
- **40-60% Better Performance**: Intelligent compilation and parallel execution
- **Enterprise Reliability**: Comprehensive error handling and monitoring
- **Superior Scalability**: Handles hundreds of agents efficiently
- **Rich Visualization**: Professional workflow diagrams
- **Production Ready**: Serialization, caching, and validation
Ready to revolutionize your multi-agent systems? Start with GraphWorkflow today! 🚀

@ -0,0 +1,909 @@
#!/usr/bin/env python3
"""
Comprehensive GraphWorkflow Demo Script
=======================================
This script demonstrates all key features of Swarms' GraphWorkflow system,
including parallel processing patterns, performance optimization, and real-world use cases.
Usage:
python comprehensive_demo.py [--demo healthcare|finance|enterprise|all]
Requirements:
uv pip install swarms
uv pip install graphviz # Optional for visualization
"""
import argparse
import time
from swarms import Agent
from swarms.structs.graph_workflow import GraphWorkflow
def create_basic_workflow_demo():
"""Demonstrate basic GraphWorkflow functionality."""
print("\n" + "=" * 60)
print("🚀 BASIC GRAPHWORKFLOW DEMONSTRATION")
print("=" * 60)
# Create simple agents
data_collector = Agent(
agent_name="DataCollector",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a data collection specialist. Gather and organize relevant information for analysis.",
verbose=False,
)
data_analyzer = Agent(
agent_name="DataAnalyzer",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a data analysis expert. Analyze the collected data and extract key insights.",
verbose=False,
)
report_generator = Agent(
agent_name="ReportGenerator",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a report generation specialist. Create comprehensive reports from analysis results.",
verbose=False,
)
# Create workflow
workflow = GraphWorkflow(
name="BasicWorkflowDemo",
description="Demonstrates basic GraphWorkflow functionality",
verbose=True,
auto_compile=True,
)
# Add nodes
for agent in [data_collector, data_analyzer, report_generator]:
workflow.add_node(agent)
# Add edges (sequential flow)
workflow.add_edge("DataCollector", "DataAnalyzer")
workflow.add_edge("DataAnalyzer", "ReportGenerator")
# Set entry and exit points
workflow.set_entry_points(["DataCollector"])
workflow.set_end_points(["ReportGenerator"])
print(
f"✅ Created workflow with {len(workflow.nodes)} nodes and {len(workflow.edges)} edges"
)
# Demonstrate compilation
compilation_status = workflow.get_compilation_status()
print(f"📊 Compilation Status: {compilation_status}")
# Demonstrate simple visualization
try:
workflow.visualize_simple()
except Exception as e:
print(f"⚠️ Visualization not available: {e}")
# Run workflow
task = "Analyze the current state of artificial intelligence in healthcare, focusing on recent developments and future opportunities."
print(f"\n🔄 Executing workflow with task: {task[:100]}...")
start_time = time.time()
results = workflow.run(task=task)
execution_time = time.time() - start_time
print(f"⏱️ Execution completed in {execution_time:.2f} seconds")
# Display results
print("\n📋 Results Summary:")
for agent_name, result in results.items():
print(f"\n🤖 {agent_name}:")
print(
f" {result[:200]}{'...' if len(result) > 200 else ''}"
)
return workflow, results
def create_parallel_processing_demo():
"""Demonstrate advanced parallel processing patterns."""
print("\n" + "=" * 60)
print("⚡ PARALLEL PROCESSING DEMONSTRATION")
print("=" * 60)
# Create data sources
web_scraper = Agent(
agent_name="WebScraper",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You specialize in web data scraping and online research.",
verbose=False,
)
api_collector = Agent(
agent_name="APICollector",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You specialize in API data collection and integration.",
verbose=False,
)
database_extractor = Agent(
agent_name="DatabaseExtractor",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You specialize in database queries and data extraction.",
verbose=False,
)
# Create parallel processors
text_processor = Agent(
agent_name="TextProcessor",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You specialize in natural language processing and text analysis.",
verbose=False,
)
numeric_processor = Agent(
agent_name="NumericProcessor",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You specialize in numerical analysis and statistical processing.",
verbose=False,
)
# Create analyzers
sentiment_analyzer = Agent(
agent_name="SentimentAnalyzer",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You specialize in sentiment analysis and emotional intelligence.",
verbose=False,
)
trend_analyzer = Agent(
agent_name="TrendAnalyzer",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You specialize in trend analysis and pattern recognition.",
verbose=False,
)
# Create synthesizer
data_synthesizer = Agent(
agent_name="DataSynthesizer",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You specialize in data synthesis and comprehensive analysis integration.",
verbose=False,
)
# Create workflow
workflow = GraphWorkflow(
name="ParallelProcessingDemo",
description="Demonstrates advanced parallel processing patterns including fan-out, fan-in, and parallel chains",
verbose=True,
auto_compile=True,
)
# Add all agents
agents = [
web_scraper,
api_collector,
database_extractor,
text_processor,
numeric_processor,
sentiment_analyzer,
trend_analyzer,
data_synthesizer,
]
for agent in agents:
workflow.add_node(agent)
# Demonstrate different parallel patterns
print("🔀 Setting up parallel processing patterns...")
# Pattern 1: Fan-out from sources to processors
print(" 📤 Fan-out: Data sources → Processors")
workflow.add_edges_from_source(
"WebScraper", ["TextProcessor", "SentimentAnalyzer"]
)
workflow.add_edges_from_source(
"APICollector", ["NumericProcessor", "TrendAnalyzer"]
)
workflow.add_edges_from_source(
"DatabaseExtractor", ["TextProcessor", "NumericProcessor"]
)
# Pattern 2: Parallel chain from processors to analyzers
print(" 🔗 Parallel chain: Processors → Analyzers")
workflow.add_parallel_chain(
["TextProcessor", "NumericProcessor"],
["SentimentAnalyzer", "TrendAnalyzer"],
)
# Pattern 3: Fan-in to synthesizer
print(" 📥 Fan-in: All analyzers → Synthesizer")
workflow.add_edges_to_target(
["SentimentAnalyzer", "TrendAnalyzer"], "DataSynthesizer"
)
# Set entry and exit points
workflow.set_entry_points(
["WebScraper", "APICollector", "DatabaseExtractor"]
)
workflow.set_end_points(["DataSynthesizer"])
print(
f"✅ Created parallel workflow with {len(workflow.nodes)} nodes and {len(workflow.edges)} edges"
)
# Analyze parallel patterns
compilation_status = workflow.get_compilation_status()
print(f"📊 Compilation Status: {compilation_status}")
print(
f"🔧 Execution layers: {len(compilation_status.get('layers', []))}"
)
print(
f"⚡ Max parallel workers: {compilation_status.get('max_workers', 'N/A')}"
)
# Run parallel workflow
task = "Research and analyze the impact of quantum computing on cybersecurity, examining technical developments, market trends, and security implications."
print("\n🔄 Executing parallel workflow...")
start_time = time.time()
results = workflow.run(task=task)
execution_time = time.time() - start_time
print(
f"⏱️ Parallel execution completed in {execution_time:.2f} seconds"
)
print(
f"🚀 Throughput: {len(results)/execution_time:.1f} agents/second"
)
# Display results
print("\n📋 Parallel Processing Results:")
for agent_name, result in results.items():
print(f"\n🤖 {agent_name}:")
print(
f" {result[:150]}{'...' if len(result) > 150 else ''}"
)
return workflow, results
def create_healthcare_workflow_demo():
"""Demonstrate healthcare-focused workflow."""
print("\n" + "=" * 60)
print("🏥 HEALTHCARE WORKFLOW DEMONSTRATION")
print("=" * 60)
# Create clinical specialists
primary_care_physician = Agent(
agent_name="PrimaryCarePhysician",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are a board-certified primary care physician. Provide:
1. Initial patient assessment and history taking
2. Differential diagnosis development
3. Treatment plan coordination
4. Preventive care recommendations
Focus on comprehensive, evidence-based primary care.""",
verbose=False,
)
cardiologist = Agent(
agent_name="Cardiologist",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are a board-certified cardiologist. Provide:
1. Cardiovascular risk assessment
2. Cardiac diagnostic interpretation
3. Treatment recommendations for heart conditions
4. Cardiovascular prevention strategies
Apply evidence-based cardiology guidelines.""",
verbose=False,
)
pharmacist = Agent(
agent_name="ClinicalPharmacist",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are a clinical pharmacist specialist. Provide:
1. Medication review and optimization
2. Drug interaction analysis
3. Dosing recommendations
4. Patient counseling guidance
Ensure medication safety and efficacy.""",
verbose=False,
)
case_manager = Agent(
agent_name="CaseManager",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are a clinical case manager. Coordinate:
1. Care plan integration and implementation
2. Resource allocation and scheduling
3. Patient education and follow-up
4. Quality metrics and outcomes tracking
Ensure coordinated, patient-centered care.""",
verbose=False,
)
# Create workflow
workflow = GraphWorkflow(
name="HealthcareWorkflowDemo",
description="Clinical decision support workflow with multi-disciplinary team collaboration",
verbose=True,
auto_compile=True,
)
# Add agents
agents = [
primary_care_physician,
cardiologist,
pharmacist,
case_manager,
]
for agent in agents:
workflow.add_node(agent)
# Create clinical workflow
workflow.add_edge("PrimaryCarePhysician", "Cardiologist")
workflow.add_edge("PrimaryCarePhysician", "ClinicalPharmacist")
workflow.add_edges_to_target(
["Cardiologist", "ClinicalPharmacist"], "CaseManager"
)
workflow.set_entry_points(["PrimaryCarePhysician"])
workflow.set_end_points(["CaseManager"])
print(
f"✅ Created healthcare workflow with {len(workflow.nodes)} specialists"
)
# Clinical case
clinical_case = """
Patient: 58-year-old male executive
Chief Complaint: Chest pain and shortness of breath during exercise
History: Hypertension, family history of coronary artery disease, sedentary lifestyle
Current Medications: Lisinopril 10mg daily
Vital Signs: BP 145/92, HR 88, BMI 29.5
Recent Tests: ECG shows non-specific changes, cholesterol 245 mg/dL
Please provide comprehensive clinical assessment and care coordination.
"""
print("\n🔄 Processing clinical case...")
start_time = time.time()
results = workflow.run(task=clinical_case)
execution_time = time.time() - start_time
print(
f"⏱️ Clinical assessment completed in {execution_time:.2f} seconds"
)
# Display clinical results
print("\n🏥 Clinical Team Assessment:")
for agent_name, result in results.items():
print(f"\n👨‍⚕️ {agent_name}:")
print(
f" 📋 {result[:200]}{'...' if len(result) > 200 else ''}"
)
return workflow, results
def create_finance_workflow_demo():
"""Demonstrate finance-focused workflow."""
print("\n" + "=" * 60)
print("💰 FINANCE WORKFLOW DEMONSTRATION")
print("=" * 60)
# Create financial analysts
market_analyst = Agent(
agent_name="MarketAnalyst",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are a senior market analyst. Provide:
1. Market condition assessment and trends
2. Sector rotation and thematic analysis
3. Economic indicator interpretation
4. Market timing and positioning recommendations
Apply rigorous market analysis frameworks.""",
verbose=False,
)
equity_researcher = Agent(
agent_name="EquityResearcher",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are an equity research analyst. Provide:
1. Company fundamental analysis
2. Financial modeling and valuation
3. Competitive positioning assessment
4. Investment thesis development
Use comprehensive equity research methodologies.""",
verbose=False,
)
risk_manager = Agent(
agent_name="RiskManager",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are a risk management specialist. Provide:
1. Portfolio risk assessment and metrics
2. Stress testing and scenario analysis
3. Risk mitigation strategies
4. Regulatory compliance guidance
Apply quantitative risk management principles.""",
verbose=False,
)
portfolio_manager = Agent(
agent_name="PortfolioManager",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="""You are a senior portfolio manager. Provide:
1. Investment decision synthesis
2. Portfolio construction and allocation
3. Performance attribution analysis
4. Client communication and reporting
Integrate all analysis into actionable investment decisions.""",
verbose=False,
)
# Create workflow
workflow = GraphWorkflow(
name="FinanceWorkflowDemo",
description="Investment decision workflow with multi-disciplinary financial analysis",
verbose=True,
auto_compile=True,
)
# Add agents
agents = [
market_analyst,
equity_researcher,
risk_manager,
portfolio_manager,
]
for agent in agents:
workflow.add_node(agent)
# Create financial workflow (parallel analysis feeding portfolio decisions)
workflow.add_edges_from_source(
"MarketAnalyst", ["EquityResearcher", "RiskManager"]
)
workflow.add_edges_to_target(
["EquityResearcher", "RiskManager"], "PortfolioManager"
)
workflow.set_entry_points(["MarketAnalyst"])
workflow.set_end_points(["PortfolioManager"])
print(
f"✅ Created finance workflow with {len(workflow.nodes)} analysts"
)
# Investment analysis task
investment_scenario = """
Investment Analysis Request: Technology Sector Allocation
Market Context:
- Interest rates: 5.25% federal funds rate
- Inflation: 3.2% CPI year-over-year
- Technology sector: -8% YTD performance
- AI theme: High investor interest and valuation concerns
Portfolio Context:
- Current tech allocation: 15% (target 20-25%)
- Risk budget: 12% tracking error limit
- Investment horizon: 3-5 years
- Client risk tolerance: Moderate-aggressive
Please provide comprehensive investment analysis and recommendations.
"""
print("\n🔄 Analyzing investment scenario...")
start_time = time.time()
results = workflow.run(task=investment_scenario)
execution_time = time.time() - start_time
print(
f"⏱️ Investment analysis completed in {execution_time:.2f} seconds"
)
# Display financial results
print("\n💼 Investment Team Analysis:")
for agent_name, result in results.items():
print(f"\n📈 {agent_name}:")
print(
f" 💡 {result[:200]}{'...' if len(result) > 200 else ''}"
)
return workflow, results
def demonstrate_serialization_features():
"""Demonstrate workflow serialization and persistence."""
print("\n" + "=" * 60)
print("💾 SERIALIZATION & PERSISTENCE DEMONSTRATION")
print("=" * 60)
# Create a simple workflow for serialization demo
agent1 = Agent(
agent_name="SerializationTestAgent1",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are agent 1 for serialization testing.",
verbose=False,
)
agent2 = Agent(
agent_name="SerializationTestAgent2",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are agent 2 for serialization testing.",
verbose=False,
)
# Create workflow
workflow = GraphWorkflow(
name="SerializationTestWorkflow",
description="Workflow for testing serialization capabilities",
verbose=True,
auto_compile=True,
)
workflow.add_node(agent1)
workflow.add_node(agent2)
workflow.add_edge(
"SerializationTestAgent1", "SerializationTestAgent2"
)
print("✅ Created test workflow for serialization")
# Test JSON serialization
print("\n📄 Testing JSON serialization...")
try:
json_data = workflow.to_json(
include_conversation=True, include_runtime_state=True
)
print(
f"✅ JSON serialization successful ({len(json_data)} characters)"
)
# Test deserialization
print("\n📥 Testing JSON deserialization...")
restored_workflow = GraphWorkflow.from_json(
json_data, restore_runtime_state=True
)
print("✅ JSON deserialization successful")
print(
f" Restored {len(restored_workflow.nodes)} nodes, {len(restored_workflow.edges)} edges"
)
except Exception as e:
print(f"❌ JSON serialization failed: {e}")
# Test file persistence
print("\n💾 Testing file persistence...")
try:
filepath = workflow.save_to_file(
"test_workflow.json",
include_conversation=True,
include_runtime_state=True,
overwrite=True,
)
print(f"✅ File save successful: {filepath}")
# Test file loading
loaded_workflow = GraphWorkflow.load_from_file(
filepath, restore_runtime_state=True
)
print("✅ File load successful")
print(
f" Loaded {len(loaded_workflow.nodes)} nodes, {len(loaded_workflow.edges)} edges"
)
# Clean up
import os
os.remove(filepath)
print("🧹 Cleaned up test file")
except Exception as e:
print(f"❌ File persistence failed: {e}")
# Test workflow validation
print("\n🔍 Testing workflow validation...")
try:
validation_result = workflow.validate(auto_fix=True)
print("✅ Validation completed")
print(f" Valid: {validation_result['is_valid']}")
print(f" Warnings: {len(validation_result['warnings'])}")
print(f" Errors: {len(validation_result['errors'])}")
if validation_result["fixed"]:
print(f" Auto-fixed: {validation_result['fixed']}")
except Exception as e:
print(f"❌ Validation failed: {e}")
def demonstrate_visualization_features():
"""Demonstrate workflow visualization capabilities."""
print("\n" + "=" * 60)
print("🎨 VISUALIZATION DEMONSTRATION")
print("=" * 60)
# Create a workflow with interesting patterns for visualization
workflow = GraphWorkflow(
name="VisualizationDemo",
description="Workflow designed to showcase visualization capabilities",
verbose=True,
auto_compile=True,
)
# Create agents with different roles
agents = []
for i, role in enumerate(
["DataSource", "Processor", "Analyzer", "Reporter"], 1
):
for j in range(2):
agent = Agent(
agent_name=f"{role}{j+1}",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt=f"You are {role} #{j+1}",
verbose=False,
)
agents.append(agent)
workflow.add_node(agent)
# Create interesting edge patterns
# Fan-out from data sources
workflow.add_edges_from_source(
"DataSource1", ["Processor1", "Processor2"]
)
workflow.add_edges_from_source(
"DataSource2", ["Processor1", "Processor2"]
)
# Parallel processing
workflow.add_parallel_chain(
["Processor1", "Processor2"], ["Analyzer1", "Analyzer2"]
)
# Fan-in to reporters
workflow.add_edges_to_target(
["Analyzer1", "Analyzer2"], "Reporter1"
)
workflow.add_edge("Analyzer1", "Reporter2")
print(
f"✅ Created visualization demo workflow with {len(workflow.nodes)} nodes"
)
# Test text visualization (always available)
print("\n📝 Testing text visualization...")
try:
text_viz = workflow.visualize_simple()
print("✅ Text visualization successful")
except Exception as e:
print(f"❌ Text visualization failed: {e}")
# Test Graphviz visualization (if available)
print("\n🎨 Testing Graphviz visualization...")
try:
viz_path = workflow.visualize(
format="png", view=False, show_summary=True
)
print(f"✅ Graphviz visualization successful: {viz_path}")
except ImportError:
print(
"⚠️ Graphviz not available - skipping advanced visualization"
)
except Exception as e:
print(f"❌ Graphviz visualization failed: {e}")
# Export workflow summary
print("\n📊 Generating workflow summary...")
try:
summary = workflow.export_summary()
print("✅ Workflow summary generated")
print(f" Structure: {summary['structure']}")
print(f" Configuration: {summary['configuration']}")
except Exception as e:
print(f"❌ Summary generation failed: {e}")
def run_performance_benchmarks():
"""Run performance benchmarks comparing different execution strategies."""
print("\n" + "=" * 60)
print("🏃‍♂️ PERFORMANCE BENCHMARKING")
print("=" * 60)
# Create workflows of different sizes
sizes = [5, 10, 15]
results = {}
for size in sizes:
print(f"\n📊 Benchmarking workflow with {size} agents...")
# Create workflow
workflow = GraphWorkflow(
name=f"BenchmarkWorkflow{size}",
description=f"Benchmark workflow with {size} agents",
verbose=False, # Reduce logging for benchmarks
auto_compile=True,
)
# Create agents
agents = []
for i in range(size):
agent = Agent(
agent_name=f"BenchmarkAgent{i+1}",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt=f"You are benchmark agent {i+1}. Provide a brief analysis.",
verbose=False,
)
agents.append(agent)
workflow.add_node(agent)
# Create simple sequential workflow
for i in range(size - 1):
workflow.add_edge(
f"BenchmarkAgent{i+1}", f"BenchmarkAgent{i+2}"
)
# Benchmark compilation
compile_start = time.time()
workflow.compile()
compile_time = time.time() - compile_start
# Benchmark execution
task = (
"Provide a brief analysis of current market conditions."
)
exec_start = time.time()
exec_results = workflow.run(task=task)
exec_time = time.time() - exec_start
# Store results
results[size] = {
"compile_time": compile_time,
"execution_time": exec_time,
"agents_executed": len(exec_results),
"throughput": (
len(exec_results) / exec_time if exec_time > 0 else 0
),
}
print(f" ⏱️ Compilation: {compile_time:.3f}s")
print(f" ⏱️ Execution: {exec_time:.3f}s")
print(
f" 🚀 Throughput: {results[size]['throughput']:.1f} agents/second"
)
# Display benchmark summary
print("\n📈 PERFORMANCE BENCHMARK SUMMARY")
print("-" * 50)
print(
f"{'Size':<6} {'Compile(s)':<12} {'Execute(s)':<12} {'Throughput':<12}"
)
print("-" * 50)
for size, metrics in results.items():
print(
f"{size:<6} {metrics['compile_time']:<12.3f} {metrics['execution_time']:<12.3f} {metrics['throughput']:<12.1f}"
)
return results
def main():
"""Main demonstration function."""
parser = argparse.ArgumentParser(
description="GraphWorkflow Comprehensive Demo"
)
parser.add_argument(
"--demo",
choices=[
"basic",
"parallel",
"healthcare",
"finance",
"serialization",
"visualization",
"performance",
"all",
],
default="all",
help="Which demonstration to run",
)
args = parser.parse_args()
print("🌟 SWARMS GRAPHWORKFLOW COMPREHENSIVE DEMONSTRATION")
print("=" * 70)
print(
"The LangGraph Killer: Advanced Multi-Agent Workflow Orchestration"
)
print("=" * 70)
demos = {
"basic": create_basic_workflow_demo,
"parallel": create_parallel_processing_demo,
"healthcare": create_healthcare_workflow_demo,
"finance": create_finance_workflow_demo,
"serialization": demonstrate_serialization_features,
"visualization": demonstrate_visualization_features,
"performance": run_performance_benchmarks,
}
if args.demo == "all":
# Run all demonstrations
for demo_name, demo_func in demos.items():
try:
print(f"\n🎯 Running {demo_name} demonstration...")
demo_func()
except Exception as e:
print(f"{demo_name} demonstration failed: {e}")
else:
# Run specific demonstration
if args.demo in demos:
try:
demos[args.demo]()
except Exception as e:
print(f"❌ Demonstration failed: {e}")
else:
print(f"❌ Unknown demonstration: {args.demo}")
print("\n" + "=" * 70)
print("🎉 DEMONSTRATION COMPLETED")
print("=" * 70)
print(
"GraphWorkflow provides enterprise-grade multi-agent orchestration"
)
print("with superior performance, reliability, and ease of use.")
print("\nNext steps:")
print("1. Try the healthcare or finance examples in your domain")
print("2. Experiment with parallel processing patterns")
print("3. Deploy to production with monitoring and optimization")
print(
"4. Explore advanced features like caching and serialization"
)
if __name__ == "__main__":
main()

@ -0,0 +1,501 @@
#!/usr/bin/env python3
"""
GraphWorkflow Quick Start Guide
==============================
This script provides a step-by-step introduction to Swarms' GraphWorkflow system.
Perfect for developers who want to get started quickly with multi-agent workflows.
Installation:
uv pip install swarms
Usage:
python quick_start_guide.py
"""
from swarms import Agent
from swarms.structs.graph_workflow import GraphWorkflow
def step_1_basic_setup():
"""Step 1: Create your first GraphWorkflow with two agents."""
print("🚀 STEP 1: Basic GraphWorkflow Setup")
print("=" * 50)
# Create two simple agents
print("📝 Creating agents...")
researcher = Agent(
agent_name="Researcher",
model_name="gpt-4o-mini", # Use cost-effective model for demo
max_loops=1,
system_prompt="You are a research specialist. Gather and analyze information on the given topic.",
verbose=False,
)
writer = Agent(
agent_name="Writer",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a content writer. Create engaging content based on research findings.",
verbose=False,
)
print(
f"✅ Created agents: {researcher.agent_name}, {writer.agent_name}"
)
# Create workflow
print("\n🔧 Creating workflow...")
workflow = GraphWorkflow(
name="MyFirstWorkflow",
description="A simple research and writing workflow",
verbose=True, # Enable detailed logging
auto_compile=True, # Automatically optimize the workflow
)
print(f"✅ Created workflow: {workflow.name}")
# Add agents to workflow
print("\n Adding agents to workflow...")
workflow.add_node(researcher)
workflow.add_node(writer)
print(f"✅ Added {len(workflow.nodes)} agents to workflow")
# Connect agents
print("\n🔗 Connecting agents...")
workflow.add_edge(
"Researcher", "Writer"
) # Researcher feeds into Writer
print(f"✅ Added {len(workflow.edges)} connections")
# Set entry and exit points
print("\n🎯 Setting entry and exit points...")
workflow.set_entry_points(["Researcher"]) # Start with Researcher
workflow.set_end_points(["Writer"]) # End with Writer
print("✅ Entry point: Researcher")
print("✅ Exit point: Writer")
return workflow
def step_2_run_workflow(workflow):
"""Step 2: Execute the workflow with a task."""
print("\n🚀 STEP 2: Running Your First Workflow")
print("=" * 50)
# Define a task
task = "Research the benefits of electric vehicles and write a compelling article about why consumers should consider making the switch."
print(f"📋 Task: {task}")
# Execute workflow
print("\n⚡ Executing workflow...")
results = workflow.run(task=task)
print(
f"✅ Workflow completed! Got results from {len(results)} agents."
)
# Display results
print("\n📊 Results:")
print("-" * 30)
for agent_name, result in results.items():
print(f"\n🤖 {agent_name}:")
print(
f"📝 {result[:300]}{'...' if len(result) > 300 else ''}"
)
return results
def step_3_parallel_processing():
"""Step 3: Create a workflow with parallel processing."""
print("\n🚀 STEP 3: Parallel Processing")
print("=" * 50)
# Create multiple specialist agents
print("👥 Creating specialist agents...")
tech_analyst = Agent(
agent_name="TechAnalyst",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a technology analyst. Focus on technical specifications, performance, and innovation.",
verbose=False,
)
market_analyst = Agent(
agent_name="MarketAnalyst",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a market analyst. Focus on market trends, pricing, and consumer adoption.",
verbose=False,
)
environmental_analyst = Agent(
agent_name="EnvironmentalAnalyst",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are an environmental analyst. Focus on sustainability, emissions, and environmental impact.",
verbose=False,
)
synthesizer = Agent(
agent_name="Synthesizer",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a synthesis expert. Combine insights from multiple analysts into a comprehensive conclusion.",
verbose=False,
)
print(f"✅ Created {4} specialist agents")
# Create parallel workflow
print("\n🔧 Creating parallel workflow...")
parallel_workflow = GraphWorkflow(
name="ParallelAnalysisWorkflow",
description="Multi-specialist analysis with parallel processing",
verbose=True,
auto_compile=True,
)
# Add all agents
agents = [
tech_analyst,
market_analyst,
environmental_analyst,
synthesizer,
]
for agent in agents:
parallel_workflow.add_node(agent)
print(f"✅ Added {len(agents)} agents to parallel workflow")
# Create parallel pattern: Multiple analysts feed into synthesizer
print("\n🔀 Setting up parallel processing pattern...")
# All analysts run in parallel, then feed into synthesizer
parallel_workflow.add_edges_to_target(
["TechAnalyst", "MarketAnalyst", "EnvironmentalAnalyst"],
"Synthesizer",
)
# Set multiple entry points (parallel execution)
parallel_workflow.set_entry_points(
["TechAnalyst", "MarketAnalyst", "EnvironmentalAnalyst"]
)
parallel_workflow.set_end_points(["Synthesizer"])
print("✅ Parallel pattern configured:")
print(" 📤 3 analysts run in parallel")
print(" 📥 Results feed into synthesizer")
# Execute parallel workflow
task = "Analyze the future of renewable energy technology from technical, market, and environmental perspectives."
print("\n⚡ Executing parallel workflow...")
print(f"📋 Task: {task}")
results = parallel_workflow.run(task=task)
print(
f"✅ Parallel execution completed! {len(results)} agents processed."
)
# Display results
print("\n📊 Parallel Analysis Results:")
print("-" * 40)
for agent_name, result in results.items():
print(f"\n🤖 {agent_name}:")
print(
f"📝 {result[:250]}{'...' if len(result) > 250 else ''}"
)
return parallel_workflow, results
def step_4_advanced_patterns():
"""Step 4: Demonstrate advanced workflow patterns."""
print("\n🚀 STEP 4: Advanced Workflow Patterns")
print("=" * 50)
# Create agents for different patterns
data_collector = Agent(
agent_name="DataCollector",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You collect and organize data from various sources.",
verbose=False,
)
processor_a = Agent(
agent_name="ProcessorA",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are processor A specializing in quantitative analysis.",
verbose=False,
)
processor_b = Agent(
agent_name="ProcessorB",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are processor B specializing in qualitative analysis.",
verbose=False,
)
validator_x = Agent(
agent_name="ValidatorX",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are validator X focusing on accuracy and consistency.",
verbose=False,
)
validator_y = Agent(
agent_name="ValidatorY",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are validator Y focusing on completeness and quality.",
verbose=False,
)
final_reporter = Agent(
agent_name="FinalReporter",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You create final comprehensive reports from all validated analyses.",
verbose=False,
)
# Create advanced workflow
advanced_workflow = GraphWorkflow(
name="AdvancedPatternsWorkflow",
description="Demonstrates fan-out, parallel chains, and fan-in patterns",
verbose=True,
auto_compile=True,
)
# Add all agents
agents = [
data_collector,
processor_a,
processor_b,
validator_x,
validator_y,
final_reporter,
]
for agent in agents:
advanced_workflow.add_node(agent)
print(f"✅ Created advanced workflow with {len(agents)} agents")
# Demonstrate different patterns
print("\n🎯 Setting up advanced patterns...")
# Pattern 1: Fan-out (one-to-many)
print(" 📤 Fan-out: DataCollector → Multiple Processors")
advanced_workflow.add_edges_from_source(
"DataCollector", ["ProcessorA", "ProcessorB"]
)
# Pattern 2: Parallel chain (many-to-many)
print(" 🔗 Parallel chain: Processors → Validators")
advanced_workflow.add_parallel_chain(
["ProcessorA", "ProcessorB"], ["ValidatorX", "ValidatorY"]
)
# Pattern 3: Fan-in (many-to-one)
print(" 📥 Fan-in: Validators → Final Reporter")
advanced_workflow.add_edges_to_target(
["ValidatorX", "ValidatorY"], "FinalReporter"
)
# Set workflow boundaries
advanced_workflow.set_entry_points(["DataCollector"])
advanced_workflow.set_end_points(["FinalReporter"])
print("✅ Advanced patterns configured")
# Show workflow structure
print("\n📊 Workflow structure:")
try:
advanced_workflow.visualize_simple()
except:
print(" (Text visualization not available)")
# Execute advanced workflow
task = "Analyze the impact of artificial intelligence on job markets, including both opportunities and challenges."
print("\n⚡ Executing advanced workflow...")
results = advanced_workflow.run(task=task)
print(
f"✅ Advanced execution completed! {len(results)} agents processed."
)
return advanced_workflow, results
def step_5_workflow_features():
"""Step 5: Explore additional workflow features."""
print("\n🚀 STEP 5: Additional Workflow Features")
print("=" * 50)
# Create a simple workflow for feature demonstration
agent1 = Agent(
agent_name="FeatureTestAgent1",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a feature testing agent.",
verbose=False,
)
agent2 = Agent(
agent_name="FeatureTestAgent2",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are another feature testing agent.",
verbose=False,
)
workflow = GraphWorkflow(
name="FeatureTestWorkflow",
description="Workflow for testing additional features",
verbose=True,
auto_compile=True,
)
workflow.add_node(agent1)
workflow.add_node(agent2)
workflow.add_edge("FeatureTestAgent1", "FeatureTestAgent2")
# Feature 1: Compilation status
print("🔍 Feature 1: Compilation Status")
status = workflow.get_compilation_status()
print(f" ✅ Compiled: {status['is_compiled']}")
print(f" 📊 Layers: {status.get('cached_layers_count', 'N/A')}")
print(f" ⚡ Workers: {status.get('max_workers', 'N/A')}")
# Feature 2: Workflow validation
print("\n🔍 Feature 2: Workflow Validation")
validation = workflow.validate(auto_fix=True)
print(f" ✅ Valid: {validation['is_valid']}")
print(f" ⚠️ Warnings: {len(validation['warnings'])}")
print(f" ❌ Errors: {len(validation['errors'])}")
# Feature 3: JSON serialization
print("\n🔍 Feature 3: JSON Serialization")
try:
json_data = workflow.to_json()
print(
f" ✅ JSON export successful ({len(json_data)} characters)"
)
# Test deserialization
restored = GraphWorkflow.from_json(json_data)
print(
f" ✅ JSON import successful ({len(restored.nodes)} nodes)"
)
except Exception as e:
print(f" ❌ JSON serialization failed: {e}")
# Feature 4: Workflow summary
print("\n🔍 Feature 4: Workflow Summary")
try:
summary = workflow.export_summary()
print(
f" 📊 Workflow info: {summary['workflow_info']['name']}"
)
print(f" 📈 Structure: {summary['structure']}")
print(f" ⚙️ Configuration: {summary['configuration']}")
except Exception as e:
print(f" ❌ Summary generation failed: {e}")
# Feature 5: Performance monitoring
print("\n🔍 Feature 5: Performance Monitoring")
import time
task = "Perform a simple test task for feature demonstration."
start_time = time.time()
results = workflow.run(task=task)
execution_time = time.time() - start_time
print(f" ⏱️ Execution time: {execution_time:.3f} seconds")
print(
f" 🚀 Throughput: {len(results)/execution_time:.1f} agents/second"
)
print(f" 📊 Results: {len(results)} agents completed")
return workflow
def main():
"""Main quick start guide function."""
print("🌟 GRAPHWORKFLOW QUICK START GUIDE")
print("=" * 60)
print("Learn GraphWorkflow in 5 easy steps!")
print("=" * 60)
try:
# Step 1: Basic setup
workflow = step_1_basic_setup()
# Step 2: Run workflow
step_2_run_workflow(workflow)
# Step 3: Parallel processing
step_3_parallel_processing()
# Step 4: Advanced patterns
step_4_advanced_patterns()
# Step 5: Additional features
step_5_workflow_features()
# Conclusion
print("\n🎉 QUICK START GUIDE COMPLETED!")
print("=" * 50)
print("You've learned how to:")
print("✅ Create basic workflows with agents")
print("✅ Execute workflows with tasks")
print("✅ Set up parallel processing")
print("✅ Use advanced workflow patterns")
print("✅ Monitor and optimize performance")
print("\n🚀 Next Steps:")
print(
"1. Try the comprehensive demo: python comprehensive_demo.py"
)
print("2. Read the full technical guide")
print("3. Implement workflows for your specific use case")
print("4. Explore healthcare and finance examples")
print("5. Deploy to production with monitoring")
except Exception as e:
print(f"\n❌ Quick start guide failed: {e}")
print("Please check your installation and try again.")
if __name__ == "__main__":
main()

@ -0,0 +1,480 @@
#!/usr/bin/env python3
"""
GraphWorkflow Setup and Test Script
==================================
This script helps you set up and test your GraphWorkflow environment.
It checks dependencies, validates the installation, and runs basic tests.
Usage:
python setup_and_test.py [--install-deps] [--run-tests] [--check-only]
"""
import sys
import subprocess
import importlib
import argparse
from typing import Dict, List, Tuple
def check_python_version() -> bool:
"""Check if Python version is compatible."""
print("🐍 Checking Python version...")
version = sys.version_info
if version.major >= 3 and version.minor >= 8:
print(
f"✅ Python {version.major}.{version.minor}.{version.micro} is compatible"
)
return True
else:
print(
f"❌ Python {version.major}.{version.minor}.{version.micro} is too old"
)
print(" GraphWorkflow requires Python 3.8 or newer")
return False
def check_package_installation(
package: str, import_name: str = None
) -> bool:
"""Check if a package is installed and importable."""
import_name = import_name or package
try:
importlib.import_module(import_name)
print(f"{package} is installed and importable")
return True
except ImportError:
print(f"{package} is not installed or not importable")
return False
def install_package(package: str) -> bool:
"""Install a package using pip."""
try:
print(f"📦 Installing {package}...")
result = subprocess.run(
[sys.executable, "-m", "pip", "install", package],
capture_output=True,
text=True,
check=True,
)
print(f"{package} installed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Failed to install {package}")
print(f" Error: {e.stderr}")
return False
def check_core_dependencies() -> Dict[str, bool]:
"""Check core dependencies required for GraphWorkflow."""
print("\n🔍 Checking core dependencies...")
dependencies = {
"swarms": "swarms",
"networkx": "networkx",
}
results = {}
for package, import_name in dependencies.items():
results[package] = check_package_installation(
package, import_name
)
return results
def check_optional_dependencies() -> Dict[str, bool]:
"""Check optional dependencies for enhanced features."""
print("\n🔍 Checking optional dependencies...")
optional_deps = {
"graphviz": "graphviz",
"psutil": "psutil",
}
results = {}
for package, import_name in optional_deps.items():
results[package] = check_package_installation(
package, import_name
)
return results
def test_basic_import() -> bool:
"""Test basic GraphWorkflow import."""
print("\n🧪 Testing basic GraphWorkflow import...")
try:
from swarms.structs.graph_workflow import GraphWorkflow
print("✅ GraphWorkflow imported successfully")
return True
except ImportError as e:
print(f"❌ Failed to import GraphWorkflow: {e}")
return False
def test_agent_import() -> bool:
"""Test Agent import."""
print("\n🧪 Testing Agent import...")
try:
from swarms import Agent
print("✅ Agent imported successfully")
return True
except ImportError as e:
print(f"❌ Failed to import Agent: {e}")
return False
def test_basic_workflow_creation() -> bool:
"""Test basic workflow creation."""
print("\n🧪 Testing basic workflow creation...")
try:
from swarms import Agent
from swarms.structs.graph_workflow import GraphWorkflow
# Create a simple agent
agent = Agent(
agent_name="TestAgent",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a test agent.",
verbose=False,
)
# Create workflow
workflow = GraphWorkflow(
name="TestWorkflow",
description="A test workflow",
verbose=False,
auto_compile=True,
)
# Add agent
workflow.add_node(agent)
print("✅ Basic workflow creation successful")
print(f" Created workflow with {len(workflow.nodes)} nodes")
return True
except Exception as e:
print(f"❌ Basic workflow creation failed: {e}")
return False
def test_workflow_compilation() -> bool:
"""Test workflow compilation."""
print("\n🧪 Testing workflow compilation...")
try:
from swarms import Agent
from swarms.structs.graph_workflow import GraphWorkflow
# Create agents
agent1 = Agent(
agent_name="Agent1",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are agent 1.",
verbose=False,
)
agent2 = Agent(
agent_name="Agent2",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are agent 2.",
verbose=False,
)
# Create workflow
workflow = GraphWorkflow(
name="CompilationTestWorkflow",
description="A workflow for testing compilation",
verbose=False,
auto_compile=False, # Manual compilation
)
# Add agents and edges
workflow.add_node(agent1)
workflow.add_node(agent2)
workflow.add_edge("Agent1", "Agent2")
# Test compilation
workflow.compile()
# Check compilation status
status = workflow.get_compilation_status()
if status["is_compiled"]:
print("✅ Workflow compilation successful")
print(
f" Layers: {status.get('cached_layers_count', 'N/A')}"
)
print(f" Workers: {status.get('max_workers', 'N/A')}")
return True
else:
print("❌ Workflow compilation failed - not compiled")
return False
except Exception as e:
print(f"❌ Workflow compilation failed: {e}")
return False
def test_workflow_validation() -> bool:
"""Test workflow validation."""
print("\n🧪 Testing workflow validation...")
try:
from swarms import Agent
from swarms.structs.graph_workflow import GraphWorkflow
# Create a simple workflow
agent = Agent(
agent_name="ValidationTestAgent",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a validation test agent.",
verbose=False,
)
workflow = GraphWorkflow(
name="ValidationTestWorkflow",
description="A workflow for testing validation",
verbose=False,
auto_compile=True,
)
workflow.add_node(agent)
# Test validation
validation = workflow.validate(auto_fix=True)
print("✅ Workflow validation successful")
print(f" Valid: {validation['is_valid']}")
print(f" Warnings: {len(validation['warnings'])}")
print(f" Errors: {len(validation['errors'])}")
return True
except Exception as e:
print(f"❌ Workflow validation failed: {e}")
return False
def test_serialization() -> bool:
"""Test workflow serialization."""
print("\n🧪 Testing workflow serialization...")
try:
from swarms import Agent
from swarms.structs.graph_workflow import GraphWorkflow
# Create a simple workflow
agent = Agent(
agent_name="SerializationTestAgent",
model_name="gpt-4o-mini",
max_loops=1,
system_prompt="You are a serialization test agent.",
verbose=False,
)
workflow = GraphWorkflow(
name="SerializationTestWorkflow",
description="A workflow for testing serialization",
verbose=False,
auto_compile=True,
)
workflow.add_node(agent)
# Test JSON serialization
json_data = workflow.to_json()
if len(json_data) > 0:
print("✅ JSON serialization successful")
print(f" JSON size: {len(json_data)} characters")
# Test deserialization
restored = GraphWorkflow.from_json(json_data)
print("✅ JSON deserialization successful")
print(f" Restored nodes: {len(restored.nodes)}")
return True
else:
print("❌ JSON serialization failed - empty result")
return False
except Exception as e:
print(f"❌ Serialization test failed: {e}")
return False
def run_all_tests() -> List[Tuple[str, bool]]:
"""Run all tests and return results."""
print("\n🚀 Running GraphWorkflow Tests")
print("=" * 50)
tests = [
("Basic Import", test_basic_import),
("Agent Import", test_agent_import),
("Basic Workflow Creation", test_basic_workflow_creation),
("Workflow Compilation", test_workflow_compilation),
("Workflow Validation", test_workflow_validation),
("Serialization", test_serialization),
]
results = []
for test_name, test_func in tests:
try:
result = test_func()
results.append((test_name, result))
except Exception as e:
print(f"{test_name} failed with exception: {e}")
results.append((test_name, False))
return results
def print_test_summary(results: List[Tuple[str, bool]]):
"""Print test summary."""
print("\n📊 TEST SUMMARY")
print("=" * 30)
passed = sum(1 for _, result in results if result)
total = len(results)
for test_name, result in results:
status = "✅ PASS" if result else "❌ FAIL"
print(f"{status} {test_name}")
print("-" * 30)
print(f"Passed: {passed}/{total} ({passed/total*100:.1f}%)")
if passed == total:
print("\n🎉 All tests passed! GraphWorkflow is ready to use.")
else:
print(
f"\n⚠️ {total-passed} tests failed. Please check the output above."
)
print(
" Consider running with --install-deps to install missing packages."
)
def main():
"""Main setup and test function."""
parser = argparse.ArgumentParser(
description="GraphWorkflow Setup and Test"
)
parser.add_argument(
"--install-deps",
action="store_true",
help="Install missing dependencies",
)
parser.add_argument(
"--run-tests",
action="store_true",
help="Run functionality tests",
)
parser.add_argument(
"--check-only",
action="store_true",
help="Only check dependencies, don't install",
)
args = parser.parse_args()
# If no arguments, run everything
if not any([args.install_deps, args.run_tests, args.check_only]):
args.install_deps = True
args.run_tests = True
print("🌟 GRAPHWORKFLOW SETUP AND TEST")
print("=" * 50)
# Check Python version
if not check_python_version():
print(
"\n❌ Python version incompatible. Please upgrade Python."
)
sys.exit(1)
# Check dependencies
core_deps = check_core_dependencies()
optional_deps = check_optional_dependencies()
# Install missing dependencies if requested
if args.install_deps and not args.check_only:
print("\n📦 Installing missing dependencies...")
# Install core dependencies
for package, installed in core_deps.items():
if not installed:
if not install_package(package):
print(
f"\n❌ Failed to install core dependency: {package}"
)
sys.exit(1)
# Install optional dependencies
for package, installed in optional_deps.items():
if not installed:
print(
f"\n📦 Installing optional dependency: {package}"
)
install_package(
package
) # Don't fail on optional deps
# Run tests if requested
if args.run_tests:
results = run_all_tests()
print_test_summary(results)
# Exit with error code if tests failed
failed_tests = sum(1 for _, result in results if not result)
if failed_tests > 0:
sys.exit(1)
elif args.check_only:
# Summary for check-only mode
core_missing = sum(
1 for installed in core_deps.values() if not installed
)
optional_missing = sum(
1 for installed in optional_deps.values() if not installed
)
print("\n📊 DEPENDENCY CHECK SUMMARY")
print("=" * 40)
print(f"Core dependencies missing: {core_missing}")
print(f"Optional dependencies missing: {optional_missing}")
if core_missing > 0:
print(
"\n⚠️ Missing core dependencies. Run with --install-deps to install."
)
sys.exit(1)
else:
print("\n✅ All core dependencies satisfied!")
print("\n🎯 Next Steps:")
print("1. Run the quick start guide: python quick_start_guide.py")
print(
"2. Try the comprehensive demo: python comprehensive_demo.py"
)
print("3. Explore healthcare and finance examples")
print("4. Read the technical documentation")
if __name__ == "__main__":
main()

@ -0,0 +1,273 @@
# Smart Database Swarm
A fully autonomous database management system powered by hierarchical multi-agent workflow using the Swarms framework.
## Overview
The Smart Database Swarm is an intelligent database management system that uses specialized AI agents to handle different aspects of database operations. The system follows a hierarchical architecture where a Database Director coordinates specialized worker agents to execute complex database tasks.
## Architecture
### Hierarchical Structure
```
Database Director (Coordinator)
├── Database Creator (Creates databases)
├── Table Manager (Manages table schemas)
├── Data Operations (Handles data insertion/updates)
└── Query Specialist (Executes queries and retrieval)
```
### Agent Specializations
1. **Database Director**: Orchestrates all database operations and coordinates specialist agents
2. **Database Creator**: Specializes in creating and initializing databases
3. **Table Manager**: Expert in table creation, schema design, and structure management
4. **Data Operations**: Handles data insertion, updates, and manipulation
5. **Query Specialist**: Manages database queries, data retrieval, and optimization
## Features
- **Autonomous Database Management**: Complete database lifecycle management
- **Intelligent Task Distribution**: Automatic assignment of tasks to appropriate specialists
- **Schema Validation**: Ensures proper table structures and data integrity
- **Security**: Built-in SQL injection prevention and query validation
- **Performance Optimization**: Query optimization and efficient data operations
- **Comprehensive Error Handling**: Robust error management and reporting
- **Multi-format Data Support**: JSON-based data insertion and flexible query parameters
## Database Tools
### Core Functions
1. **`create_database(database_name, database_path)`**: Creates new SQLite databases
2. **`create_table(database_path, table_name, schema)`**: Creates tables with specified schemas
3. **`insert_data(database_path, table_name, data)`**: Inserts data into tables
4. **`query_database(database_path, query, params)`**: Executes SELECT queries
5. **`update_table_data(database_path, table_name, update_data, where_clause)`**: Updates existing data
6. **`get_database_schema(database_path)`**: Retrieves comprehensive schema information
## Usage Examples
### Basic Usage
```python
from smart_database_swarm import smart_database_swarm
# Simple database creation and setup
task = """
Create a user management database:
1. Create database 'user_system'
2. Create users table with id, username, email, created_at
3. Insert 5 sample users
4. Query all users ordered by creation date
"""
result = smart_database_swarm.run(task=task)
print(result)
```
### E-commerce System
```python
# Complex e-commerce database system
ecommerce_task = """
Create a comprehensive e-commerce database system:
1. Create database 'ecommerce_store'
2. Create tables:
- customers (id, name, email, phone, address, created_at)
- products (id, name, description, price, category, stock, created_at)
- orders (id, customer_id, order_date, total_amount, status)
- order_items (id, order_id, product_id, quantity, unit_price)
3. Insert sample data:
- 10 customers with realistic information
- 20 products across different categories
- 15 orders with multiple items each
4. Execute analytical queries:
- Top selling products by quantity
- Customer lifetime value analysis
- Monthly sales trends
- Inventory levels by category
"""
result = smart_database_swarm.run(task=ecommerce_task)
```
### Data Analysis and Reporting
```python
# Advanced data analysis
analysis_task = """
Analyze the existing databases and provide insights:
1. Get schema information for all databases
2. Generate data quality reports
3. Identify optimization opportunities
4. Create performance metrics dashboard
5. Suggest database improvements
Query patterns:
- Customer segmentation analysis
- Product performance metrics
- Order fulfillment statistics
- Revenue analysis by time periods
"""
result = smart_database_swarm.run(task=analysis_task)
```
## Data Formats
### Table Schema Definition
```python
# Column definitions with types and constraints
schema = "id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, email TEXT UNIQUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP"
```
### Data Insertion Formats
#### Format 1: List of Dictionaries
```json
[
{"name": "John Doe", "email": "john@example.com"},
{"name": "Jane Smith", "email": "jane@example.com"}
]
```
#### Format 2: Columns and Values
```json
{
"columns": ["name", "email"],
"values": [
["John Doe", "john@example.com"],
["Jane Smith", "jane@example.com"]
]
}
```
### Update Operations
```json
{
"salary": 75000,
"department": "Engineering",
"last_updated": "2024-01-15"
}
```
## Advanced Features
### Security
- **SQL Injection Prevention**: Parameterized queries and input validation
- **Query Validation**: Only SELECT queries allowed for query operations
- **Input Sanitization**: Automatic cleaning and validation of inputs
### Performance
- **Connection Management**: Efficient database connection handling
- **Query Optimization**: Intelligent query planning and execution
- **Batch Operations**: Support for bulk data operations
### Error Handling
- **Comprehensive Error Messages**: Detailed error reporting and solutions
- **Graceful Degradation**: System continues operating despite individual failures
- **Transaction Safety**: Atomic operations with rollback capabilities
## Best Practices
### Database Design
1. **Use Proper Data Types**: Choose appropriate SQL data types for your data
2. **Implement Constraints**: Use PRIMARY KEY, FOREIGN KEY, and CHECK constraints
3. **Normalize Data**: Follow database normalization principles
4. **Index Strategy**: Create indexes for frequently queried columns
### Agent Coordination
1. **Clear Task Definitions**: Provide specific, actionable task descriptions
2. **Sequential Operations**: Allow agents to complete dependencies before next steps
3. **Comprehensive Requirements**: Include all necessary details in task descriptions
4. **Result Validation**: Review agent outputs for completeness and accuracy
### Data Operations
1. **Backup Before Updates**: Always backup data before major modifications
2. **Test Queries**: Validate queries on sample data before production execution
3. **Monitor Performance**: Track query execution times and optimize as needed
4. **Validate Data**: Ensure data integrity through proper validation
## File Structure
```
examples/guides/smart_database/
├── smart_database_swarm.py # Main implementation
├── README.md # This documentation
└── databases/ # Generated databases (auto-created)
```
## Dependencies
- `swarms`: Core framework for multi-agent systems
- `sqlite3`: Database operations (built-in Python)
- `json`: Data serialization (built-in Python)
- `pathlib`: File path operations (built-in Python)
- `loguru`: Minimal logging functionality
## Running the System
```bash
# Navigate to the smart_database directory
cd examples/guides/smart_database
# Run the demonstration
python smart_database_swarm.py
# The system will create databases in ./databases/ directory
# Check the generated databases and results
```
## Expected Output
The system will create:
1. **Databases**: SQLite database files in `./databases/` directory
2. **Detailed Results**: JSON-formatted operation results
3. **Agent Coordination**: Logs showing how tasks are distributed
4. **Performance Metrics**: Execution times and success statistics
## Troubleshooting
### Common Issues
1. **Database Not Found**: Ensure database path is correct and accessible
2. **Schema Errors**: Verify SQL syntax in table creation statements
3. **Data Format Issues**: Check JSON formatting for data insertion
4. **Permission Errors**: Ensure write permissions for database directory
### Debug Mode
Enable verbose logging to see detailed agent interactions:
```python
smart_database_swarm.verbose = True
result = smart_database_swarm.run(task=your_task)
```
## Contributing
To extend the Smart Database Swarm:
1. **Add New Tools**: Create additional database operation functions
2. **Enhance Agents**: Improve agent prompts and capabilities
3. **Add Database Types**: Support for PostgreSQL, MySQL, etc.
4. **Performance Optimization**: Implement caching and connection pooling
## License
This project is part of the Swarms framework and follows the same licensing terms.

@ -1,5 +1,5 @@
from swarms.structs.agent import Agent
from swarms.structs.council_judge import CouncilAsAJudge
from swarms.structs.council_as_judge import CouncilAsAJudge
# ========== USAGE EXAMPLE ==========

@ -46,7 +46,7 @@ technical_analyst = Agent(
)
# Create list of agents
agents = [market_researcher, financial_analyst, technical_analyst]
agents = [market_researcher, financial_analyst]
# Initialize the concurrent workflow
workflow = ConcurrentWorkflow(

@ -8,7 +8,7 @@ from loguru import logger
from tqdm import tqdm
from swarms.structs.agent import Agent
from swarms.structs.council_judge import CouncilAsAJudge
from swarms.structs.council_as_judge import CouncilAsAJudge
# Dataset configurations
DATASET_CONFIGS = {

@ -1,5 +1,5 @@
from swarms.structs.agent import Agent
from swarms.structs.council_judge import CouncilAsAJudge
from swarms.structs.council_as_judge import CouncilAsAJudge
if __name__ == "__main__":

@ -1,5 +1,5 @@
from swarms.structs.agent import Agent
from swarms.structs.council_judge import CouncilAsAJudge
from swarms.structs.council_as_judge import CouncilAsAJudge
if __name__ == "__main__":

@ -5,7 +5,7 @@ This example shows how to use the CouncilAsAJudge to evaluate various types
of responses including technical explanations, creative writing, and problem-solving.
"""
from swarms.structs.council_judge import CouncilAsAJudge
from swarms.structs.council_as_judge import CouncilAsAJudge
def evaluate_technical_response():

@ -5,7 +5,7 @@ This example shows how to use the CouncilAsAJudge with different output types,
custom worker configurations, and focused evaluation scenarios.
"""
from swarms.structs.council_judge import CouncilAsAJudge
from swarms.structs.council_as_judge import CouncilAsAJudge
def evaluate_with_final_output():

@ -6,7 +6,7 @@ across multiple dimensions including accuracy, helpfulness, harmlessness,
coherence, conciseness, and instruction adherence.
"""
from swarms.structs.council_judge import CouncilAsAJudge
from swarms.structs.council_as_judge import CouncilAsAJudge
def main():

@ -0,0 +1,51 @@
#!/usr/bin/env python3
"""
Basic Graph Workflow Example
A minimal example showing how to use GraphWorkflow with backend selection.
"""
from swarms.structs.graph_workflow import GraphWorkflow
from swarms.structs.agent import Agent
agent_one = Agent(agent_name="research_agent", model="gpt-4o-mini")
agent_two = Agent(
agent_name="research_agent_two", model="gpt-4o-mini"
)
agent_three = Agent(
agent_name="research_agent_three", model="gpt-4o-mini"
)
def main():
"""
Run a basic graph workflow example without print statements.
"""
# Create agents
# Create workflow with backend selection
workflow = GraphWorkflow(
name="Basic Example",
verbose=True,
)
# Add agents to workflow
workflow.add_node(agent_one)
workflow.add_node(agent_two)
workflow.add_node(agent_three)
# Create simple chain using the actual agent names
workflow.add_edge("research_agent", "research_agent_two")
workflow.add_edge("research_agent_two", "research_agent_three")
# Compile the workflow
workflow.compile()
# Run the workflow
task = "Complete a simple task"
results = workflow.run(task)
return results
if __name__ == "__main__":
main()

@ -0,0 +1,370 @@
# EuroSwarm Parliament - European Parliament Simulation
A comprehensive simulation of the European Parliament with 717 MEPs (Members of European Parliament) based on real EU data, featuring full democratic functionality including bill introduction, committee work, parliamentary debates, and democratic voting mechanisms.
## Overview
The EuroSwarm Parliament transforms the basic senator simulation into a full-fledged European Parliament with democratic capabilities. Unlike the original senator simulation that only allowed simple "Aye/Nay" voting, this system provides:
- **Democratic Discussion**: Full parliamentary debates with diverse perspectives
- **Committee Work**: Specialized committee hearings and analysis
- **Bill Processing**: Complete legislative workflow from introduction to final vote
- **Political Group Coordination**: Realistic political group dynamics
- **Real MEP Data**: Based on actual EU.xml data with 700 real MEPs
- **Board of Directors Pattern**: Advanced democratic decision-making using the Board of Directors swarm
## Key Features
### Democratic Functionality
- **Bill Introduction**: MEPs can introduce bills with sponsors and co-sponsors
- **Committee Hearings**: Specialized committee analysis and recommendations
- **Parliamentary Debates**: Multi-perspective discussions with diverse participants
- **Democratic Voting**: Comprehensive voting with individual reasoning and political group analysis
- **Amendment Process**: Support for bill amendments and modifications
### Realistic Parliament Structure
- **717 MEPs**: Based on real EU.xml data with actual MEP names and affiliations
- **Political Groups**: All major European political groups represented
- **Committee System**: 16 specialized committees with chairs and members
- **Leadership Positions**: President, Vice Presidents, Committee Chairs
- **Country Representation**: All EU member states represented
### Advanced AI Agents
- **Individual MEP Agents**: Each MEP has a unique AI agent with:
- Political group alignment
- National party affiliation
- Committee memberships
- Areas of expertise
- Country-specific interests
- **Democratic Decision-Making**: Board of Directors pattern for consensus building
- **Contextual Responses**: MEPs respond based on their political positions and expertise
## Architecture
### Core Components
#### 1. ParliamentaryMember
Represents individual MEPs with:
- Personal information (name, country, political group)
- Parliamentary role and committee memberships
- Areas of expertise and voting weight
- AI agent for decision-making
#### 2. ParliamentaryBill
Represents legislative proposals with:
- Title, description, and legislative procedure type
- Committee assignment and sponsorship
- Status tracking and amendment support
#### 3. ParliamentaryCommittee
Represents parliamentary committees with:
- Chair and vice-chair positions
- Member lists and responsibilities
- Current bills under consideration
#### 4. ParliamentaryVote
Represents voting sessions with:
- Individual MEP votes and reasoning
- Political group analysis
- Final results and statistics
### Democratic Decision-Making
The system uses the Board of Directors pattern for democratic decision-making:
1. **Political Group Leaders**: Each political group has a representative on the democratic council
2. **Weighted Voting**: Voting weights based on group size
3. **Consensus Building**: Multi-round discussions to reach consensus
4. **Individual Voting**: MEPs vote individually after considering the democratic council's analysis
## Political Groups
The simulation includes all major European political groups:
- **Group of the European People's Party (Christian Democrats)** - EPP
- **Group of the Progressive Alliance of Socialists and Democrats** - S&D
- **Renew Europe Group** - RE
- **Group of the Greens/European Free Alliance** - Greens/EFA
- **European Conservatives and Reformists Group** - ECR
- **The Left group in the European Parliament** - GUE/NGL
- **Patriots for Europe Group** - Patriots
- **Europe of Sovereign Nations Group** - ESN
- **Non-attached Members** - NI
## Committees
16 specialized committees covering all major policy areas:
1. **Agriculture and Rural Development**
2. **Budgetary Control**
3. **Civil Liberties, Justice and Home Affairs**
4. **Development**
5. **Economic and Monetary Affairs**
6. **Employment and Social Affairs**
7. **Environment, Public Health and Food Safety**
8. **Foreign Affairs**
9. **Industry, Research and Energy**
10. **Internal Market and Consumer Protection**
11. **International Trade**
12. **Legal Affairs**
13. **Petitions**
14. **Regional Development**
15. **Security and Defence**
16. **Transport and Tourism**
## Usage
### Basic Initialization
```python
from euroswarm_parliament import EuroSwarmParliament, VoteType
# Initialize parliament
parliament = EuroSwarmParliament(
eu_data_file="EU.xml",
parliament_size=None, # Use all MEPs from EU.xml (718)
enable_democratic_discussion=True,
enable_committee_work=True,
enable_amendment_process=True,
verbose=False
)
```
### Bill Introduction and Processing
```python
# Introduce a bill
bill = parliament.introduce_bill(
title="European Climate Law",
description="Framework for achieving climate neutrality by 2050",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Environment, Public Health and Food Safety",
sponsor="Philippe Lamberts"
)
# Conduct committee hearing
hearing = parliament.conduct_committee_hearing(
committee=bill.committee,
bill=bill
)
# Conduct parliamentary debate
debate = parliament.conduct_parliamentary_debate(
bill=bill,
max_speakers=20
)
# Conduct democratic vote
vote = parliament.conduct_democratic_vote(bill)
```
### Complete Democratic Session
```python
# Run a complete parliamentary session
session = parliament.run_democratic_session(
bill_title="Artificial Intelligence Act",
bill_description="Comprehensive regulation of AI systems in the EU",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Internal Market and Consumer Protection"
)
print(f"Final Outcome: {session['session_summary']['final_outcome']}")
```
### Individual MEP Interaction
```python
# Get specific MEP
mep = parliament.get_mep("Valérie Hayer")
# Ask for position on policy
response = mep.agent.run("What is your position on digital privacy regulation?")
print(f"{mep.full_name}: {response}")
```
### Political Analysis
```python
# Get parliament composition
composition = parliament.get_parliament_composition()
# Analyze political groups
for group_name, stats in composition['political_groups'].items():
print(f"{group_name}: {stats['count']} MEPs ({stats['percentage']:.1f}%)")
# Get country representation
country_members = parliament.get_country_members("Germany")
print(f"German MEPs: {len(country_members)}")
```
## Democratic Features
### 1. Democratic Discussion
- **Multi-Perspective Debates**: MEPs from different political groups and countries
- **Expertise-Based Input**: MEPs contribute based on their areas of expertise
- **Constructive Dialogue**: Respectful debate with evidence-based arguments
### 2. Committee Work
- **Specialized Analysis**: Committees provide detailed technical analysis
- **Expert Recommendations**: Committee members offer specialized insights
- **Stakeholder Consideration**: Multiple perspectives on policy impacts
### 3. Democratic Voting
- **Individual Reasoning**: Each MEP provides reasoning for their vote
- **Political Group Analysis**: Voting patterns by political affiliation
- **Transparent Process**: Full visibility into decision-making process
### 4. Consensus Building
- **Board of Directors Pattern**: Advanced democratic decision-making
- **Weighted Representation**: Political groups weighted by size
- **Multi-Round Discussion**: Iterative process to reach consensus
## 🔧 Configuration
### Parliament Settings
```python
parliament = EuroSwarmParliament(
eu_data_file="EU.xml", # Path to EU data file
parliament_size=None, # Use all MEPs from EU.xml (717)
enable_democratic_discussion=True, # Enable democratic features
enable_committee_work=True, # Enable committee system
enable_amendment_process=True, # Enable bill amendments
verbose=False # Enable detailed logging
)
```
### MEP Agent Configuration
Each MEP agent is configured with:
- **System Prompt**: Comprehensive political background and principles
- **Model**: GPT-4o-mini for consistent responses
- **Max Loops**: 3 iterations for thorough analysis
- **Expertise Areas**: Based on political group and country
## 📊 Data Sources
### EU.xml File
The simulation uses real EU data from the EU.xml file containing:
- **MEP Names**: Full names of all 700 MEPs
- **Countries**: Country representation
- **Political Groups**: European political group affiliations
- **National Parties**: National political party memberships
- **MEP IDs**: Unique identifiers for each MEP
### Fallback System
If EU.xml cannot be loaded, the system creates representative fallback MEPs:
- **Sample MEPs**: Representative selection from major political groups
- **Realistic Data**: Based on actual European Parliament composition
- **Full Functionality**: All democratic features remain available
## 🎮 Example Scenarios
### Scenario 1: Climate Policy Debate
```python
# Climate change legislation with diverse perspectives
session = parliament.run_democratic_session(
bill_title="European Climate Law",
bill_description="Carbon neutrality framework for 2050",
committee="Environment, Public Health and Food Safety"
)
```
### Scenario 2: Digital Regulation
```python
# Digital services regulation with technical analysis
session = parliament.run_democratic_session(
bill_title="Digital Services Act",
bill_description="Online platform regulation",
committee="Internal Market and Consumer Protection"
)
```
### Scenario 3: Social Policy
```python
# Minimum wage directive with social considerations
session = parliament.run_democratic_session(
bill_title="European Minimum Wage Directive",
bill_description="Framework for adequate minimum wages",
committee="Employment and Social Affairs"
)
```
## 🔮 Future Enhancements
### Planned Optimizations
1. **Performance Optimization**: Parallel processing for large-scale voting
2. **Advanced NLP**: Better analysis of debate transcripts and reasoning
3. **Real-time Updates**: Dynamic parliament composition updates
4. **Historical Analysis**: Track voting patterns and political evolution
5. **External Integration**: Connect with real EU data sources
### Potential Features
1. **Amendment System**: Full amendment proposal and voting
2. **Lobbying Simulation**: Interest group influence on MEPs
3. **Media Integration**: Public opinion and media coverage
4. **International Relations**: Interaction with other EU institutions
5. **Budget Simulation**: Financial impact analysis of legislation
## 📝 Requirements
### Dependencies
- `swarms`: Core swarm framework
- `loguru`: Advanced logging
- `xml.etree.ElementTree`: XML parsing for EU data
- `dataclasses`: Data structure support
- `typing`: Type hints
- `datetime`: Date and time handling
### Data Files
- `EU.xml`: European Parliament member data (included)
## 🏃‍♂️ Quick Start
1. **Install Dependencies**:
```bash
pip install swarms loguru
```
2. **Run Example**:
```bash
python euroswarm_parliament_example.py
```
3. **Create Custom Session**:
```python
from euroswarm_parliament import EuroSwarmParliament, VoteType
parliament = EuroSwarmParliament()
session = parliament.run_democratic_session(
bill_title="Your Bill Title",
bill_description="Your bill description",
committee="Relevant Committee"
)
```
## 🤝 Contributing
The EuroSwarm Parliament is designed to be extensible and customizable. Contributions are welcome for:
- **New Democratic Features**: Additional parliamentary procedures
- **Performance Optimizations**: Faster processing for large parliaments
- **Data Integration**: Additional EU data sources
- **Analysis Tools**: Advanced political analysis features
- **Documentation**: Improved documentation and examples
## 📄 License
This project is part of the Swarms Democracy framework and follows the same licensing terms.
## 🏛️ Acknowledgments
- **European Parliament**: For the democratic structure and procedures
- **EU Data**: For providing comprehensive MEP information
- **Swarms Framework**: For the underlying multi-agent architecture
- **Board of Directors Pattern**: For advanced democratic decision-making
---
*The EuroSwarm Parliament represents a significant advancement in democratic simulation, providing a realistic and comprehensive model of European parliamentary democracy with full AI-powered MEP representation and democratic decision-making processes.*

@ -0,0 +1,56 @@
"""
EuroSwarm Parliament - European Parliament Simulation
A comprehensive simulation of the European Parliament with 717 MEPs (Members of European Parliament)
based on real EU data, featuring full democratic functionality including bill introduction, committee work,
parliamentary debates, and democratic voting mechanisms.
Enhanced with hierarchical democratic structure where each political group operates as a specialized
Board of Directors with expertise areas, and a Parliament Speaker aggregates decisions using weighted voting.
Includes Wikipedia personality system for realistic, personality-driven MEP behavior based on real biographical data.
"""
from euroswarm_parliament import (
EuroSwarmParliament,
ParliamentaryMember,
ParliamentaryBill,
ParliamentaryVote,
ParliamentaryCommittee,
PoliticalGroupBoard,
ParliamentSpeaker,
ParliamentaryRole,
VoteType,
VoteResult,
)
# Import Wikipedia personality system
try:
from wikipedia_personality_scraper import (
WikipediaPersonalityScraper,
MEPPersonalityProfile,
)
WIKIPEDIA_PERSONALITY_AVAILABLE = True
except ImportError:
WIKIPEDIA_PERSONALITY_AVAILABLE = False
__version__ = "2.1.0"
__author__ = "Swarms Democracy Team"
__description__ = "European Parliament Simulation with Enhanced Hierarchical Democratic Functionality and Wikipedia Personality System"
__all__ = [
"EuroSwarmParliament",
"ParliamentaryMember",
"ParliamentaryBill",
"ParliamentaryVote",
"ParliamentaryCommittee",
"PoliticalGroupBoard",
"ParliamentSpeaker",
"ParliamentaryRole",
"VoteType",
"VoteResult",
"WikipediaPersonalityScraper",
"MEPPersonalityProfile",
"WIKIPEDIA_PERSONALITY_AVAILABLE",
]

@ -0,0 +1,662 @@
"""
EuroSwarm Parliament - Example Script
This script demonstrates the comprehensive democratic functionality of the EuroSwarm Parliament,
including bill introduction, committee work, parliamentary debates, and democratic voting.
"""
# Import directly from the file
from euroswarm_parliament import (
EuroSwarmParliament,
VoteType,
)
def demonstrate_parliament_initialization():
"""Demonstrate parliament initialization and basic functionality with cost optimization."""
print(
"\nEUROSWARM PARLIAMENT INITIALIZATION DEMONSTRATION (COST OPTIMIZED)"
)
print("=" * 60)
# Initialize the parliament with cost optimization
parliament = EuroSwarmParliament(
eu_data_file="EU.xml",
parliament_size=None, # Use all MEPs from EU.xml (717)
enable_democratic_discussion=True,
enable_committee_work=True,
enable_amendment_process=True,
enable_lazy_loading=True, # NEW: Lazy load MEP agents
enable_caching=True, # NEW: Enable response caching
batch_size=25, # NEW: Batch size for concurrent execution
budget_limit=100.0, # NEW: Budget limit in dollars
verbose=True,
)
print(f"Parliament initialized with {len(parliament.meps)} MEPs")
# Show parliament composition with cost stats
composition = parliament.get_parliament_composition()
print("\nPARLIAMENT COMPOSITION:")
print(f"Total MEPs: {composition['total_meps']}")
print(
f"Loaded MEPs: {composition['loaded_meps']} (lazy loading active)"
)
print("\nCOST OPTIMIZATION:")
cost_stats = composition["cost_stats"]
print(
f"Budget Limit: ${cost_stats['budget_remaining'] + cost_stats['total_cost']:.2f}"
)
print(f"Budget Used: ${cost_stats['total_cost']:.2f}")
print(f"Budget Remaining: ${cost_stats['budget_remaining']:.2f}")
print(f"Cache Hit Rate: {cost_stats['cache_hit_rate']:.1%}")
print("\nPOLITICAL GROUP DISTRIBUTION:")
for group, data in composition["political_groups"].items():
count = data["count"]
percentage = data["percentage"]
print(f" {group}: {count} MEPs ({percentage:.1f}%)")
print("\nCOMMITTEE LEADERSHIP:")
for committee_name, committee_data in composition[
"committees"
].items():
chair = committee_data["chair"]
if chair:
print(f" {committee_name}: {chair}")
return parliament
def demonstrate_individual_mep_interaction(parliament):
"""Demonstrate individual MEP interaction and personality."""
print("\nINDIVIDUAL MEP INTERACTION DEMONSTRATION")
print("=" * 60)
# Get a sample MEP
sample_mep_name = list(parliament.meps.keys())[0]
sample_mep = parliament.meps[sample_mep_name]
print(f"Sample MEP: {sample_mep.full_name}")
print(f"Country: {sample_mep.country}")
print(f"Political Group: {sample_mep.political_group}")
print(f"National Party: {sample_mep.national_party}")
print(f"Committees: {', '.join(sample_mep.committees)}")
print(f"Expertise Areas: {', '.join(sample_mep.expertise_areas)}")
# Test MEP agent interaction
if sample_mep.agent:
test_prompt = "What are your views on European integration and how do you approach cross-border cooperation?"
print(f"\nMEP Response to: '{test_prompt}'")
print("-" * 50)
try:
response = sample_mep.agent.run(test_prompt)
print(
response[:500] + "..."
if len(response) > 500
else response
)
except Exception as e:
print(f"Error getting MEP response: {e}")
def demonstrate_committee_work(parliament):
"""Demonstrate committee work and hearings."""
print("\nCOMMITTEE WORK DEMONSTRATION")
print("=" * 60)
# Get a real MEP as sponsor
sponsor = list(parliament.meps.keys())[0]
# Create a test bill
bill = parliament.introduce_bill(
title="European Digital Rights and Privacy Protection Act",
description="Comprehensive legislation to strengthen digital rights, enhance privacy protection, and establish clear guidelines for data handling across the European Union.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Legal Affairs",
sponsor=sponsor,
)
print(f"Bill: {bill.title}")
print(f"Committee: {bill.committee}")
print(f"Sponsor: {bill.sponsor}")
# Conduct committee hearing
print("\nCONDUCTING COMMITTEE HEARING...")
hearing_result = parliament.conduct_committee_hearing(
bill.committee, bill
)
print(f"Committee: {hearing_result['committee']}")
print(f"Participants: {len(hearing_result['participants'])} MEPs")
print(
f"Recommendation: {hearing_result['recommendations']['recommendation']}"
)
print(
f"Support: {hearing_result['recommendations']['support_percentage']:.1f}%"
)
print(
f"Oppose: {hearing_result['recommendations']['oppose_percentage']:.1f}%"
)
print(
f"Amend: {hearing_result['recommendations']['amend_percentage']:.1f}%"
)
def demonstrate_parliamentary_debate(parliament):
"""Demonstrate parliamentary debate functionality."""
print("\nPARLIAMENTARY DEBATE DEMONSTRATION")
print("=" * 60)
# Get a real MEP as sponsor
sponsor = list(parliament.meps.keys())[1]
# Create a test bill
bill = parliament.introduce_bill(
title="European Green Deal Implementation Act",
description="Legislation to implement the European Green Deal, including carbon neutrality targets, renewable energy investments, and sustainable development measures.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Environment, Public Health and Food Safety",
sponsor=sponsor,
)
print(f"Bill: {bill.title}")
print(f"Description: {bill.description}")
# Conduct parliamentary debate
print("\nCONDUCTING PARLIAMENTARY DEBATE...")
debate_result = parliament.conduct_parliamentary_debate(
bill, max_speakers=10
)
print(
f"Debate Participants: {len(debate_result['participants'])} MEPs"
)
print("Debate Analysis:")
print(
f" Support: {debate_result['analysis']['support_count']} speakers ({debate_result['analysis']['support_percentage']:.1f}%)"
)
print(
f" Oppose: {debate_result['analysis']['oppose_count']} speakers ({debate_result['analysis']['oppose_percentage']:.1f}%)"
)
print(
f" Neutral: {debate_result['analysis']['neutral_count']} speakers ({debate_result['analysis']['neutral_percentage']:.1f}%)"
)
def demonstrate_democratic_voting(parliament):
"""Demonstrate democratic voting functionality."""
print("\nDEMOCRATIC VOTING DEMONSTRATION")
print("=" * 60)
# Get a real MEP as sponsor
sponsor = list(parliament.meps.keys())[2]
# Create a test bill
bill = parliament.introduce_bill(
title="European Social Rights and Labor Protection Act",
description="Legislation to strengthen social rights, improve labor conditions, and ensure fair treatment of workers across the European Union.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Employment and Social Affairs",
sponsor=sponsor,
)
print(f"Bill: {bill.title}")
print(f"Sponsor: {bill.sponsor}")
# Conduct democratic vote
print("\nCONDUCTING DEMOCRATIC VOTE...")
vote_result = parliament.conduct_democratic_vote(bill)
# Calculate percentages
total_votes = (
vote_result.votes_for
+ vote_result.votes_against
+ vote_result.abstentions
)
in_favor_percentage = (
(vote_result.votes_for / total_votes * 100)
if total_votes > 0
else 0
)
against_percentage = (
(vote_result.votes_against / total_votes * 100)
if total_votes > 0
else 0
)
abstentions_percentage = (
(vote_result.abstentions / total_votes * 100)
if total_votes > 0
else 0
)
print("Vote Results:")
print(f" Total Votes: {total_votes}")
print(
f" In Favor: {vote_result.votes_for} ({in_favor_percentage:.1f}%)"
)
print(
f" Against: {vote_result.votes_against} ({against_percentage:.1f}%)"
)
print(
f" Abstentions: {vote_result.abstentions} ({abstentions_percentage:.1f}%)"
)
print(f" Result: {vote_result.result.value}")
# Show political group breakdown if available
if (
hasattr(vote_result, "group_votes")
and vote_result.group_votes
):
print("\nPOLITICAL GROUP BREAKDOWN:")
for group, votes in vote_result.group_votes.items():
print(
f" {group}: {votes['in_favor']}/{votes['total']} in favor ({votes['percentage']:.1f}%)"
)
else:
print(
f"\nIndividual votes recorded: {len(vote_result.individual_votes)} MEPs"
)
def demonstrate_complete_democratic_session(parliament):
"""Demonstrate a complete democratic parliamentary session."""
print("\nCOMPLETE DEMOCRATIC SESSION DEMONSTRATION")
print("=" * 60)
# Get a real MEP as sponsor
sponsor = list(parliament.meps.keys())[3]
# Run complete session
session_result = parliament.run_democratic_session(
bill_title="European Innovation and Technology Advancement Act",
bill_description="Comprehensive legislation to promote innovation, support technology startups, and establish Europe as a global leader in digital transformation and technological advancement.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Industry, Research and Energy",
sponsor=sponsor,
)
print("Session Results:")
print(f" Bill: {session_result['bill'].title}")
print(
f" Committee Hearing: {session_result['hearing']['recommendations']['recommendation']}"
)
print(
f" Debate Participants: {len(session_result['debate']['participants'])} MEPs"
)
print(f" Final Vote: {session_result['vote']['result']}")
print(
f" Vote Margin: {session_result['vote']['in_favor_percentage']:.1f}% in favor"
)
def demonstrate_political_analysis(parliament):
"""Demonstrate political analysis and voting prediction."""
print("\nPOLITICAL ANALYSIS DEMONSTRATION")
print("=" * 60)
# Get a real MEP as sponsor
sponsor = list(parliament.meps.keys())[4]
# Create a test bill
bill = parliament.introduce_bill(
title="European Climate Action and Sustainability Act",
description="Comprehensive climate action legislation including carbon pricing, renewable energy targets, and sustainable development measures.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Environment, Public Health and Food Safety",
sponsor=sponsor,
)
print(f"Bill: {bill.title}")
print(f"Sponsor: {bill.sponsor}")
# Analyze political landscape
analysis = parliament.analyze_political_landscape(bill)
print("\nPOLITICAL LANDSCAPE ANALYSIS:")
print(f" Overall Support: {analysis['overall_support']:.1f}%")
print(f" Opposition: {analysis['opposition']:.1f}%")
print(f" Uncertainty: {analysis['uncertainty']:.1f}%")
print("\nPOLITICAL GROUP ANALYSIS:")
for group, data in analysis["group_analysis"].items():
print(
f" {group}: {data['support']:.1f}% support, {data['opposition']:.1f}% opposition"
)
def demonstrate_hierarchical_democratic_voting(parliament):
"""Demonstrate hierarchical democratic voting with political group boards."""
print("\nHIERARCHICAL DEMOCRATIC VOTING DEMONSTRATION")
print("=" * 60)
# Get a real MEP as sponsor
sponsor = list(parliament.meps.keys())[5]
# Create a test bill
bill = parliament.introduce_bill(
title="European Climate Action and Sustainability Act",
description="Comprehensive climate action legislation including carbon pricing, renewable energy targets, and sustainable development measures.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Environment, Public Health and Food Safety",
sponsor=sponsor,
)
print(f"Bill: {bill.title}")
print(f"Sponsor: {bill.sponsor}")
# Conduct hierarchical vote
print("\nCONDUCTING HIERARCHICAL DEMOCRATIC VOTE...")
hierarchical_result = (
parliament.conduct_hierarchical_democratic_vote(bill)
)
print("Hierarchical Vote Results:")
print(f" Total Votes: {hierarchical_result['total_votes']}")
print(
f" In Favor: {hierarchical_result['in_favor']} ({hierarchical_result['in_favor_percentage']:.1f}%)"
)
print(
f" Against: {hierarchical_result['against']} ({hierarchical_result['against_percentage']:.1f}%)"
)
print(f" Result: {hierarchical_result['result']}")
print("\nPOLITICAL GROUP BOARD DECISIONS:")
for group, decision in hierarchical_result[
"group_decisions"
].items():
print(
f" {group}: {decision['decision']} ({decision['confidence']:.1f}% confidence)"
)
def demonstrate_complete_hierarchical_session(parliament):
"""Demonstrate a complete hierarchical democratic session."""
print("\nCOMPLETE HIERARCHICAL DEMOCRATIC SESSION DEMONSTRATION")
print("=" * 60)
# Get a real MEP as sponsor
sponsor = list(parliament.meps.keys())[6]
# Run complete hierarchical session
session_result = parliament.run_hierarchical_democratic_session(
bill_title="European Climate Action and Sustainability Act",
bill_description="Comprehensive climate action legislation including carbon pricing, renewable energy targets, and sustainable development measures.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Environment, Public Health and Food Safety",
sponsor=sponsor,
)
print("Hierarchical Session Results:")
print(f" Bill: {session_result['bill'].title}")
print(
f" Committee Hearing: {session_result['hearing']['recommendations']['recommendation']}"
)
print(
f" Debate Participants: {len(session_result['debate']['participants'])} MEPs"
)
print(f" Final Vote: {session_result['vote']['result']}")
print(
f" Vote Margin: {session_result['vote']['in_favor_percentage']:.1f}% in favor"
)
def demonstrate_wikipedia_personalities(parliament):
"""Demonstrate the Wikipedia personality system for realistic MEP behavior."""
print("\nWIKIPEDIA PERSONALITY SYSTEM DEMONSTRATION")
print("=" * 60)
# Check if Wikipedia personalities are available
if not parliament.enable_wikipedia_personalities:
print("Wikipedia personality system not available")
print(
"To enable: Install required dependencies and run Wikipedia scraper"
)
return
print("Wikipedia personality system enabled")
print(
f"Loaded {len(parliament.personality_profiles)} personality profiles"
)
# Show sample personality profiles
print("\nSAMPLE PERSONALITY PROFILES:")
print("-" * 40)
sample_count = 0
for mep_name, profile in parliament.personality_profiles.items():
if sample_count >= 3: # Show only 3 samples
break
print(f"\n{mep_name}")
print(
f" Wikipedia URL: {profile.wikipedia_url if profile.wikipedia_url else 'Not available'}"
)
print(
f" Summary: {profile.summary[:200]}..."
if profile.summary
else "No summary available"
)
print(
f" Political Views: {profile.political_views[:150]}..."
if profile.political_views
else "Based on party alignment"
)
print(
f" Policy Focus: {profile.policy_focus[:150]}..."
if profile.policy_focus
else "General parliamentary work"
)
print(
f" Achievements: {profile.achievements[:150]}..."
if profile.achievements
else "Parliamentary service"
)
print(f" Last Updated: {profile.last_updated}")
sample_count += 1
# Demonstrate personality-driven voting
print("\nPERSONALITY-DRIVEN VOTING DEMONSTRATION:")
print("-" * 50)
# Create a test bill that would trigger different personality responses
bill = parliament.introduce_bill(
title="European Climate Action and Green Technology Investment Act",
description="Comprehensive legislation to accelerate Europe's transition to renewable energy, including massive investments in green technology, carbon pricing mechanisms, and support for affected industries and workers.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Environment",
sponsor="Climate Action Leader",
)
print(f"Bill: {bill.title}")
print(f"Description: {bill.description}")
# Show how different MEPs with Wikipedia personalities would respond
print("\nPERSONALITY-BASED RESPONSES:")
print("-" * 40)
sample_meps = list(parliament.personality_profiles.keys())[:3]
for mep_name in sample_meps:
mep = parliament.meps.get(mep_name)
profile = parliament.personality_profiles.get(mep_name)
if mep and profile:
print(f"\n{mep_name} ({mep.political_group})")
# Show personality influence
if profile.political_views:
print(
f" Political Views: {profile.political_views[:100]}..."
)
if profile.policy_focus:
print(
f" Policy Focus: {profile.policy_focus[:100]}..."
)
# Predict voting behavior based on personality
if (
"environment" in profile.policy_focus.lower()
or "climate" in profile.political_views.lower()
):
predicted_vote = "LIKELY SUPPORT"
reasoning = (
"Environmental policy focus and climate advocacy"
)
elif (
"economic" in profile.policy_focus.lower()
or "business" in profile.political_views.lower()
):
predicted_vote = "LIKELY OPPOSE"
reasoning = "Economic concerns about investment costs"
else:
predicted_vote = "UNCERTAIN"
reasoning = (
"Mixed considerations based on party alignment"
)
print(f" Predicted Vote: {predicted_vote}")
print(f" Reasoning: {reasoning}")
# Demonstrate scraping functionality
print("\nWIKIPEDIA SCRAPING CAPABILITIES:")
print("-" * 50)
print("Can scrape Wikipedia data for all 717 MEPs")
print(
"Extracts political views, career history, and achievements"
)
print("Creates detailed personality profiles in JSON format")
print(
"Integrates real personality data into AI agent system prompts"
)
print("Enables realistic, personality-driven voting behavior")
print("Respectful API usage with configurable delays")
print("\nTo scrape all MEP personalities:")
print(" parliament.scrape_wikipedia_personalities(delay=1.0)")
print(
" # This will create personality profiles for all 717 MEPs"
)
print(" # Profiles are saved in 'mep_personalities/' directory")
def demonstrate_optimized_parliamentary_session(parliament):
"""Demonstrate cost-optimized parliamentary session."""
print("\nCOST-OPTIMIZED PARLIAMENTARY SESSION DEMONSTRATION")
print("=" * 60)
# Run optimized session with cost limit
session_result = parliament.run_optimized_parliamentary_session(
bill_title="European Digital Rights and Privacy Protection Act",
bill_description="Comprehensive legislation to strengthen digital rights, enhance privacy protection, and establish clear guidelines for data handling across the European Union.",
bill_type=VoteType.ORDINARY_LEGISLATIVE_PROCEDURE,
committee="Legal Affairs",
max_cost=25.0, # Max $25 for this session
)
print("Session Results:")
print(
f" Bill: {session_result['session_summary']['bill_title']}"
)
print(
f" Final Outcome: {session_result['session_summary']['final_outcome']}"
)
print(
f" Total Cost: ${session_result['session_summary']['total_cost']:.2f}"
)
print(
f" Budget Remaining: ${session_result['cost_stats']['budget_remaining']:.2f}"
)
# Show detailed cost statistics
cost_stats = parliament.get_cost_statistics()
print("\nDETAILED COST STATISTICS:")
print(f" Total Tokens Used: {cost_stats['total_tokens']:,}")
print(f" Requests Made: {cost_stats['requests_made']}")
print(f" Cache Hits: {cost_stats['cache_hits']}")
print(f" Cache Hit Rate: {cost_stats['cache_hit_rate']:.1%}")
print(
f" Loading Efficiency: {cost_stats['loading_efficiency']:.1%}"
)
print(f" Cache Size: {cost_stats['cache_size']} entries")
return session_result
def main():
"""Main demonstration function."""
print("EUROSWARM PARLIAMENT - COST OPTIMIZED DEMONSTRATION")
print("=" * 60)
print(
"This demonstration shows the EuroSwarm Parliament with cost optimization features:"
)
print("• Lazy loading of MEP agents (only create when needed)")
print("• Response caching (avoid repeated API calls)")
print("• Batch processing (control memory and cost)")
print("• Budget controls (hard limits on spending)")
print("• Cost tracking (real-time monitoring)")
# Initialize parliament with cost optimization
parliament = demonstrate_parliament_initialization()
# Demonstrate individual MEP interaction (will trigger lazy loading)
demonstrate_individual_mep_interaction(parliament)
# Demonstrate committee work with cost optimization
demonstrate_committee_work(parliament)
# Demonstrate parliamentary debate with cost optimization
demonstrate_parliamentary_debate(parliament)
# Demonstrate democratic voting with cost optimization
demonstrate_democratic_voting(parliament)
# Demonstrate political analysis with cost optimization
demonstrate_political_analysis(parliament)
# Demonstrate optimized parliamentary session
demonstrate_optimized_parliamentary_session(parliament)
# Show final cost statistics
final_stats = parliament.get_cost_statistics()
print("\nFINAL COST STATISTICS:")
print(f"Total Cost: ${final_stats['total_cost']:.2f}")
print(f"Budget Remaining: ${final_stats['budget_remaining']:.2f}")
print(f"Cache Hit Rate: {final_stats['cache_hit_rate']:.1%}")
print(
f"Loading Efficiency: {final_stats['loading_efficiency']:.1%}"
)
print("\n✅ COST OPTIMIZATION DEMONSTRATION COMPLETED!")
print(
"✅ EuroSwarm Parliament now supports cost-effective large-scale simulations"
)
print(
f"✅ Lazy loading: {final_stats['loaded_meps']}/{final_stats['total_meps']} MEPs loaded"
)
print(f"✅ Caching: {final_stats['cache_hit_rate']:.1%} hit rate")
print(
f"✅ Budget control: ${final_stats['total_cost']:.2f} spent of ${final_stats['budget_remaining'] + final_stats['total_cost']:.2f} budget"
)
if __name__ == "__main__":
main()

@ -0,0 +1,80 @@
#!/usr/bin/env python3
"""
Test script to verify mass agent template can process more than 500 agents.
"""
from mass_agent_template import MassAgentTemplate
def test_mass_agents():
print(
"Testing Mass Agent Template - Processing More Than 50 Agents"
)
print("=" * 60)
# Initialize template with 200 agents
template = MassAgentTemplate(
agent_count=200,
budget_limit=50.0,
batch_size=25,
verbose=True,
)
print(f"Initialized with {len(template.agents)} agents")
print(f"Budget limit: ${template.cost_tracker.budget_limit}")
# Test processing 100 agents
print("\nTesting with 100 agents...")
result = template.run_mass_task(
"What is the most important skill for your role?",
agent_count=100,
)
print("Results:")
print(f" Agents processed: {len(result['agents_used'])}")
print(f" Cost: ${result['cost_stats']['total_cost']:.4f}")
print(
f" Budget remaining: ${result['cost_stats']['budget_remaining']:.2f}"
)
print(f" Cached: {result.get('cached', False)}")
# Test processing 150 agents
print("\nTesting with 150 agents...")
result2 = template.run_mass_task(
"Describe your approach to problem-solving", agent_count=150
)
print("Results:")
print(f" Agents processed: {len(result2['agents_used'])}")
print(f" Cost: ${result2['cost_stats']['total_cost']:.4f}")
print(
f" Budget remaining: ${result2['cost_stats']['budget_remaining']:.2f}"
)
print(f" Cached: {result2.get('cached', False)}")
# Show final stats
final_stats = template.get_system_stats()
print("\nFinal Statistics:")
print(f" Total agents: {final_stats['total_agents']}")
print(f" Loaded agents: {final_stats['loaded_agents']}")
print(
f" Total cost: ${final_stats['cost_stats']['total_cost']:.4f}"
)
print(
f" Budget remaining: ${final_stats['cost_stats']['budget_remaining']:.2f}"
)
# Success criteria
total_processed = len(result["agents_used"]) + len(
result2["agents_used"]
)
print(f"\nTotal agents processed: {total_processed}")
if total_processed > 50:
print("✅ SUCCESS: Template processed more than 50 agents!")
else:
print("❌ FAILURE: Template still limited to 50 agents")
if __name__ == "__main__":
test_mass_agents()

@ -0,0 +1,681 @@
#!/usr/bin/env python3
"""
Wikipedia Personality Scraper for EuroSwarm Parliament MEPs
This module scrapes Wikipedia data for each MEP to create realistic, personality-driven
AI agents based on their real backgrounds, political history, and personal beliefs.
"""
import json
import os
import time
import re
from typing import Dict, List, Optional, Any
from dataclasses import dataclass, asdict
import requests
from loguru import logger
@dataclass
class MEPPersonalityProfile:
"""
Comprehensive personality profile for an MEP based on Wikipedia data.
Attributes:
full_name: Full name of the MEP
mep_id: Unique MEP identifier
wikipedia_url: URL of the MEP's Wikipedia page
summary: Brief summary of the MEP's background
early_life: Early life and education information
political_career: Political career and positions held
political_views: Key political views and positions
policy_focus: Areas of policy expertise and focus
achievements: Notable achievements and accomplishments
controversies: Any controversies or notable incidents
personal_life: Personal background and family information
education: Educational background
professional_background: Professional experience before politics
party_affiliations: Political party history
committee_experience: Parliamentary committee experience
voting_record: Notable voting patterns or positions
public_statements: Key public statements or quotes
interests: Personal and professional interests
languages: Languages spoken
awards: Awards and recognitions
publications: Publications or written works
social_media: Social media presence
last_updated: When the profile was last updated
"""
full_name: str
mep_id: str
wikipedia_url: Optional[str] = None
summary: str = ""
early_life: str = ""
political_career: str = ""
political_views: str = ""
policy_focus: str = ""
achievements: str = ""
controversies: str = ""
personal_life: str = ""
education: str = ""
professional_background: str = ""
party_affiliations: str = ""
committee_experience: str = ""
voting_record: str = ""
public_statements: str = ""
interests: str = ""
languages: str = ""
awards: str = ""
publications: str = ""
social_media: str = ""
last_updated: str = ""
class WikipediaPersonalityScraper:
"""
Scraper for gathering Wikipedia personality data for MEPs.
"""
def __init__(
self,
output_dir: str = "mep_personalities",
verbose: bool = True,
):
"""
Initialize the Wikipedia personality scraper.
Args:
output_dir: Directory to store personality profiles
verbose: Enable verbose logging
"""
self.output_dir = output_dir
self.verbose = verbose
self.session = requests.Session()
self.session.headers.update(
{
"User-Agent": "EuroSwarm Parliament Personality Scraper/1.0 (https://github.com/swarms-democracy)"
}
)
# Create output directory
os.makedirs(output_dir, exist_ok=True)
if verbose:
logger.info(
f"Wikipedia Personality Scraper initialized. Output directory: {output_dir}"
)
def extract_mep_data_from_xml(
self, xml_file: str = "EU.xml"
) -> List[Dict[str, str]]:
"""
Extract MEP data from EU.xml file.
Args:
xml_file: Path to EU.xml file
Returns:
List of MEP data dictionaries
"""
meps = []
try:
with open(xml_file, "r", encoding="utf-8") as f:
content = f.read()
# Use regex to extract MEP data
mep_pattern = r"<mep>\s*<fullName>(.*?)</fullName>\s*<country>(.*?)</country>\s*<politicalGroup>(.*?)</politicalGroup>\s*<id>(.*?)</id>\s*<nationalPoliticalGroup>(.*?)</nationalPoliticalGroup>\s*</mep>"
mep_matches = re.findall(mep_pattern, content, re.DOTALL)
for (
full_name,
country,
political_group,
mep_id,
national_party,
) in mep_matches:
meps.append(
{
"full_name": full_name.strip(),
"country": country.strip(),
"political_group": political_group.strip(),
"mep_id": mep_id.strip(),
"national_party": national_party.strip(),
}
)
if self.verbose:
logger.info(
f"Extracted {len(meps)} MEPs from {xml_file}"
)
except Exception as e:
logger.error(
f"Error extracting MEP data from {xml_file}: {e}"
)
return meps
def search_wikipedia_page(
self, mep_name: str, country: str
) -> Optional[str]:
"""
Search for a Wikipedia page for an MEP.
Args:
mep_name: Full name of the MEP
country: Country of the MEP
Returns:
Wikipedia page title if found, None otherwise
"""
try:
# Search for the MEP on Wikipedia
search_url = "https://en.wikipedia.org/w/api.php"
search_params = {
"action": "query",
"format": "json",
"list": "search",
"srsearch": f'"{mep_name}" {country}',
"srlimit": 5,
"srnamespace": 0,
}
response = self.session.get(
search_url, params=search_params
)
response.raise_for_status()
data = response.json()
search_results = data.get("query", {}).get("search", [])
if search_results:
# Return the first result
return search_results[0]["title"]
# Try alternative search without quotes
search_params["srsearch"] = f"{mep_name} {country}"
response = self.session.get(
search_url, params=search_params
)
response.raise_for_status()
data = response.json()
search_results = data.get("query", {}).get("search", [])
if search_results:
return search_results[0]["title"]
except Exception as e:
if self.verbose:
logger.warning(
f"Error searching Wikipedia for {mep_name}: {e}"
)
return None
def get_wikipedia_content(
self, page_title: str
) -> Optional[Dict[str, Any]]:
"""
Get Wikipedia content for a specific page.
Args:
page_title: Wikipedia page title
Returns:
Dictionary containing page content and metadata
"""
try:
# Get page content
content_url = "https://en.wikipedia.org/w/api.php"
content_params = {
"action": "query",
"format": "json",
"titles": page_title,
"prop": "extracts|info|categories",
"exintro": True,
"explaintext": True,
"inprop": "url",
"cllimit": 50,
}
response = self.session.get(
content_url, params=content_params
)
response.raise_for_status()
data = response.json()
pages = data.get("query", {}).get("pages", {})
if pages:
page_id = list(pages.keys())[0]
page_data = pages[page_id]
return {
"title": page_data.get("title", ""),
"extract": page_data.get("extract", ""),
"url": page_data.get("fullurl", ""),
"categories": [
cat["title"]
for cat in page_data.get("categories", [])
],
"pageid": page_data.get("pageid", ""),
"length": page_data.get("length", 0),
}
except Exception as e:
if self.verbose:
logger.warning(
f"Error getting Wikipedia content for {page_title}: {e}"
)
return None
def parse_wikipedia_content(
self, content: str, mep_name: str
) -> Dict[str, str]:
"""
Parse Wikipedia content to extract structured personality information.
Args:
content: Raw Wikipedia content
mep_name: Name of the MEP
Returns:
Dictionary of parsed personality information
"""
personality_data = {
"summary": "",
"early_life": "",
"political_career": "",
"political_views": "",
"policy_focus": "",
"achievements": "",
"controversies": "",
"personal_life": "",
"education": "",
"professional_background": "",
"party_affiliations": "",
"committee_experience": "",
"voting_record": "",
"public_statements": "",
"interests": "",
"languages": "",
"awards": "",
"publications": "",
"social_media": "",
}
# Extract summary (first paragraph)
paragraphs = content.split("\n\n")
if paragraphs:
personality_data["summary"] = paragraphs[0][
:1000
] # Limit summary length
# Look for specific sections
content_lower = content.lower()
# Early life and education
early_life_patterns = [
r"early life[^.]*\.",
r"born[^.]*\.",
r"childhood[^.]*\.",
r"grew up[^.]*\.",
r"education[^.]*\.",
]
for pattern in early_life_patterns:
matches = re.findall(
pattern, content_lower, re.IGNORECASE
)
if matches:
personality_data["early_life"] = " ".join(
matches[:3]
) # Take first 3 matches
break
# Political career
political_patterns = [
r"political career[^.]*\.",
r"elected[^.]*\.",
r"parliament[^.]*\.",
r"minister[^.]*\.",
r"party[^.]*\.",
]
for pattern in political_patterns:
matches = re.findall(
pattern, content_lower, re.IGNORECASE
)
if matches:
personality_data["political_career"] = " ".join(
matches[:5]
) # Take first 5 matches
break
# Political views
views_patterns = [
r"political views[^.]*\.",
r"positions[^.]*\.",
r"advocates[^.]*\.",
r"supports[^.]*\.",
r"opposes[^.]*\.",
]
for pattern in views_patterns:
matches = re.findall(
pattern, content_lower, re.IGNORECASE
)
if matches:
personality_data["political_views"] = " ".join(
matches[:3]
)
break
# Policy focus
policy_patterns = [
r"policy[^.]*\.",
r"focus[^.]*\.",
r"issues[^.]*\.",
r"legislation[^.]*\.",
]
for pattern in policy_patterns:
matches = re.findall(
pattern, content_lower, re.IGNORECASE
)
if matches:
personality_data["policy_focus"] = " ".join(
matches[:3]
)
break
# Achievements
achievement_patterns = [
r"achievements[^.]*\.",
r"accomplishments[^.]*\.",
r"success[^.]*\.",
r"won[^.]*\.",
r"received[^.]*\.",
]
for pattern in achievement_patterns:
matches = re.findall(
pattern, content_lower, re.IGNORECASE
)
if matches:
personality_data["achievements"] = " ".join(
matches[:3]
)
break
return personality_data
def create_personality_profile(
self, mep_data: Dict[str, str]
) -> MEPPersonalityProfile:
"""
Create a personality profile for an MEP.
Args:
mep_data: MEP data from XML file
Returns:
MEPPersonalityProfile object
"""
mep_name = mep_data["full_name"]
country = mep_data["country"]
# Search for Wikipedia page
page_title = self.search_wikipedia_page(mep_name, country)
if page_title:
# Get Wikipedia content
wiki_content = self.get_wikipedia_content(page_title)
if wiki_content:
# Parse content
personality_data = self.parse_wikipedia_content(
wiki_content["extract"], mep_name
)
# Create profile
profile = MEPPersonalityProfile(
full_name=mep_name,
mep_id=mep_data["mep_id"],
wikipedia_url=wiki_content["url"],
summary=personality_data["summary"],
early_life=personality_data["early_life"],
political_career=personality_data[
"political_career"
],
political_views=personality_data[
"political_views"
],
policy_focus=personality_data["policy_focus"],
achievements=personality_data["achievements"],
controversies=personality_data["controversies"],
personal_life=personality_data["personal_life"],
education=personality_data["education"],
professional_background=personality_data[
"professional_background"
],
party_affiliations=personality_data[
"party_affiliations"
],
committee_experience=personality_data[
"committee_experience"
],
voting_record=personality_data["voting_record"],
public_statements=personality_data[
"public_statements"
],
interests=personality_data["interests"],
languages=personality_data["languages"],
awards=personality_data["awards"],
publications=personality_data["publications"],
social_media=personality_data["social_media"],
last_updated=time.strftime("%Y-%m-%d %H:%M:%S"),
)
if self.verbose:
logger.info(
f"Created personality profile for {mep_name} from Wikipedia"
)
return profile
# Create minimal profile if no Wikipedia data found
profile = MEPPersonalityProfile(
full_name=mep_name,
mep_id=mep_data["mep_id"],
summary=f"{mep_name} is a Member of the European Parliament representing {country}.",
political_career=f"Currently serving as MEP for {country}.",
political_views=f"Member of {mep_data['political_group']} and {mep_data['national_party']}.",
last_updated=time.strftime("%Y-%m-%d %H:%M:%S"),
)
if self.verbose:
logger.warning(
f"No Wikipedia data found for {mep_name}, created minimal profile"
)
return profile
def save_personality_profile(
self, profile: MEPPersonalityProfile
) -> str:
"""
Save personality profile to JSON file.
Args:
profile: MEPPersonalityProfile object
Returns:
Path to saved file
"""
# Create safe filename
safe_name = re.sub(r"[^\w\s-]", "", profile.full_name).strip()
safe_name = re.sub(r"[-\s]+", "_", safe_name)
filename = f"{safe_name}_{profile.mep_id}.json"
filepath = os.path.join(self.output_dir, filename)
# Convert to dictionary and save
profile_dict = asdict(profile)
with open(filepath, "w", encoding="utf-8") as f:
json.dump(profile_dict, f, indent=2, ensure_ascii=False)
if self.verbose:
logger.info(f"Saved personality profile: {filepath}")
return filepath
def scrape_all_mep_personalities(
self, xml_file: str = "EU.xml", delay: float = 1.0
) -> Dict[str, str]:
"""
Scrape personality data for all MEPs.
Args:
xml_file: Path to EU.xml file
delay: Delay between requests to be respectful to Wikipedia
Returns:
Dictionary mapping MEP names to their personality profile file paths
"""
meps = self.extract_mep_data_from_xml(xml_file)
profile_files = {}
if self.verbose:
logger.info(
f"Starting personality scraping for {len(meps)} MEPs"
)
for i, mep_data in enumerate(meps, 1):
mep_name = mep_data["full_name"]
if self.verbose:
logger.info(f"Processing {i}/{len(meps)}: {mep_name}")
try:
# Create personality profile
profile = self.create_personality_profile(mep_data)
# Save profile
filepath = self.save_personality_profile(profile)
profile_files[mep_name] = filepath
# Respectful delay
time.sleep(delay)
except Exception as e:
logger.error(f"Error processing {mep_name}: {e}")
continue
if self.verbose:
logger.info(
f"Completed personality scraping. {len(profile_files)} profiles created."
)
return profile_files
def load_personality_profile(
self, filepath: str
) -> MEPPersonalityProfile:
"""
Load personality profile from JSON file.
Args:
filepath: Path to personality profile JSON file
Returns:
MEPPersonalityProfile object
"""
with open(filepath, "r", encoding="utf-8") as f:
data = json.load(f)
return MEPPersonalityProfile(**data)
def get_personality_summary(
self, profile: MEPPersonalityProfile
) -> str:
"""
Generate a personality summary for use in AI agent system prompts.
Args:
profile: MEPPersonalityProfile object
Returns:
Formatted personality summary
"""
summary_parts = []
if profile.summary:
summary_parts.append(f"Background: {profile.summary}")
if profile.political_career:
summary_parts.append(
f"Political Career: {profile.political_career}"
)
if profile.political_views:
summary_parts.append(
f"Political Views: {profile.political_views}"
)
if profile.policy_focus:
summary_parts.append(
f"Policy Focus: {profile.policy_focus}"
)
if profile.achievements:
summary_parts.append(
f"Notable Achievements: {profile.achievements}"
)
if profile.education:
summary_parts.append(f"Education: {profile.education}")
if profile.professional_background:
summary_parts.append(
f"Professional Background: {profile.professional_background}"
)
return "\n".join(summary_parts)
def main():
"""Main function to run the Wikipedia personality scraper."""
print("🏛️ WIKIPEDIA PERSONALITY SCRAPER FOR EUROSWARM PARLIAMENT")
print("=" * 70)
# Initialize scraper
scraper = WikipediaPersonalityScraper(
output_dir="mep_personalities", verbose=True
)
# Scrape all MEP personalities
profile_files = scraper.scrape_all_mep_personalities(delay=1.0)
print("\n✅ Scraping completed!")
print(f"📁 Profiles saved to: {scraper.output_dir}")
print(f"📊 Total profiles created: {len(profile_files)}")
# Show sample profile
if profile_files:
sample_name = list(profile_files.keys())[0]
sample_file = profile_files[sample_name]
sample_profile = scraper.load_personality_profile(sample_file)
print(f"\n📋 Sample Profile: {sample_name}")
print("-" * 50)
print(scraper.get_personality_summary(sample_profile))
if __name__ == "__main__":
main()

Before

Width:  |  Height:  |  Size: 943 KiB

After

Width:  |  Height:  |  Size: 943 KiB

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save