Team Ai
Modelpublic

ParallelLLC/algorithmic_trading

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
27likes32downloads
agent_base.py24 linesDownload Raw Back to agentic_ai_system
1import abc2import logging3from typing import Dict, Any4 5class Agent(abc.ABC):6    def __init__(self, config: Dict[str, Any]):7        self.config = config8        self.logger = logging.getLogger(self.__class__.__name__)9        self.logger.info(f"Initialized {self.__class__.__name__}")10 11    @abc.abstractmethod12    def act(self, data: Any) -> Dict[str, Any]:13        """Produce an action given input data"""14        pass15    16    def log_action(self, action: Dict[str, Any]) -> None:17        """Log the action taken by the agent"""18        self.logger.info(f"Action taken: {action}")19    20    def log_error(self, error: Exception, context: str = "") -> None:21        """Log errors with context"""22        self.logger.error(f"Error in {self.__class__.__name__}: {error}", 23                         exc_info=True, extra={'context': context})24