Skip to main content

A framework for building multi-agent systems using AWS Bedrock

Project description

🤖 Bedrock Swarm

PyPI version Python Documentation Status Tests Coverage License: MIT Code style: black

Bedrock Swarm Logo

A powerful framework for building multi-agent systems using AWS Bedrock. Create, manage, and orchestrate AI agents powered by state-of-the-art language models.

✨ Features

  • 🚀 Easy-to-use API - Create and manage AI agents with just a few lines of code
  • 🤝 Multi-Agent Support - Build complex systems with multiple cooperating agents
  • 🔧 Extensible Tool System - Create and add custom tools to enhance agent capabilities
  • 💾 Memory Management - Built-in conversation memory for persistent context
  • 🔒 Type Safety - Full type hints and runtime type checking
  • 📚 Comprehensive Documentation - Detailed guides and API reference

🛠️ Installation

# Basic installation
pip install bedrock-swarm

# With development dependencies
pip install "bedrock-swarm[dev]"

# With documentation dependencies
pip install "bedrock-swarm[docs]"

🚀 Quick Start

Here's a simple example using an agent with the built-in CurrentTimeTool:

from bedrock_swarm.agency.agency import Agency
from bedrock_swarm.config import AWSConfig
from bedrock_swarm.tools.time import CurrentTimeTool

# Create AWS config
aws_config = AWSConfig(region="us-east-1")

# Create agency
agency = Agency(aws_config=aws_config)

# Create an agent with the time tool
agent = agency.add_agent(
    name="time_agent",
    model_id="us.anthropic.claude-3-5-sonnet-20241022-v2:0",
    tools=[CurrentTimeTool()],
    instructions="You are a helpful assistant that can tell the current time in different formats and timezones.",
)

# Create a thread
thread = agency.create_thread("time_agent")

# Example conversation
messages = [
    "What time is it now?",
    "What time is it in UTC?",
    "What's the current date in YYYY-MM-DD format?",
]

for message in messages:
    response = agency.execute(thread.thread_id, message)
    print(f"User: {message}")
    print(f"Assistant: {response.content}\n")

🎯 Examples

Check out our examples directory for ready-to-use examples:

  1. Simple Time Example - A basic example showing how to:
    • Configure AWS and create an agent
    • Use the CurrentTimeTool for time-related queries
    • Handle different time formats and timezones

To run the examples:

  1. Install with development dependencies:
pip install "bedrock-swarm[dev]"
  1. Set up your environment variables:
export AWS_REGION=us-west-2
export AWS_PROFILE=default
  1. Run an example:
python examples/simple_time.py

🛠️ Built-in Tools

CurrentTimeTool

A versatile tool for getting the current time and date in various formats and timezones:

from bedrock_swarm.tools.time import CurrentTimeTool

time_tool = CurrentTimeTool()

# Get current time in ISO format
current_time = time_tool.execute()  # Returns: "2024-03-14T15:09:26"

# Get time in specific format
formatted_time = time_tool.execute(
    format="%Y-%m-%d %H:%M:%S"
)  # Returns: "2024-03-14 15:09:26"

# Get time in specific timezone
utc_time = time_tool.execute(
    timezone="UTC",
    format="%H:%M:%S"
)  # Returns: "15:09:26"

# Get formatted date in specific timezone
tokyo_date = time_tool.execute(
    timezone="Asia/Tokyo",
    format="%A, %B %d, %Y"
)  # Returns: "Thursday, March 14, 2024"

🔧 Creating Custom Tools

You can create your own tools by extending the BaseTool class:

from typing import Any, Dict
from bedrock_swarm.tools.base import BaseTool

class MyCustomTool(BaseTool):
    @property
    def name(self) -> str:
        return "my_tool"

    @property
    def description(self) -> str:
        return "Description of my tool"

    def get_schema(self) -> Dict[str, Any]:
        return {
            "name": self.name,
            "description": self.description,
            "parameters": {
                "type": "object",
                "properties": {
                    "param1": {"type": "string"},
                },
                "required": ["param1"]
            }
        }

    def _execute_impl(self, **kwargs: Any) -> str:
        # Implement your tool logic here
        return f"Tool executed with {kwargs}"

📖 Documentation

Visit our documentation for:

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

📬 Contact

Logging

Bedrock Swarm includes built-in logging capabilities to help you monitor and debug your applications. By default, logging is set to WARNING level.

from bedrock_swarm import configure_logging

# Enable debug logging
configure_logging(level="DEBUG")

For detailed information about logging configuration and best practices, see the Logging Guide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bedrock_swarm-0.1.5.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bedrock_swarm-0.1.5-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file bedrock_swarm-0.1.5.tar.gz.

File metadata

  • Download URL: bedrock_swarm-0.1.5.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for bedrock_swarm-0.1.5.tar.gz
Algorithm Hash digest
SHA256 eb644f0ba7dbff7d8b33bea37ba5f663e2921ecbf2ff05dcaaacf1b0d0479f38
MD5 4d1f36055ed47bb607cdabba4558ad1e
BLAKE2b-256 19f1f2a2b12072e1e6f4273626c1a24347f44f764b802481509c341791f08bf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for bedrock_swarm-0.1.5.tar.gz:

Publisher: release.yml on sandrich/bedrock-swarm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bedrock_swarm-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: bedrock_swarm-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for bedrock_swarm-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3d74c3e878671dd055d2b0974d494b62147641e272ff717bf3a7b65bed94961f
MD5 58c46fc91c3e581bc436a390a40a8a79
BLAKE2b-256 556c623f8c42ab352204a0dcf4f1c4c810e5d7e820b1f9caf64965e558908d81

See more details on using hashes here.

Provenance

The following attestation bundles were made for bedrock_swarm-0.1.5-py3-none-any.whl:

Publisher: release.yml on sandrich/bedrock-swarm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page