|
""" |
|
Agents module for Personal Coach CrewAI Application |
|
Contains all agent definitions and orchestration logic |
|
""" |
|
|
|
from typing import TYPE_CHECKING |
|
|
|
|
|
__version__ = "1.0.0" |
|
__author__ = "Personal Coach AI Team" |
|
|
|
|
|
if TYPE_CHECKING: |
|
from .crew_agents import ( |
|
ConversationHandlerAgent, |
|
WisdomAdvisorAgent, |
|
ResponseValidatorAgent, |
|
InteractionManagerAgent, |
|
PersonalCoachCrew |
|
) |
|
|
|
|
|
__all__ = [ |
|
|
|
"ConversationHandlerAgent", |
|
"WisdomAdvisorAgent", |
|
"ResponseValidatorAgent", |
|
"InteractionManagerAgent", |
|
|
|
|
|
"PersonalCoachCrew", |
|
|
|
|
|
"create_all_agents", |
|
"get_agent_by_role", |
|
|
|
|
|
"AGENT_ROLES", |
|
"AGENT_GOALS" |
|
] |
|
|
|
|
|
AGENT_ROLES = { |
|
"CONVERSATION_HANDLER": "Empathetic Conversation Handler", |
|
"WISDOM_ADVISOR": "Knowledge and Wisdom Advisor", |
|
"RESPONSE_VALIDATOR": "Response Quality Validator", |
|
"INTERACTION_MANAGER": "Interaction Flow Manager" |
|
} |
|
|
|
|
|
AGENT_GOALS = { |
|
"CONVERSATION_HANDLER": "Understand user's emotional state and needs through empathetic dialogue", |
|
"WISDOM_ADVISOR": "Provide relevant wisdom and practical guidance from knowledge base", |
|
"RESPONSE_VALIDATOR": "Ensure responses are safe, appropriate, and supportive", |
|
"INTERACTION_MANAGER": "Manage conversation flow and deliver responses effectively" |
|
} |
|
|
|
|
|
def create_all_agents(config): |
|
""" |
|
Factory function to create all agents with proper configuration |
|
|
|
Args: |
|
config: Configuration object with necessary settings |
|
|
|
Returns: |
|
dict: Dictionary of initialized agents |
|
""" |
|
from .crew_agents import ( |
|
ConversationHandlerAgent, |
|
WisdomAdvisorAgent, |
|
ResponseValidatorAgent, |
|
InteractionManagerAgent |
|
) |
|
|
|
agents = { |
|
"conversation_handler": ConversationHandlerAgent(config), |
|
"wisdom_advisor": WisdomAdvisorAgent(config), |
|
"response_validator": ResponseValidatorAgent(config), |
|
"interaction_manager": InteractionManagerAgent(config) |
|
} |
|
|
|
return agents |
|
|
|
def get_agent_by_role(role: str, config): |
|
""" |
|
Get a specific agent by its role |
|
|
|
Args: |
|
role: Agent role constant |
|
config: Configuration object |
|
|
|
Returns: |
|
Agent instance or None |
|
""" |
|
from .crew_agents import ( |
|
ConversationHandlerAgent, |
|
WisdomAdvisorAgent, |
|
ResponseValidatorAgent, |
|
InteractionManagerAgent |
|
) |
|
|
|
agent_map = { |
|
"CONVERSATION_HANDLER": ConversationHandlerAgent, |
|
"WISDOM_ADVISOR": WisdomAdvisorAgent, |
|
"RESPONSE_VALIDATOR": ResponseValidatorAgent, |
|
"INTERACTION_MANAGER": InteractionManagerAgent |
|
} |
|
|
|
agent_class = agent_map.get(role) |
|
if agent_class: |
|
return agent_class(config) |
|
return None |
|
|
|
|
|
import os |
|
if os.getenv("DEBUG_MODE", "false").lower() == "true": |
|
print(f"Agents module v{__version__} initialized") |