Skip to main content

Swarms Deploy 🚀

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

PyPI version License: MIT Python 3.8+

Production-grade API deployment framework for Swarms AI workflows. Easily deploy, scale, and manage your swarm-based applications with enterprise features.

Features ✨

  • 🔥 Fast API-based deployment framework
  • 🤖 Support for synchronous and asynchronous swarm execution
  • 🔄 Built-in load balancing and scaling
  • 📊 Real-time monitoring and logging
  • 🛡️ Enterprise-grade error handling
  • 🎯 Priority-based task execution
  • 📦 Simple deployment and configuration
  • 🔌 Extensible plugin architecture

Installation 📦

pip install -U swarms-deploy

Quick Start 🚀

import os
from dotenv import load_dotenv
from swarms import Agent, SequentialWorkflow
from swarm_models import OpenAIChat
from swarm_deploy import SwarmDeploy

load_dotenv()

# Get the OpenAI API key from the environment variable
api_key = os.getenv("GROQ_API_KEY")

# Model
model = OpenAIChat(
    openai_api_base="https://api.groq.com/openai/v1",
    openai_api_key=api_key,
    model_name="llama-3.1-70b-versatile",
    temperature=0.1,
)


# Initialize specialized agents
data_extractor_agent = Agent(
    agent_name="Data-Extractor",
    system_prompt=None,
    llm=model,
    max_loops=1,
    autosave=True,
    verbose=True,
    dynamic_temperature_enabled=True,
    saved_state_path="data_extractor_agent.json",
    user_name="pe_firm",
    retry_attempts=1,
    context_length=200000,
    output_type="string",
)

summarizer_agent = Agent(
    agent_name="Document-Summarizer",
    system_prompt=None,
    llm=model,
    max_loops=1,
    autosave=True,
    verbose=True,
    dynamic_temperature_enabled=True,
    saved_state_path="summarizer_agent.json",
    user_name="pe_firm",
    retry_attempts=1,
    context_length=200000,
    output_type="string",
)

financial_analyst_agent = Agent(
    agent_name="Financial-Analyst",
    system_prompt=None,
    llm=model,
    max_loops=1,
    autosave=True,
    verbose=True,
    dynamic_temperature_enabled=True,
    saved_state_path="financial_analyst_agent.json",
    user_name="pe_firm",
    retry_attempts=1,
    context_length=200000,
    output_type="string",
)

market_analyst_agent = Agent(
    agent_name="Market-Analyst",
    system_prompt=None,
    llm=model,
    max_loops=1,
    autosave=True,
    verbose=True,
    dynamic_temperature_enabled=True,
    saved_state_path="market_analyst_agent.json",
    user_name="pe_firm",
    retry_attempts=1,
    context_length=200000,
    output_type="string",
)

operational_analyst_agent = Agent(
    agent_name="Operational-Analyst",
    system_prompt=None,
    llm=model,
    max_loops=1,
    autosave=True,
    verbose=True,
    dynamic_temperature_enabled=True,
    saved_state_path="operational_analyst_agent.json",
    user_name="pe_firm",
    retry_attempts=1,
    context_length=200000,
    output_type="string",
)

# Initialize the SwarmRouter
router = SequentialWorkflow(
    name="pe-document-analysis-swarm",
    description="Analyze documents for private equity due diligence and investment decision-making",
    max_loops=1,
    agents=[
        data_extractor_agent,
        summarizer_agent,
        financial_analyst_agent,
        market_analyst_agent,
        operational_analyst_agent,
    ],
    output_type="all",
)

# Advanced usage with configuration
swarm = SwarmDeploy(
    router,
    max_workers=4,
    # cache_backend="redis"
)
swarm.start(
    host="0.0.0.0",
    port=8000,
    workers=4,
)

Advanced Usage 🔧

Configuration Options

swarm = SwarmDeploy(
    workflow,
    max_workers=4,
    cache_backend="redis",
    ssl_config={
        "keyfile": "path/to/key.pem",
        "certfile": "path/to/cert.pem"
    }
)

API Reference 📚

SwarmInput Model

class SwarmInput(BaseModel):
    task: str          # Task description
    img: Optional[str] # Optional image input
    priority: int      # Task priority (0-10)

API Endpoints

  • POST /v1/swarms/completions/{callable_name}
    • Execute a task with the specified swarm
    • Returns: SwarmOutput or SwarmBatchOutput

Example Request

curl -X POST "http://localhost:8000/v1/swarms/completions/document-analysis" \
     -H "Content-Type: application/json" \
     -d '{"task": "Analyze financial report", "priority": 5}'

Monitoring and Logging 📊

SwarmDeploy provides built-in monitoring capabilities:

  • Real-time task execution stats
  • Error tracking and reporting
  • Performance metrics
  • Task history and audit logs

Error Handling 🛡️

The system includes comprehensive error handling:

try:
    result = await swarm.run(task)
except Exception as e:
    error_output = SwarmOutput(
        id=str(uuid.uuid4()),
        status="error",
        execution_time=time.time() - start_time,
        result=None,
        error=str(e)
    )

Best Practices 🎯

  1. Always set appropriate task priorities
  2. Implement proper error handling
  3. Use clustering for high-availability
  4. Monitor system performance
  5. Regular maintenance and updates

Contributing 🤝

Contributions are welcome! Please read our Contributing Guidelines for details on our code of conduct and the process for submitting pull requests.

Support 💬

License 📄

MIT License - see the LICENSE file for details.


Powered by swarms.ai 🚀

For enterprise support and custom solutions, contact kye@swarms.world

Metadata

Release files for swarm-deploy 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarm-deploy 0.0.4
File Size Uploaded
swarm_deploy-0.0.4.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swarm-deploy 0.0.4
File Interpreter ABI Platform
swarm_deploy-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / swarm_deploy-0.0.4.tar.gz

Download URL swarm_deploy-0.0.4.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
048ddb1d121b631462245f85e030146ec6fee5969319a24d51645357654f2b97
BLAKE2b-256 checksum
How to use checksums
c403c0fcf270e492c1db27f5e7565baa09bac30cc310eac5075e05693f672f74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.8 Darwin/23.3.0

Release files / swarm_deploy-0.0.4-py3-none-any.whl

Download URL swarm_deploy-0.0.4-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f1e36d3afcbd37e3c3e9ebea07fc435b670c88824dabdc76b6bf708bffcdab1
BLAKE2b-256 checksum
How to use checksums
1eeed0ca4821ddcdf065bf2323f8dff3082d98c76baaf6c6d5c1d505db205ed7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.8 Darwin/23.3.0

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page