wire llms, ui tweaks
This commit is contained in:
@@ -148,10 +148,25 @@ async def run_fce(
|
||||
}
|
||||
|
||||
t0 = time.time()
|
||||
notification_text = await mcp.call_tool("passenger", "generate_notification", {"context": context})
|
||||
raw_result = await mcp.call_tool("passenger", "generate_notification", {"context": context})
|
||||
latency = int((time.time() - t0) * 1000)
|
||||
await emit("tool_call_end", tool="generate_notification", latency_ms=latency, is_live=False)
|
||||
|
||||
# Parse structured response (text + provider)
|
||||
llm_provider = "template"
|
||||
if isinstance(raw_result, dict) and "text" in raw_result:
|
||||
notification_text = raw_result["text"]
|
||||
llm_provider = raw_result.get("provider", "unknown")
|
||||
elif isinstance(raw_result, str):
|
||||
try:
|
||||
parsed = json.loads(raw_result)
|
||||
notification_text = parsed.get("text", raw_result)
|
||||
llm_provider = parsed.get("provider", "unknown")
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
notification_text = raw_result
|
||||
else:
|
||||
notification_text = str(raw_result)
|
||||
|
||||
await emit("node_exit", node="synthesize")
|
||||
|
||||
# ── Node 4: Format Output ──
|
||||
@@ -164,14 +179,15 @@ async def run_fce(
|
||||
if airport_status:
|
||||
data_sources.append("faa_status_live")
|
||||
if crew_notes:
|
||||
data_sources.append("get_crew_notes")
|
||||
data_sources.append("crew_notes")
|
||||
|
||||
notification = {
|
||||
"flight_id": flight_id,
|
||||
"type": "DELAY_NOTIFICATION" if status == "DELAYED" else f"{status}_NOTIFICATION",
|
||||
"status": status,
|
||||
"delay_minutes": delay_minutes,
|
||||
"notification_text": notification_text if isinstance(notification_text, str) else str(notification_text),
|
||||
"notification_text": notification_text,
|
||||
"llm_provider": llm_provider,
|
||||
"generated_at": datetime.now(timezone.utc).isoformat(),
|
||||
"data_sources": data_sources,
|
||||
"human_approved": True, # auto-approve in demo
|
||||
|
||||
Reference in New Issue
Block a user