Skip to content

Commit d34dedd

Browse files
committed
Add logging for the AI services
1 parent b8e9ae6 commit d34dedd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/api/routes.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
ThreadMessage,
2020
ThreadRun,
2121
AsyncAgentEventHandler,
22+
RunStep
2223
)
2324

2425
# Create a logger for this module
@@ -100,6 +101,19 @@ async def on_done(self) -> Optional[str]:
100101
stream_data = {'type': "stream_end"}
101102
return serialize_sse_event(stream_data)
102103

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
103117

104118
@router.get("/", response_class=HTMLResponse)
105119
async def index(request: Request):
@@ -116,7 +130,7 @@ async def get_result(thread_id: str, agent_id: str, ai_client : AIProjectClient)
116130
) as stream:
117131
logger.info("Successfully created stream; starting to process events")
118132
async for event in stream:
119-
_, _, event_func_return_val = event
133+
_, event_data_obj, event_func_return_val = event
120134
logger.debug(f"Received event: {event}")
121135
if event_func_return_val:
122136
logger.info(f"Yielding event: {event_func_return_val}")

0 commit comments

Comments
 (0)