jarondon82's picture
Initial commit for EmotionMirror finalproject
f7e620e
"""
Base agent class for EmotionMirror application.
Provides the foundation for all agent implementations.
"""
from abc import ABC, abstractmethod
import logging
from typing import Dict, Any
class BaseAgent(ABC):
"""Base class for all agents in EmotionMirror"""
def __init__(self, name: str, description: str = ""):
"""
Initialize the base agent.
Args:
name: Name of the agent
description: Description of the agent's purpose
"""
self.name = name
self.description = description
self.logger = logging.getLogger(f"agent.{name}")
@abstractmethod
def process(self, data: Dict[str, Any]) -> Dict[str, Any]:
"""
Process data and return a result.
Args:
data: Input data to process
Returns:
Dictionary with processing results
"""
pass
def log_activity(self, message: str, level: str = 'info') -> None:
"""
Log agent activity.
Args:
message: Log message
level: Log level (debug, info, warning, error, critical)
"""
log_methods = {
'debug': self.logger.debug,
'info': self.logger.info,
'warning': self.logger.warning,
'error': self.logger.error,
'critical': self.logger.critical
}
log_method = log_methods.get(level.lower(), self.logger.info)
log_method(f"[{self.name}] {message}")
def __str__(self) -> str:
"""String representation of the agent"""
return f"Agent({self.name}): {self.description}"