swarm-deploy


Nameswarm-deploy JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/The-Swarm-Corporation/SwarmDeploy
SummarySwarm-Deploy - TGSC
upload_time2025-01-16 01:11:42
maintainerNone
docs_urlNone
authorKye Gomez
requires_python<4.0,>=3.10
licenseMIT
keywords artificial intelligence deep learning optimizers prompt engineering
VCS
bugtrack_url
requirements swarms asyncio uuid datetime typing orjson structlog aiocache fastapi prometheus_client pydantic rich
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Swarms Deploy 🚀

[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![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/kyegomezb)


[![PyPI version](https://badge.fury.io/py/swarms-deploy.svg)](https://badge.fury.io/py/swarms-deploy)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

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 📦

```bash
pip install -U swarms-deploy
```

## Quick Start 🚀

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

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

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

```bash
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:

```python
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](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.

## Support 💬

- Email: kye@swarms.world
- Discord: [Join our community](https://swarms.world/swarms)
- Documentation: [https://docs.swarms.world](https://docs.swarms.world)

## License 📄

MIT License - see the [LICENSE](LICENSE) file for details.

---

Powered by [swarms.ai](https://swarms.ai) 🚀

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

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/The-Swarm-Corporation/SwarmDeploy",
    "name": "swarm-deploy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "artificial intelligence, deep learning, optimizers, Prompt Engineering",
    "author": "Kye Gomez",
    "author_email": "kye@apac.ai",
    "download_url": "https://files.pythonhosted.org/packages/c4/03/c0fcf270e492c1db27f5e7565baa09bac30cc310eac5075e05693f672f74/swarm_deploy-0.0.4.tar.gz",
    "platform": null,
    "description": "# Swarms Deploy \ud83d\ude80\n\n[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![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/kyegomezb)\n\n\n[![PyPI version](https://badge.fury.io/py/swarms-deploy.svg)](https://badge.fury.io/py/swarms-deploy)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n\nProduction-grade API deployment framework for Swarms AI workflows. Easily deploy, scale, and manage your swarm-based applications with enterprise features.\n\n## Features \u2728\n\n- \ud83d\udd25 Fast API-based deployment framework\n- \ud83e\udd16 Support for synchronous and asynchronous swarm execution\n- \ud83d\udd04 Built-in load balancing and scaling\n- \ud83d\udcca Real-time monitoring and logging\n- \ud83d\udee1\ufe0f Enterprise-grade error handling\n- \ud83c\udfaf Priority-based task execution\n- \ud83d\udce6 Simple deployment and configuration\n- \ud83d\udd0c Extensible plugin architecture\n\n## Installation \ud83d\udce6\n\n```bash\npip install -U swarms-deploy\n```\n\n## Quick Start \ud83d\ude80\n\n```python\nimport os\nfrom dotenv import load_dotenv\nfrom swarms import Agent, SequentialWorkflow\nfrom swarm_models import OpenAIChat\nfrom swarm_deploy import SwarmDeploy\n\nload_dotenv()\n\n# Get the OpenAI API key from the environment variable\napi_key = os.getenv(\"GROQ_API_KEY\")\n\n# Model\nmodel = OpenAIChat(\n    openai_api_base=\"https://api.groq.com/openai/v1\",\n    openai_api_key=api_key,\n    model_name=\"llama-3.1-70b-versatile\",\n    temperature=0.1,\n)\n\n\n# Initialize specialized agents\ndata_extractor_agent = Agent(\n    agent_name=\"Data-Extractor\",\n    system_prompt=None,\n    llm=model,\n    max_loops=1,\n    autosave=True,\n    verbose=True,\n    dynamic_temperature_enabled=True,\n    saved_state_path=\"data_extractor_agent.json\",\n    user_name=\"pe_firm\",\n    retry_attempts=1,\n    context_length=200000,\n    output_type=\"string\",\n)\n\nsummarizer_agent = Agent(\n    agent_name=\"Document-Summarizer\",\n    system_prompt=None,\n    llm=model,\n    max_loops=1,\n    autosave=True,\n    verbose=True,\n    dynamic_temperature_enabled=True,\n    saved_state_path=\"summarizer_agent.json\",\n    user_name=\"pe_firm\",\n    retry_attempts=1,\n    context_length=200000,\n    output_type=\"string\",\n)\n\nfinancial_analyst_agent = Agent(\n    agent_name=\"Financial-Analyst\",\n    system_prompt=None,\n    llm=model,\n    max_loops=1,\n    autosave=True,\n    verbose=True,\n    dynamic_temperature_enabled=True,\n    saved_state_path=\"financial_analyst_agent.json\",\n    user_name=\"pe_firm\",\n    retry_attempts=1,\n    context_length=200000,\n    output_type=\"string\",\n)\n\nmarket_analyst_agent = Agent(\n    agent_name=\"Market-Analyst\",\n    system_prompt=None,\n    llm=model,\n    max_loops=1,\n    autosave=True,\n    verbose=True,\n    dynamic_temperature_enabled=True,\n    saved_state_path=\"market_analyst_agent.json\",\n    user_name=\"pe_firm\",\n    retry_attempts=1,\n    context_length=200000,\n    output_type=\"string\",\n)\n\noperational_analyst_agent = Agent(\n    agent_name=\"Operational-Analyst\",\n    system_prompt=None,\n    llm=model,\n    max_loops=1,\n    autosave=True,\n    verbose=True,\n    dynamic_temperature_enabled=True,\n    saved_state_path=\"operational_analyst_agent.json\",\n    user_name=\"pe_firm\",\n    retry_attempts=1,\n    context_length=200000,\n    output_type=\"string\",\n)\n\n# Initialize the SwarmRouter\nrouter = SequentialWorkflow(\n    name=\"pe-document-analysis-swarm\",\n    description=\"Analyze documents for private equity due diligence and investment decision-making\",\n    max_loops=1,\n    agents=[\n        data_extractor_agent,\n        summarizer_agent,\n        financial_analyst_agent,\n        market_analyst_agent,\n        operational_analyst_agent,\n    ],\n    output_type=\"all\",\n)\n\n# Advanced usage with configuration\nswarm = SwarmDeploy(\n    router,\n    max_workers=4,\n    # cache_backend=\"redis\"\n)\nswarm.start(\n    host=\"0.0.0.0\",\n    port=8000,\n    workers=4,\n)\n\n```\n\n## Advanced Usage \ud83d\udd27\n\n### Configuration Options\n\n```python\nswarm = SwarmDeploy(\n    workflow,\n    max_workers=4,\n    cache_backend=\"redis\",\n    ssl_config={\n        \"keyfile\": \"path/to/key.pem\",\n        \"certfile\": \"path/to/cert.pem\"\n    }\n)\n```\n\n\n\n## API Reference \ud83d\udcda\n\n### SwarmInput Model\n\n```python\nclass SwarmInput(BaseModel):\n    task: str          # Task description\n    img: Optional[str] # Optional image input\n    priority: int      # Task priority (0-10)\n```\n\n### API Endpoints\n\n- **POST** `/v1/swarms/completions/{callable_name}`\n  - Execute a task with the specified swarm\n  - Returns: SwarmOutput or SwarmBatchOutput\n\n### Example Request\n\n```bash\ncurl -X POST \"http://localhost:8000/v1/swarms/completions/document-analysis\" \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\"task\": \"Analyze financial report\", \"priority\": 5}'\n```\n\n## Monitoring and Logging \ud83d\udcca\n\nSwarmDeploy provides built-in monitoring capabilities:\n\n- Real-time task execution stats\n- Error tracking and reporting\n- Performance metrics\n- Task history and audit logs\n\n## Error Handling \ud83d\udee1\ufe0f\n\nThe system includes comprehensive error handling:\n\n```python\ntry:\n    result = await swarm.run(task)\nexcept Exception as e:\n    error_output = SwarmOutput(\n        id=str(uuid.uuid4()),\n        status=\"error\",\n        execution_time=time.time() - start_time,\n        result=None,\n        error=str(e)\n    )\n```\n\n## Best Practices \ud83c\udfaf\n\n1. Always set appropriate task priorities\n2. Implement proper error handling\n3. Use clustering for high-availability\n4. Monitor system performance\n5. Regular maintenance and updates\n\n## Contributing \ud83e\udd1d\n\nContributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.\n\n## Support \ud83d\udcac\n\n- Email: kye@swarms.world\n- Discord: [Join our community](https://swarms.world/swarms)\n- Documentation: [https://docs.swarms.world](https://docs.swarms.world)\n\n## License \ud83d\udcc4\n\nMIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\nPowered by [swarms.ai](https://swarms.ai) \ud83d\ude80\n\nFor enterprise support and custom solutions, contact kye@swarms.world",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Swarm-Deploy - TGSC",
    "version": "0.0.4",
    "project_urls": {
        "Documentation": "https://github.com/The-Swarm-Corporation/SwarmDeploy",
        "Homepage": "https://github.com/The-Swarm-Corporation/SwarmDeploy",
        "Repository": "https://github.com/The-Swarm-Corporation/SwarmDeploy"
    },
    "split_keywords": [
        "artificial intelligence",
        " deep learning",
        " optimizers",
        " prompt engineering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1eeed0ca4821ddcdf065bf2323f8dff3082d98c76baaf6c6d5c1d505db205ed7",
                "md5": "9d0b291e82a39ec7e6c0fa0b3e839842",
                "sha256": "2f1e36d3afcbd37e3c3e9ebea07fc435b670c88824dabdc76b6bf708bffcdab1"
            },
            "downloads": -1,
            "filename": "swarm_deploy-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9d0b291e82a39ec7e6c0fa0b3e839842",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 10854,
            "upload_time": "2025-01-16T01:11:40",
            "upload_time_iso_8601": "2025-01-16T01:11:40.790044Z",
            "url": "https://files.pythonhosted.org/packages/1e/ee/d0ca4821ddcdf065bf2323f8dff3082d98c76baaf6c6d5c1d505db205ed7/swarm_deploy-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c403c0fcf270e492c1db27f5e7565baa09bac30cc310eac5075e05693f672f74",
                "md5": "1b5d8b2e6f8e8143eddd6f176c4b1e5e",
                "sha256": "048ddb1d121b631462245f85e030146ec6fee5969319a24d51645357654f2b97"
            },
            "downloads": -1,
            "filename": "swarm_deploy-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1b5d8b2e6f8e8143eddd6f176c4b1e5e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 12348,
            "upload_time": "2025-01-16T01:11:42",
            "upload_time_iso_8601": "2025-01-16T01:11:42.945263Z",
            "url": "https://files.pythonhosted.org/packages/c4/03/c0fcf270e492c1db27f5e7565baa09bac30cc310eac5075e05693f672f74/swarm_deploy-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-16 01:11:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "The-Swarm-Corporation",
    "github_project": "SwarmDeploy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "swarms",
            "specs": []
        },
        {
            "name": "asyncio",
            "specs": []
        },
        {
            "name": "uuid",
            "specs": []
        },
        {
            "name": "datetime",
            "specs": []
        },
        {
            "name": "typing",
            "specs": []
        },
        {
            "name": "orjson",
            "specs": []
        },
        {
            "name": "structlog",
            "specs": []
        },
        {
            "name": "aiocache",
            "specs": []
        },
        {
            "name": "fastapi",
            "specs": []
        },
        {
            "name": "prometheus_client",
            "specs": []
        },
        {
            "name": "pydantic",
            "specs": []
        },
        {
            "name": "rich",
            "specs": []
        }
    ],
    "lcname": "swarm-deploy"
}
        
Elapsed time: 0.52124s