The Multi-Agent AI System provides a comprehensive API for interacting with specialized AI agents through a coordinated workflow system.
The main orchestrator that manages workflow execution and agent communication.
process(input_data: Dict[str, Any]) -> Dict[str, Any]Processes a task through the multi-agent workflow.
Parameters:
input_data: Dictionary containing task information
task (str): The main task descriptioncontext (dict, optional): Additional context informationReturns:
success (bool): Whether the workflow completed successfullyresult (dict): Workflow execution resultsworkflow_plan (dict): The executed workflow planagent (str): Agent identifierExample:
input_data = {
"task": "Explain machine learning basics",
"context": {"audience": "beginners"}
}
result = await coordinator.process(input_data)
get_all_agent_metrics() -> Dict[str, Any]Returns performance metrics for all agents in the system.
health_check_all_agents() -> Dict[str, Any]Performs health checks on all agents and returns system status.
Specialized agent for information gathering and analysis.
process(input_data: Dict[str, Any]) -> Dict[str, Any]Performs research based on the input query.
Parameters:
input_data: Dictionary containing research parameters
query (str): Research queryresearch_type (str): Type of research (“general”, “factual”, “analytical”, “comparative”)Returns:
success (bool): Whether research completed successfullyfindings (str): Research findingsconfidence (str): Confidence level (“high”, “medium”, “low”)Specialized agent for content generation and refinement.
process(input_data: Dict[str, Any]) -> Dict[str, Any]Generates content based on the input request.
Parameters:
input_data: Dictionary containing content parameters
content_request (str): Content generation requestcontent_type (str): Type of content (“explanation”, “summary”, “analysis”, “creative”, “technical”)style (str): Writing style (“professional”, “casual”, “academic”, “technical”, “creative”)length (str): Content length (“short”, “medium”, “long”, “extended”)Returns:
success (bool): Whether content generation completed successfullycontent (str): Generated contentword_count (int): Number of words in generated contentrefine_content(content: str, refinement_instructions: str) -> Dict[str, Any]Refines existing content based on specific instructions.
Specialized agent for quality assurance and safety validation.
process(input_data: Dict[str, Any]) -> Dict[str, Any]Validates content for safety and quality.
Parameters:
input_data: Dictionary containing validation parameters
content (str): Content to validatevalidation_type (str): Type of validation (“safety”, “quality”, “technical”, “comprehensive”)strict_mode (bool): Whether to use strict validation rulesReturns:
success (bool): Whether validation completed successfullyvalidation_passed (bool): Whether content passed validationsafety_score (float): Safety score (0-100)quality_score (float): Quality score (0-100)issues (list): List of identified issuesrecommendations (list): Improvement recommendationsManages system configuration with validation and environment variable support.
openai_api_key (str): OpenAI API key (required)openai_model (str): Model to use (default: “gpt-4”)max_retries (int): Maximum retry attempts (default: 3)timeout_seconds (int): Request timeout (default: 30)log_level (str): Logging level (default: “INFO”)enable_input_validation (bool): Enable input validation (default: True)enable_output_filtering (bool): Enable output filtering (default: True)Provides comprehensive system health monitoring.
check_system_health() -> Dict[str, Any]Performs comprehensive system health check including:
get_system_metrics() -> Dict[str, Any]Returns current system resource metrics.
The system implements comprehensive error handling:
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"])
from src.agents.research_agent import ResearchAgent
research_agent = ResearchAgent(config, logger)
# Factual research
research_input = {
"query": "Current renewable energy statistics",
"research_type": "factual"
}
result = await research_agent.process(research_input)
from src.agents.content_agent import ContentAgent
content_agent = ContentAgent(config, logger)
# Generate technical documentation
content_input = {
"content_request": "API documentation for user authentication",
"content_type": "technical",
"style": "technical",
"length": "long"
}
result = await content_agent.process(content_input)
from src.agents.validation_agent import ValidationAgent
validation_agent = ValidationAgent(config, logger)
# Comprehensive validation
validation_input = {
"content": "Content to validate...",
"validation_type": "comprehensive",
"strict_mode": True
}
result = await validation_agent.process(validation_input)