wire llms, ui tweaks
This commit is contained in:
@@ -5,7 +5,6 @@ notification prompt template (multi-tone).
|
||||
"""
|
||||
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from fastmcp import FastMCP
|
||||
|
||||
@@ -25,17 +24,33 @@ mcp = FastMCP(
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def generate_notification(context: dict) -> str:
|
||||
async def generate_notification(context: dict) -> str:
|
||||
"""Synthesizes flight disruption context into an empathetic,
|
||||
actionable passenger notification.
|
||||
|
||||
Uses Claude Sonnet via AWS Bedrock Converse API.
|
||||
Uses Claude via Anthropic SDK (or Bedrock when USE_BEDROCK=true).
|
||||
Output: clear, human, no jargon, includes gate/time/status.
|
||||
|
||||
NOTE: In v1, this returns a structured template from the context data.
|
||||
LLM integration will be added when Bedrock is wired up.
|
||||
Falls back to template if no API key is configured.
|
||||
"""
|
||||
# V1: structured template — will be replaced with Bedrock call
|
||||
try:
|
||||
from mcp_servers.shared_llm import generate, _get_provider
|
||||
|
||||
system_prompt = (
|
||||
"You are a passenger notification system for Stellar Air. "
|
||||
"Write a clear, empathetic notification about this flight disruption. "
|
||||
"Explain WHY the delay or cancellation happened using the operational data provided. "
|
||||
"Tell the passenger what's happening next: new boarding time, gate, status. "
|
||||
"Be human and reassuring. No aviation jargon. No speculation. "
|
||||
"If data is missing for a section, omit it — don't make things up."
|
||||
)
|
||||
text = await generate(system_prompt, json.dumps(context, indent=2))
|
||||
return json.dumps({"text": text, "provider": _get_provider()})
|
||||
except Exception:
|
||||
return json.dumps({"text": _template_notification(context), "provider": "template"})
|
||||
|
||||
|
||||
def _template_notification(context: dict) -> str:
|
||||
"""Structured template fallback when LLM is unavailable."""
|
||||
flight_id = context.get("flight_id", "")
|
||||
origin = context.get("origin", "")
|
||||
destination = context.get("destination", "")
|
||||
|
||||
Reference in New Issue
Block a user