Spaces:
Runtime error
Runtime error
| from typing import Dict, List | |
| from crewai import Agent | |
| import logging | |
| from utils.log_manager import LogManager | |
| class ConversationAgent: | |
| """Agent specialized in therapeutic conversations""" | |
| def __init__(self, model_config: Dict, **kwargs): | |
| self.model_config = model_config | |
| self.log_manager = LogManager() | |
| self.logger = self.log_manager.get_agent_logger("conversation") | |
| # Initialize the CrewAI agent | |
| self.agent = Agent( | |
| role="Therapeutic Conversation Specialist", | |
| goal="Guide therapeutic conversations and provide emotional support", | |
| backstory="""I am an AI agent specialized in therapeutic conversation techniques. | |
| I use evidence-based approaches to provide emotional support and guidance while maintaining | |
| appropriate boundaries and recognizing when to escalate to crisis intervention.""", | |
| verbose=True, | |
| allow_delegation=False, | |
| tools=[] # Tools will be added as needed | |
| ) | |
| self.logger.info("Conversation Agent initialized") | |
| def process_message(self, message: str, context: Dict = None) -> Dict: | |
| """Process a message and return a therapeutic response""" | |
| self.logger.info("Processing message") | |
| context = context or {} | |
| try: | |
| # For now, return a simple response since we haven't set up the LLM | |
| response = "I understand and I'm here to help. Could you tell me more about how you're feeling?" | |
| return { | |
| "message": response, | |
| "agent_type": "conversation", | |
| "task_type": "therapeutic_dialogue" | |
| } | |
| except Exception as e: | |
| self.logger.error(f"Error processing message: {str(e)}") | |
| return { | |
| "message": "I apologize, but I encountered an error. Let me try a different approach.", | |
| "agent_type": "conversation", | |
| "task_type": "error_recovery" | |
| } | |
| def get_status(self) -> Dict: | |
| """Get the current status of the agent""" | |
| return { | |
| "type": "conversation", | |
| "ready": True, | |
| "tools_available": len(self.agent.tools) | |
| } |