19
19
ThreadMessage ,
20
20
ThreadRun ,
21
21
AsyncAgentEventHandler ,
22
+ RunStep
22
23
)
23
24
24
25
# Create a logger for this module
@@ -100,6 +101,19 @@ async def on_done(self) -> Optional[str]:
100
101
stream_data = {'type' : "stream_end" }
101
102
return serialize_sse_event (stream_data )
102
103
104
+ async def on_run_step (self , step : RunStep ) -> Optional [str ]:
105
+ logger .info (f"Step { step ['id' ]} status: { step ['status' ]} " )
106
+ step_details = step .get ("step_details" , {})
107
+ tool_calls = step_details .get ("tool_calls" , [])
108
+
109
+ if tool_calls :
110
+ logger .info ("Tool calls:" )
111
+ for call in tool_calls :
112
+ azure_ai_search_details = call .get ("azure_ai_search" , {})
113
+ if azure_ai_search_details :
114
+ logger .info (f"azure_ai_search input: { azure_ai_search_details .get ('input' )} " )
115
+ logger .info (f"azure_ai_search output: { azure_ai_search_details .get ('output' )} " )
116
+ return None
103
117
104
118
@router .get ("/" , response_class = HTMLResponse )
105
119
async def index (request : Request ):
@@ -116,7 +130,7 @@ async def get_result(thread_id: str, agent_id: str, ai_client : AIProjectClient)
116
130
) as stream :
117
131
logger .info ("Successfully created stream; starting to process events" )
118
132
async for event in stream :
119
- _ , _ , event_func_return_val = event
133
+ _ , event_data_obj , event_func_return_val = event
120
134
logger .debug (f"Received event: { event } " )
121
135
if event_func_return_val :
122
136
logger .info (f"Yielding event: { event_func_return_val } " )
0 commit comments