Skip to main content

A high-level library for building and managing teams of AutoGen agents

Project description

AskTheApi Team Builder

PyPI version License: MIT Python Versions

A high-level Python library for building and managing networks of autonomous agents that collaborate to solve complex tasks. It’s designed to work seamlessly with APIs defined using the OpenAPI standard. The library provides a clean, type-safe interface for creating, configuring, and running teams of agents, making it easy to orchestrate multi-agent workflows with minimal boilerplate.

Features

  • 🚀 Effortless Agent Network Creation Quickly build agent networks with custom tools and capabilities based on OpenAPI specifications.

  • 🤝 Team-Based Collaboration Easily define agent teams with automatic coordination handled by a built-in planning agent.

  • 📡 Streaming Interactions Stream agent communication in real-time for more dynamic and responsive workflows.

  • 🔧 Built-in HTTP Client Simplify tool implementation with an integrated HTTP client ready to call external APIs.

  • ✨ Type Safety with Pydantic Leverage Pydantic models for robust data validation and clear type definitions.

  • 🎯 Clean and Intuitive API Designed for developers—minimal boilerplate, maximum clarity.

Installation

pip install asktheapi-team-builder

Quick Start

Here's how to use the package:

1. Create agents from OpenAPI spec

from asktheapi_team_builder import TeamBuilder, Agent, Tool, Message, APISpecHandler
from typing import List
async def create_agents_from_spec():
    # Initialize handlers
    api_spec_handler = APISpecHandler()
    
    # Download and parse OpenAPI spec
    spec_content = await api_spec_handler.download_url_spec("https://api.example.com/openapi.json")
    
    # Classify endpoints into logical groups
    classification_result = await api_spec_handler.classify_spec(
        spec_content
    )
    
    # Generate agents for each group
    agents = []
    for group_spec in classification_result.specs:
        agent_result = await api_spec_handler.generate_agent_for_group(
            group_spec,
            spec_content
        )
        agents.append(agent_result)
    
    return agents

2. Build and run a team

async def run_agent_team(agents: List[Agent], query: str):
    # Initialize team builder
    team_builder = TeamBuilder(
        model="gpt-4",
        model_config={"temperature": 0.7}
    )
    
    # Build the team
    team = await team_builder.build_team(agents)
    
    # Create messages
    messages = [
        Message(
            role="user",
            content=query
        )
    ]
    
    # Run the team with streaming
    async for event in team_builder.run_team(team, messages, stream=True):
        if isinstance(event, ChatMessage):
            print(f"{event.source}: {event.content}")

Example usage

async def main():
    # Create agents from spec
    api_agents = await create_agents_from_spec()
    
    # Combine with manual agents
    all_agents = [weather_agent] + api_agents
    
    # Run the team
    await run_agent_team(
        all_agents,
        "What's the weather like in London and how might it affect local businesses?"
    )

Custom Headers and Configuration

You can configure the team builder with custom headers and model settings:

team_builder = TeamBuilder(
    model="gpt-4",
    model_config={
        "temperature": 0.7,
        "default_headers": {
            "Authorization": "Bearer your-token",
            "Custom-Header": "custom-value"
        }
    }
)

# Run team with extra headers for specific requests
team = await team_builder.build_team(agents)
result = await team_builder.run_team(
    team,
    messages,
    extra_headers={"Request-ID": "123"}
)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Clone the repository
git clone https://github.com/alexalbala/asktheapi-team-builder.git
cd asktheapi-team-builder

# Install dependencies
pip install -e ".[dev]"

# Run tests
pytest

License

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

Acknowledgments

  • Built on top of Microsoft's AutoGen
  • Inspired by the need for a higher-level interface for agent team management

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

asktheapi_team_builder-0.2.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

asktheapi_team_builder-0.2.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file asktheapi_team_builder-0.2.2.tar.gz.

File metadata

  • Download URL: asktheapi_team_builder-0.2.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for asktheapi_team_builder-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e7012949faae6d7cf8757d83f8a2da11c836d089653f8f4e1d8a6251e782c0ca
MD5 19f07abb1cd52d10291f8530fb4b0e09
BLAKE2b-256 4a12d07319dab2ac451aa83f4d5adebd367208a7b0342feaac70bc87f6887563

See more details on using hashes here.

File details

Details for the file asktheapi_team_builder-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for asktheapi_team_builder-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 678f242cf07f6989bcbfad9be41cff8eb7f0b64a881509c240304c994c3f16a6
MD5 36cce12e9be23392c0a80c85d7c4bcda
BLAKE2b-256 5aeaddd0ef9c38f731267e575f739c5953b1bdaa864e97e1049c525bfe9392e7

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