API Reference

Overview

The Multi-Agent AI System provides a comprehensive API for interacting with specialized AI agents through a coordinated workflow system.

Note: This is a comprehensive API reference. For the complete documentation with all details, see the full API documentation.

CoordinatorAgent

The main orchestrator that manages workflow execution and agent communication.

process(input_data)

Processes a task through the multi-agent workflow.


# Example usage
input_data = {
    "task": "Explain machine learning basics",
    "context": {"audience": "beginners"}
}
result = await coordinator.process(input_data)
                        
Parameters:
  • input_data (dict): Task information with 'task' and optional 'context'
Returns:
  • success (bool): Whether workflow completed successfully
  • result (dict): Workflow execution results
  • workflow_plan (dict): The executed workflow plan

ResearchAgent

Specialized agent for information gathering and analysis.


# Research example
research_input = {
    "query": "Current renewable energy statistics",
    "research_type": "factual"
}
result = await research_agent.process(research_input)
                        

Research Types:

  • general: Comprehensive research on any topic
  • factual: Focus on verifiable facts and data
  • analytical: Deep analysis with insights
  • comparative: Compare multiple options or perspectives

ContentAgent

Specialized agent for content generation and refinement.


# Content generation example
content_input = {
    "content_request": "API documentation for user authentication",
    "content_type": "technical",
    "style": "technical",
    "length": "long"
}
result = await content_agent.process(content_input)
                        

Content Types:

  • explanation: Clear, structured explanations
  • summary: Concise summaries
  • analysis: Detailed analysis
  • creative: Creative content
  • technical: Technical documentation

ValidationAgent

Specialized agent for quality assurance and safety validation.


# Validation example
validation_input = {
    "content": "Content to validate...",
    "validation_type": "comprehensive",
    "strict_mode": True
}
result = await validation_agent.process(validation_input)
                        

Validation Types:

  • safety: Safety and content filtering
  • quality: Quality and coherence checks
  • technical: Technical accuracy validation
  • comprehensive: All validation types

Configuration

System configuration with validation and environment variable support.


from src.core.config import Config

# Initialize with custom values
config = Config(
    openai_api_key="your_api_key",
    max_retries=5,
    timeout_seconds=60
)
                        

Key Parameters:

Parameter Type Default Description
openai_api_key str - OpenAI API key (required)
max_retries int 3 Maximum retry attempts
timeout_seconds int 30 Request timeout
log_level str INFO Logging level

Health Monitoring

Comprehensive system health monitoring and metrics collection.


from src.core.health import HealthChecker

health_checker = HealthChecker(config)
health_status = health_checker.check_system_health()

# Get system metrics
metrics = health_checker.get_system_metrics()
                        

Usage Examples

Basic Usage


from src.agents.coordinator_agent import CoordinatorAgent
from src.core.config import Config
from src.utils.logger import setup_logger

# Initialize system
config = Config(openai_api_key="your_api_key")
logger = setup_logger()
coordinator = CoordinatorAgent(config, logger)

# Process a task
input_data = {"task": "Explain renewable energy benefits"}
result = await coordinator.process(input_data)

if result["success"]:
    print(result["result"]["final_output"])
                        

Error Handling


try:
    result = await coordinator.process(input_data)
    if result["success"]:
        # Handle successful result
        output = result["result"]["final_output"]
    else:
        # Handle workflow failure
        error = result.get("error", "Unknown error")
        print(f"Workflow failed: {error}")
except Exception as e:
    # Handle system error
    print(f"System error: {e}")