MCPcopy
hub / github.com/kyegomez/swarms

github.com/kyegomez/swarms @6.8.1 sqlite

repository ↗ · DeepWiki ↗ · release 6.8.1 ↗
2,138 symbols 7,332 edges 277 files 1,073 documented · 50%
README

Logo

The Enterprise-Grade Production-Ready Multi-Agent Orchestration Framework

<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>

🐦 Twitter   •   📢 Discord   •   Swarms Platform   •   📙 Documentation

Join our Discord Subscribe on YouTube Connect on LinkedIn Follow on X.com

GitHub issues GitHub forks GitHub stars GitHub licenseGitHub star chartDependency Status Downloads

Share on Twitter Share on Facebook Share on LinkedIn

Share on Reddit Share on Hacker News Share on Pinterest Share on WhatsApp

✨ Features

Category Features Benefits
🏢 Enterprise Architecture • Production-Ready Infrastructure

• High Reliability Systems

• Modular Design

• Comprehensive Logging | • Reduced downtime

• Easier maintenance

• Better debugging

• Enhanced monitoring | | 🤖 Agent Orchestration | • Hierarchical Swarms

• Parallel Processing

• Sequential Workflows

• Graph-based Workflows

• Dynamic Agent Rearrangement | • Complex task handling

• Improved performance

• Flexible workflows

• Optimized execution | | 🔄 Integration Capabilities | • Multi-Model Support

• Custom Agent Creation

• Extensive Tool Library

• Multiple Memory Systems | • Provider flexibility

• Custom solutions

• Extended functionality

• Enhanced memory management | | 📈 Scalability | • Concurrent Processing

• Resource Management

• Load Balancing

• Horizontal Scaling | • Higher throughput

• Efficient resource use

• Better performance

• Easy scaling | | 🛠️ Developer Tools | • Simple API

• Extensive Documentation

• Active Community

• CLI Tools | • Faster development

• Easy learning curve

• Community support

• Quick deployment | | 🔐 Security Features | • Error Handling

• Rate Limiting

• Monitoring Integration

• Audit Logging | • Improved reliability

• API protection

• Better monitoring

• Enhanced tracking | | 📊 Advanced Features | • SpreadsheetSwarm

• Group Chat

• Agent Registry

• Mixture of Agents | • Mass agent management

• Collaborative AI

• Centralized control

• Complex solutions | | 🔌 Provider Support | • OpenAI

• Anthropic

• ChromaDB

• Custom Providers | • Provider flexibility

• Storage options

• Custom integration

• Vendor independence | | 💪 Production Features | • Automatic Retries

• Async Support

• Environment Management

• Type Safety | • Better reliability

• Improved performance

• Easy configuration

• Safer code | | 🎯 Use Case Support | • Task-Specific Agents

• Custom Workflows

• Industry Solutions

• Extensible Framework | • Quick deployment

• Flexible solutions

• Industry readiness

• Easy customization |


Requirements

  • python3.10 or above!
  • $ pip install -U swarms And, don't forget to install swarms!
  • .env file with API keys from your providers like OPENAI_API_KEY, ANTHROPIC_API_KEY
  • Set an .env Variable with your desired workspace dir: WORKSPACE_DIR="agent_workspace" or do it in your terminal with export WORKSPACE_DIR="agent_workspace"
  • Finally, swarms onboarding to get you started.

Guides and Walkthroughs

Refer to our documentation for production grade implementation details.

Section Links
Installation Installation
Quickstart Get Started
Agent Internal Mechanisms Agent Architecture
Agent API Agent API
Integrating External Agents Griptape, Autogen, etc Integrating External APIs
Creating Agents from YAML Creating Agents from YAML
Why You Need Swarms Why MultiAgent Collaboration is Necessary
Swarm Architectures Analysis Swarm Architectures
Choosing the Right Swarm for Your Business Problem¶ CLICK HERE
AgentRearrange Docs CLICK HERE

Install 💻

Install the following packages with copy and paste

$ pip3 install -U swarms swarm-models swarms-memory

Onboarding

Now that you have downloaded swarms with pip3 install -U swarms, we get access to the CLI. Get Onboarded with CLI Now with:

swarms onboarding

You can also run this command for help:

swarms help

For more documentation on the CLI CLICK HERE


Usage Examples 🤖

Here are some example scripts to get you started. For more comprehensive documentation, visit our docs.

Example Name Description Type of Examples Link
Swarms Examples A collection of simple examples to demonstrate Swarms capabilities. Basic Usage https://github.com/The-Swarm-Corporation/swarms-examples?tab=readme-ov-file
Cookbook A comprehensive guide with recipes for various use cases and scenarios. Advanced Usage https://github.com/The-Swarm-Corporation/Cookbook

Agent Class

The Agent class is a fundamental component of the Swarms framework, designed to execute tasks autonomously. It fuses llms, tools and long-term memory capabilities to create a full stack agent. The Agent class is highly customizable, allowing for fine-grained control over its behavior and interactions.

run Method

The run method is the primary entry point for executing tasks with an Agent instance. It accepts a task string as the main input task and processes it according to the agent's configuration. And, it can also accept an img parameter such as img="image_filepath.png to process images if you have a VLM attached such as GPT4VisionAPI

Simple Example

from swarms import Agent

agent = Agent(
    agent_name="Stock-Analysis-Agent",
    model_name="gpt-4o-mini",
    max_loops="auto",
    interactive=True,
    streaming_on=True,
)

agent.run("What is the current market trend for tech stocks?")

Settings and Customization

The Agent class offers a range of settings to tailor its behavior to specific needs. Some key settings include:

Setting Description Default Value
agent_name The name of the agent. "DefaultAgent"
system_prompt The system prompt to use for the agent. "Default system prompt."
llm The language model to use for processing tasks. OpenAIChat instance
max_loops The maximum number of loops to execute for a task. 1
autosave Enables or disables autosaving of the agent's state. False
dashboard Enables or disables the dashboard for the agent. False
verbose Controls the verbosity of the agent's output. False
dynamic_temperature_enabled Enables or disables dynamic temperature adjustment for the language model. False
saved_state_path The path to save the agent's state. "agent_state.json"
user_name The username associated with the agent. "default_user"
retry_attempts The number of retry attempts for failed tasks. 1
context_length The maximum length of the context to consider for tasks. 200000
return_step_meta Controls whether to return step metadata in the output. False
output_type The type of output to return (e.g., "json", "string"). "string"
import os
from swarms import Agent

from swarms.prompts.finance_agent_sys_prompt import (
    FINANCIAL_AGENT_SYS_PROMPT,
)
# Initialize the agent
agent = Agent(
    agent_name="Financial-Analysis-Agent",
    system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
    model_name="gpt-4o-mini",
    max_loops=1,
    autosave=True,
    dashboard=False,
    verbose=True,
    dynamic_temperature_enabled=True,
    saved_state_path="finance_agent.json",
    user_name="swarms_corp",
    retry_attempts=1,
    context_length=200000,
    return_step_meta=False,
    output_type="string",
    streaming_on=False,
)


agent.run(
    "How can I establish a ROTH IRA to buy stocks and get a tax break? What are the criteria"
)


Integrating RAG with Swarms for Enhanced Long-Term Memory

Agent equipped with quasi-infinite long term memory using RAG (Relational Agent Graph) for advanced document understanding, analysis, and retrieval capabilities.

Mermaid Diagram for RAG Integration

graph TD
    A[Initialize Agent with RAG] --> B[Receive Task]
    B --> C[Query Long-Term Memory]
    C --> D[Process Task with Context]
    D --> E[Generate Response]
    E --> F[Update Long-Term Memory]
    F --> G[Return Output]

```python from swarms import Agent from swarms.prompts.finance_agent_sys_prompt import ( FINANCIAL_AGENT_SYS_PROMPT, ) import os

from swarms_memory import ChromaDB

Initialize the ChromaDB client for long-term memory management

chromadb = ChromaDB( metric="cosine", # Metric for similarity measurement output_dir="finance_agent_rag", # Directory for storing RAG data # docs_folder="artifacts", # Uncomment and specify the folder containing yo

Core symbols most depended-on inside this repo

get
called by 123
swarms/structs/company.py
run
called by 58
new_features_examples/gemini_model.py
add
called by 48
swarms/structs/company.py
run
called by 46
swarms/structs/task.py
initialize_logger
called by 44
swarms/utils/loguru_logger.py
add
called by 33
swarms/structs/conversation.py
print_panel
called by 30
swarms/utils/formatter.py
start
called by 26
api/advanced_api.py

Shape

Method 1,023
Function 792
Class 276
Route 47

Languages

Python100%

Modules by API surface

tests/structs/test_agent.py139 symbols
tests/tools/test_tools_base.py110 symbols
swarms/structs/agent.py89 symbols
api/advanced_api.py87 symbols
swarms/structs/base_swarm.py79 symbols
api/main.py69 symbols
new_features_examples/microstructure.py46 symbols
tests/structs/test_sequential_workflow.py42 symbols
swarms/structs/base_structure.py38 symbols
swarms/structs/async_workflow.py35 symbols
tests/structs/test_task.py26 symbols
tests/structs/test_conversation.py26 symbols

Dependencies from manifests, versioned

asyncio3.4.3 · 1×
babel2.16 · 1×
black23.1 · 1×
colorama0.4 · 1×
docstring_parser0.16 · 1×
jinja23.1 · 1×
markdown3.7 · 1×
mkdocs-material-extensions1.3 · 1×
mypy-protobuf3.0.0 · 1×
paginate0.5 · 1×
pandas2.2.2 · 1×
pydantic2.8.2 · 1×

For agents

$ claude mcp add swarms \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact