|
7 | 7 |
|
8 | 8 | # agent_framework imports |
9 | 9 | from agent_framework.azure import AzureOpenAIChatClient |
| 10 | + |
10 | 11 | from agent_framework import ChatMessage, ChatOptions |
11 | 12 | from agent_framework._workflows import MagenticBuilder |
12 | 13 | from agent_framework._workflows._magentic import AgentRunResponseUpdate # type: ignore |
|
24 | 25 | from af.config.settings import connection_config, orchestration_config |
25 | 26 | from af.models.messages import WebsocketMessageType |
26 | 27 | from af.orchestration.human_approval_manager import HumanApprovalMagenticManager |
27 | | -from af.magentic_agents.magentic_agent_factory import ( |
28 | | - MagenticAgentFactory, |
29 | | - ) |
| 28 | +from af.magentic_agents.magentic_agent_factory import MagenticAgentFactory |
30 | 29 |
|
31 | 30 | class OrchestrationManager: |
32 | 31 | """Manager for handling orchestration logic using agent_framework Magentic workflow.""" |
@@ -104,20 +103,30 @@ def get_token(): |
104 | 103 | return token.token |
105 | 104 |
|
106 | 105 | # Create Azure chat client (agent_framework style) - relying on environment or explicit kwargs. |
107 | | - chat_client = AzureOpenAIChatClient( |
108 | | - endpoint=config.AZURE_OPENAI_ENDPOINT, |
109 | | - model_deployment_name=config.AZURE_OPENAI_DEPLOYMENT_NAME, |
110 | | - azure_ad_token_provider=get_token, |
111 | | - ) |
112 | | - |
| 106 | + try: |
| 107 | + chat_client = AzureOpenAIChatClient( |
| 108 | + endpoint=config.AZURE_OPENAI_ENDPOINT, |
| 109 | + deployment_name=config.AZURE_OPENAI_DEPLOYMENT_NAME, |
| 110 | + ad_token_provider=get_token, |
| 111 | + ) |
| 112 | + except Exception as e: # noqa: BLE001 |
| 113 | + logging.getLogger(__name__).error( |
| 114 | + "chat_client error: %s", e |
| 115 | + ) |
| 116 | + raise |
113 | 117 | # HumanApprovalMagenticManager needs the chat_client passed as 'chat_client' in its constructor signature (it subclasses StandardMagenticManager) |
114 | | - manager = HumanApprovalMagenticManager( |
115 | | - user_id=user_id, |
116 | | - chat_client=chat_client, |
117 | | - instructions=None, # optionally supply orchestrator system instructions |
118 | | - max_round_count=orchestration_config.max_rounds, |
119 | | - ) |
120 | | - |
| 118 | + try: |
| 119 | + manager = HumanApprovalMagenticManager( |
| 120 | + user_id=user_id, |
| 121 | + chat_client=chat_client, |
| 122 | + instructions=None, # optionally supply orchestrator system instructions |
| 123 | + max_round_count=orchestration_config.max_rounds, |
| 124 | + ) |
| 125 | + except Exception as e: # noqa: BLE001 |
| 126 | + logging.getLogger(__name__).error( |
| 127 | + "manager error: %s", e |
| 128 | + ) |
| 129 | + raise |
121 | 130 | # Build participant map: use each agent's name as key |
122 | 131 | participants = {} |
123 | 132 | for ag in agents: |
|
0 commit comments