Skip to main content

Library for building AMP agents

Project description

AMP Agent

A Python library for building and deploying AMP agents with ease. This library provides the functionality needed to create, manage, and run AMP agents.

Features

  • Easy agent creation with base classes and interfaces
  • Built-in HTTP server with Flask integration
  • Token-based authentication and validation
  • Configuration management
  • Database integration with AsyncPG
  • Async/sync support
  • Logging and error handling
  • Semantic interest matching
  • Event subscription and listening
  • Agent setup and registration utilities
  • Swarm-based agent components

Modules

  • amp_agent: Core functionality for building and running agents
  • amp_setup: Configuration and setup utilities
  • semantic: Semantic interest matching and processing
  • subscription: Event subscription and listening
  • swarm_cell: Swarm-based agent components

Installation

You can install the package using pip:

pip install amp-agent

For development installation:

pip install -e ".[dev]"

For testing:

pip install -e ".[test]"

For documentation:

pip install -e ".[docs]"

For machine learning features (advanced semantic matching):

pip install -e ".[ml]"

You can combine multiple extras like this:

pip install -e ".[dev,ml]"

Quick Start

Here's a simple example of creating an AMP agent:

from amp_agent import AgentInterface
from amp_agent.amp_setup import ConfigManager

class MyAgent(AgentInterface):
    async def process_message(self, content: str, metadata: dict = None) -> str:
        return f"Processed: {content}"

# Setup configuration
config_manager = ConfigManager()
config = config_manager.load_config()

# Create and run server
from amp_agent.server import create_app
app = create_app()
app.run()

Development

  1. Clone the repository:
git clone https://github.com/theswarmhub/amp-agent.git
cd amp-agent
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install development dependencies:
pip install -e ".[dev]"
  1. Run tests:
pytest

Configuration

Create a .env file:

DATABASE_URL=postgresql://user:password@localhost:5432/dbname
JWT_SECRET_KEY=your-secret-key
DEBUG=True

Module Usage Examples

Core Features

from amp_agent import AgentInterface
from amp_agent.amp_setup import ConfigManager

# Create an agent
class MyAgent(AgentInterface):
    async def process_message(self, content: str, metadata: dict = None) -> str:
        return f"Processed: {content}"

# Load configuration
config_manager = ConfigManager()
config = config_manager.load_config()

Semantic Processing

from amp_agent.semantic import interest

# Define interests
@interest("code_review")
async def handle_code_review(content: str) -> str:
    return "Code review processed"

Event Subscription (Optional)

# Import the optional subscription module when needed
from amp_agent.subscription import AMPListener

# Create and start a listener
listener = AMPListener(config)
listener.start()

Swarm Components (Optional)

# Import the optional swarm_cell module when needed
from amp_agent.swarm_cell import SwarmCell

# Create a swarm cell
cell = SwarmCell(config)
cell.initialize()

Documentation

For detailed documentation, visit https://amp-agent.readthedocs.io/

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests
  5. Submit a pull request

License

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

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

amp_agent-0.1.3.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

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

amp_agent-0.1.3-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file amp_agent-0.1.3.tar.gz.

File metadata

  • Download URL: amp_agent-0.1.3.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for amp_agent-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f1f92d40890b7b7aa6e12538eaab5f300f8b88b00a8914643246e8f2693de910
MD5 f3ae601d195fa2e15571eaf18f0511bc
BLAKE2b-256 9eb5ecf268a3ec03e481f2a6d7325d4455ca2132358be989a69367880ff5df8a

See more details on using hashes here.

File details

Details for the file amp_agent-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: amp_agent-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 43.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for amp_agent-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1a7c16e66a49e4390cefe1f0c38255e19a445367ef9e92242bca468a66806d0d
MD5 5e67bfd9f21600fc6896091103ed90dd
BLAKE2b-256 93de1b81559b58171643d56b2b2880b43d3a77e24b78192e7b2d21bb287500bd

See more details on using hashes here.

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