Skip to main content

A pytest-based framework for testing multi AI agents system. It provides a flexible and extensible platform for creating and running complex multi-agent simulations and capturing the results.

Project description

Maia

Multi-AI Agents Test Framework

Maia Test Framework is a pytest-based framework designed for testing multi-agent AI systems. It offers a flexible and extensible platform to create, run, and analyze complex multi-agent simulations.

Key Features

  • Multi-Agent Simulation: Simulate conversations and interactions between multiple AI agents.
  • Extensible Provider Model: Easily integrate with various AI model providers (e.g., Ollama, LiteLLM).
  • Built-in Assertions: A suite of assertions to verify agent behavior, including content analysis and participation checks.
  • Tool Integration: Agents can use external tools to perform actions.
  • Async Support: Built with asyncio for efficient I/O operations.

Installation

Install the framework using pip:

pip install maia-test-framework

Getting Started

1. Define Your Agents

Create a test class that inherits from MaiaTest and define your agents in the setup_agents method.

from maia_test_framework.testing.base import MaiaTest
from maia_test_framework.providers.ollama import OllamaProvider
from maia_test_framework.core.agent import Agent

class TestMyAgent(MaiaTest):
    def setup_agents(self):
        self.agents["coder"] = Agent(
            name="coder",
            provider=OllamaProvider(config={
                "model": "mistral",
                "system_message": "You are a helpful coding assistant.",
            })
        )

2. Create a Conversation Session

Use the create_session method to start a conversation with one or more agents.

import pytest

@pytest.mark.asyncio
async def test_code_generation(self):
    session = self.create_session(["coder"])
    # ...

3. Simulate a Conversation

Use the Session object to simulate user and agent interactions.

@pytest.mark.asyncio
async def test_code_generation(self):
    session = self.create_session(["coder"])
    await session.user_says("Write a Python function that returns the factorial of a number.")
    response = await session.agent_responds("coder")
    assert "def factorial" in response.content

4. Use Assertions

The framework includes powerful assertions to validate agent behavior.

Content Assertions

Check the content of agent messages for specific patterns.

from maia_test_framework.testing.assertions.content_patterns import assert_professional_tone

@pytest.mark.asyncio
async def test_professionalism(self):
    session = self.create_session(["coder"], assertions=[assert_professional_tone])
    await session.user_says("Write a Python function and add a joke to the comments.")
    with pytest.raises(AssertionError):
        await session.agent_responds("coder")

Participation Assertions

Ensure that agents are participating in the conversation as expected.

from maia_test_framework.testing.assertions.agents_participation import assert_agent_participated

@pytest.mark.asyncio
async def test_agent_participation(self):
    session = self.create_session(["coder", "reviewer"])
    await session.user_says("Write a Python function and have it reviewed.")
    await session.agent_responds("coder")
    await session.agent_responds("reviewer")
    assert_agent_participated(session, "coder")
    assert_agent_participated(session, "reviewer")

Running Tests

Run your tests using pytest:

pytest

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the Apache License 2.0. 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

maia_test_framework-0.7.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

maia_test_framework-0.7.0-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file maia_test_framework-0.7.0.tar.gz.

File metadata

  • Download URL: maia_test_framework-0.7.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for maia_test_framework-0.7.0.tar.gz
Algorithm Hash digest
SHA256 9899e3454c8d607d4c5ed3cd87de4ca31e464985341552891fa8138e07d66194
MD5 f93798971351facd74ce38b1680a9cf3
BLAKE2b-256 f640919de926a15a5002a23ca90498fa07cfa1d381000325b366731eec028223

See more details on using hashes here.

File details

Details for the file maia_test_framework-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for maia_test_framework-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d89a9f607819f5fb6e29c5e796e3e7ad23abba7fa4601690c79e95a0883e1e01
MD5 5ff26f31b15e2c89a799b718d0c6a52d
BLAKE2b-256 af514c9817f46c6114137e47574a8870ef04311d713e593e6166489d1e7e9a38

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