Skip to main content

A thin wrapper for autogen library with optional ag2 support

Project description

auto-base

A thin wrapper for the ag2 library, providing a simplified interface for easy usage.

Installation

pip install auto-base

This will automatically install the required dependency ag2.

Usage

Basic Usage

from auto_base import AutoBase

# Create an instance of the wrapper
auto = AutoBase()

# Check if ag2 is available
print(f"ag2 available: {auto.ag2_available}")

# Access autogen attributes directly
print(auto.DEFAULT_MODEL)  # Access autogen constants

# Get raw autogen instance
autogen_raw = auto.autogen

Agent Creation

from auto_base import AutoBase

auto = AutoBase()

# Create AssistantAgent
assistant = auto.create_assistant_agent(
    name="assistant",
    system_message="You are a helpful AI assistant",
    llm_config={
        "temperature": 0.7,
        "config_list": [
            {"model": "gpt-4", "api_key": "YOUR_API_KEY"}
        ]
    }
)

# Create UserProxyAgent
user_proxy = auto.create_user_proxy_agent(
    name="user_proxy",
    code_execution_config={"use_docker": False},  # Disable docker for code execution
    human_input_mode="NEVER"  # No human input required
)

# Create GroupChat
groupchat = auto.create_group_chat(
    agents=[assistant, user_proxy],
    messages=[],
    max_round=5,
    speaker_selection_method="auto"
)

# Create GroupChatManager
groupchat_manager = auto.create_group_chat_manager(
    groupchat=groupchat,
    llm_config={
        "config_list": [
            {"model": "gpt-4", "api_key": "YOUR_API_KEY"}
        ]
    }
)

Configuration Management

from auto_base import AutoBase

auto = AutoBase()

# Load config from dotenv file
config_list = auto.config_list_from_dotenv(
    dotenv_file_path=".env"
)

# Load config from JSON file
# config_list = auto.config_list_from_json(
#     file_path="OAI_CONFIG_LIST.json",
#     filter_dict={"model": ["gpt-4", "gpt-3.5-turbo"]}
# )

# Get GPT-4 and GPT-3.5 config list
# config_list = auto.config_list_gpt4_gpt35()

Function Registration

from auto_base import AutoBase

auto = AutoBase()

# Define a function to register
def add_numbers(a, b):
    """Add two numbers together"""
    return a + b

# Register the function
user_proxy = auto.create_user_proxy_agent(name="user_proxy")
auto.register_function(
    func=add_numbers,
    callable_agent=user_proxy,
    name="add_numbers",
    description="Add two numbers together"
)

Initiating Chats

from auto_base import AutoBase

auto = AutoBase()

# Create agents
assistant = auto.create_assistant_agent(name="assistant", system_message="You are helpful")
user_proxy = auto.create_user_proxy_agent(name="user_proxy", human_input_mode="NEVER")

# Initiate a chat between two agents
result = auto.initiate_chat(
    sender=user_proxy,
    receiver=assistant,
    message="What is the capital of France?"
)

# Or with group chat
# groupchat = auto.create_group_chat(agents=[assistant, user_proxy])
# manager = auto.create_group_chat_manager(groupchat=groupchat)
# result = auto.initiate_group_chat(
#     group_chat_manager=manager,
#     message="What is the capital of France?"
# )

Features

  • Thin wrapper around autogen library with optional ag2 support
  • Simplified API for creating and managing autogen agents
  • Easy agent creation: AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager
  • Convenient configuration management
  • Simplified function registration for agent use
  • Easy chat initiation between agents
  • Optional ag2 integration (available if ag2 is installed)
  • Backward compatible with direct autogen access
  • Well-documented with usage examples

Development

Installation for Development

# Clone the repository
git clone https://github.com/yourusername/auto-base.git
cd auto-base

# Install in development mode
pip install -e .

Running Tests

python test_wrapper.py

License

MIT

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

auto_base-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

auto_base-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file auto_base-0.1.0.tar.gz.

File metadata

  • Download URL: auto_base-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for auto_base-0.1.0.tar.gz
Algorithm Hash digest
SHA256 386264ac68abf0cfb7cf433149cba7cbceb71fdc64abd0c83da86b85a66ba741
MD5 0a144422acd4038262bbb3ea84e9f150
BLAKE2b-256 3dba7882aeecf9b3c373d5df1a801df45ed40d9e0504e2ebb7c5c71b2dfeef8b

See more details on using hashes here.

File details

Details for the file auto_base-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: auto_base-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for auto_base-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68e44b3ed6ffc8897004424eab37371d2a586fdffb52e873e6c0d7e810267149
MD5 6eb7f481975c94a159a941709894f8c5
BLAKE2b-256 675ad0ccfe8f4849f6785496fe8c47206d6c3476ae99aa84d58c8e47a7e0b8d7

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