|
13 | 13 | from common.auth.azure_credential_utils import get_azure_credential |
14 | 14 |
|
15 | 15 | # Import agent factory and the new AppConfig |
16 | | -from kernel_agents.agent_factory import AgentFactory |
17 | | -from kernel_agents.group_chat_manager import GroupChatManager |
18 | | -from kernel_agents.hr_agent import HrAgent |
19 | | -from kernel_agents.human_agent import HumanAgent |
20 | | -from kernel_agents.marketing_agent import MarketingAgent |
21 | | -from kernel_agents.planner_agent import PlannerAgent |
22 | | -from kernel_agents.procurement_agent import ProcurementAgent |
23 | | -from kernel_agents.product_agent import ProductAgent |
24 | | -from kernel_agents.tech_support_agent import TechSupportAgent |
25 | | -from common.models.messages_kernel import AgentType |
26 | 16 | from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent |
27 | 17 |
|
28 | 18 | logging.basicConfig(level=logging.INFO) |
|
32 | 22 | azure_agent_instances: Dict[str, Dict[str, AzureAIAgent]] = {} |
33 | 23 |
|
34 | 24 |
|
35 | | -async def get_agents(session_id: str, user_id: str) -> Dict[str, Any]: |
36 | | - """ |
37 | | - Get or create agent instances for a session. |
38 | | -
|
39 | | - Args: |
40 | | - session_id: The session identifier |
41 | | - user_id: The user identifier |
42 | | -
|
43 | | - Returns: |
44 | | - Dictionary of agent instances mapped by their names |
45 | | - """ |
46 | | - cache_key = f"{session_id}_{user_id}" |
47 | | - |
48 | | - if cache_key in agent_instances: |
49 | | - return agent_instances[cache_key] |
50 | | - |
51 | | - try: |
52 | | - # Create all agents for this session using the factory |
53 | | - raw_agents = await AgentFactory.create_all_agents( |
54 | | - session_id=session_id, |
55 | | - user_id=user_id, |
56 | | - temperature=0.0, # Default temperature |
57 | | - ) |
58 | | - |
59 | | - # Get mapping of agent types to class names |
60 | | - agent_classes = { |
61 | | - AgentType.HR: HrAgent.__name__, |
62 | | - AgentType.PRODUCT: ProductAgent.__name__, |
63 | | - AgentType.MARKETING: MarketingAgent.__name__, |
64 | | - AgentType.PROCUREMENT: ProcurementAgent.__name__, |
65 | | - AgentType.TECH_SUPPORT: TechSupportAgent.__name__, |
66 | | - AgentType.GENERIC: TechSupportAgent.__name__, |
67 | | - AgentType.HUMAN: HumanAgent.__name__, |
68 | | - AgentType.PLANNER: PlannerAgent.__name__, |
69 | | - AgentType.GROUP_CHAT_MANAGER: GroupChatManager.__name__, |
70 | | - } |
71 | | - |
72 | | - # Convert to the agent name dictionary format used by the rest of the app |
73 | | - agents = { |
74 | | - agent_classes[agent_type]: agent for agent_type, agent in raw_agents.items() |
75 | | - } |
76 | | - |
77 | | - # Cache the agents |
78 | | - agent_instances[cache_key] = agents |
79 | | - |
80 | | - return agents |
81 | | - except Exception as e: |
82 | | - logging.error(f"Error creating agents: {str(e)}") |
83 | | - raise |
84 | | - |
85 | | - |
86 | 25 | async def rai_success(description: str, is_task_creation: bool) -> bool: |
87 | 26 | """ |
88 | 27 | Checks if a description passes the RAI (Responsible AI) check. |
|
0 commit comments