File size: 3,223 Bytes
20d720d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"""
Agents module for Personal Coach CrewAI Application
Contains all agent definitions and orchestration logic
"""

from typing import TYPE_CHECKING

# Version info
__version__ = "1.0.0"
__author__ = "Personal Coach AI Team"

# Lazy imports to avoid circular dependencies
if TYPE_CHECKING:
    from .crew_agents import (
        ConversationHandlerAgent,
        WisdomAdvisorAgent,
        ResponseValidatorAgent,
        InteractionManagerAgent,
        PersonalCoachCrew
    )

# Define what should be imported with "from agents import *"
__all__ = [
    # Main agents
    "ConversationHandlerAgent",
    "WisdomAdvisorAgent", 
    "ResponseValidatorAgent",
    "InteractionManagerAgent",
    
    # Crew orchestrator
    "PersonalCoachCrew",
    
    # Agent utilities
    "create_all_agents",
    "get_agent_by_role",
    
    # Constants
    "AGENT_ROLES",
    "AGENT_GOALS"
]

# Agent role constants
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
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"
}

# Lazy loading functions
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

# Module initialization message (only in debug mode)
import os
if os.getenv("DEBUG_MODE", "false").lower() == "true":
    print(f"Agents module v{__version__} initialized")