Remove stale insurance live demo code

This commit is contained in:
Shubhamsaboo
2026-05-02 12:14:44 -07:00
parent ba2544f07e
commit a3ba80b4be
4 changed files with 3 additions and 130 deletions
@@ -4,8 +4,6 @@ const timelineEl = document.querySelector("#timeline");
const handoffEl = document.querySelector("#handoff");
const packetMarkdownEl = document.querySelector("#packetMarkdown");
const packetDialog = document.querySelector("#packetDialog");
const routePill = document.querySelector("#routePill");
const claimState = document.querySelector("#claimState");
const packetProgress = document.querySelector("#packetProgress");
const callStatus = document.querySelector("#callStatus");
const micButton = document.querySelector("#micButton");
@@ -97,21 +95,19 @@ function render() {
renderFields();
renderTimeline();
renderHandoff();
renderRoute();
renderPacket();
}
function renderTranscript() {
transcriptEl.innerHTML = state.transcript
.map((turn) => {
const safeText = escapeHtml(turn.text).replace(/passenger has neck pain/gi, '<span class="highlight">$&</span>');
const initials = turn.speaker === "Agent" ? "AI" : "CL";
return `
<article class="turn ${turn.speaker === "Agent" ? "agent" : "claimant"}">
<div class="speaker-icon">${initials}</div>
<div class="bubble">
<strong>${escapeHtml(turn.speaker)}</strong><time>${escapeHtml(turn.time || now())}</time>
<p>${safeText}</p>
<p>${escapeHtml(turn.text)}</p>
</div>
</article>
`;
@@ -240,17 +236,6 @@ function renderHandoff() {
packetProgress.textContent = `${state.progress}%`;
}
function renderRoute() {
if (!routePill || !claimState) return;
const route = state.route || "needs_docs";
routePill.className = "route-pill";
if (route === "emergency_escalation") routePill.classList.add("emergency");
if (route === "needs_docs" || route === "special_investigation") routePill.classList.add("docs");
if (route === "ready_for_adjuster") routePill.classList.add("ready");
routePill.textContent = routeLabels[route] || route;
claimState.textContent = `Claim state: ${(routeLabels[route] || route).toLowerCase()}`;
}
function renderPacket() {
packetMarkdownEl.textContent = state.packet_markdown || "# Initial Adjuster Handoff\n\nNo packet generated yet.";
}
@@ -18,7 +18,7 @@ from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
from fastapi import FastAPI, File, Form, HTTPException, UploadFile, WebSocket, WebSocketDisconnect
from fastapi import FastAPI, HTTPException, WebSocket, WebSocketDisconnect
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
@@ -134,37 +134,6 @@ def _claimant_text(session: IntakeSession) -> str:
)
def _transcribe_audio(audio_bytes: bytes, mime_type: str) -> str:
try:
from google.genai import types
except ImportError as exc:
raise HTTPException(
status_code=503,
detail="Missing google-genai package. Run pip install -r requirements.txt.",
) from exc
try:
response = _client().models.generate_content(
model=MODEL,
contents=[
types.Part.from_bytes(data=audio_bytes, mime_type=mime_type),
(
"Transcribe this claimant audio as plain text only. "
"Preserve names, phone numbers, policy numbers, locations, dates, "
"injuries, documents, and evidence exactly when audible."
),
],
)
except HTTPException:
raise
except Exception as exc:
raise HTTPException(status_code=502, detail=f"Gemini audio transcription failed: {exc}") from exc
text = (response.text or "").strip()
if not text:
raise HTTPException(status_code=422, detail="No speech was transcribed from the audio.")
return text
def _status(value: Any, urgent: bool = False) -> str:
text = str(value or "").strip().lower()
if urgent:
@@ -528,29 +497,6 @@ async def message(request: MessageRequest) -> SessionResponse:
)
@app.post("/api/audio", response_model=SessionResponse)
async def audio_message(
session_id: str = Form(...),
audio: UploadFile = File(...),
) -> SessionResponse:
session = sessions.get(session_id)
if session is None:
raise HTTPException(status_code=404, detail="Unknown intake session.")
audio_bytes = await audio.read()
if not audio_bytes:
raise HTTPException(status_code=400, detail="Audio file is empty.")
mime_type = audio.content_type or "audio/webm"
text = _transcribe_audio(audio_bytes, mime_type)
session.transcript.append({"speaker": "Claimant", "text": text})
state = await _process_with_adk_graph(session, add_claimant_facing_reply=True)
return SessionResponse(
session_id=session.session_id,
model=MODEL,
has_api_key=_has_api_key(),
state=state,
)
@app.websocket("/ws/live")
async def live_voice(websocket: WebSocket) -> None:
await websocket.accept()
@@ -109,8 +109,7 @@ h3 {
}
.live-model,
.status-line,
.state-pill {
.status-line {
color: var(--muted);
font-size: 13px;
display: inline-flex;
@@ -135,7 +134,6 @@ h3 {
background: var(--muted-soft);
}
.route-pill,
.status-pill {
border-radius: 999px;
font-size: 12px;
@@ -145,54 +143,6 @@ h3 {
letter-spacing: 0;
}
.operator {
display: flex;
align-items: center;
gap: 12px;
}
.headset {
width: 22px;
height: 22px;
border: 2px solid var(--body);
border-bottom: 0;
border-radius: 14px 14px 4px 4px;
position: relative;
opacity: 0.9;
}
.headset::before,
.headset::after {
content: "";
position: absolute;
top: 10px;
width: 5px;
height: 9px;
background: var(--body);
border-radius: 3px;
}
.headset::before {
left: -4px;
}
.headset::after {
right: -4px;
}
.avatar {
width: 34px;
height: 34px;
display: grid;
place-items: center;
border-radius: 50%;
background: var(--panel-strong);
border: 1px solid var(--hairline-strong);
color: var(--ink);
font-size: 12px;
font-weight: 700;
}
.dashboard {
display: grid;
grid-template-columns: minmax(340px, 0.9fr) minmax(470px, 1.23fr) minmax(370px, 0.96fr);
@@ -475,13 +425,6 @@ h3 {
overflow-wrap: anywhere;
}
.highlight {
color: var(--danger);
background: var(--danger-bg);
border-radius: 4px;
padding: 1px 3px;
}
.text-entry {
display: grid;
grid-template-columns: 1fr auto;
@@ -1,7 +1,6 @@
google-adk>=2.0.0a1
google-genai>=1.0.0
fastapi>=0.115
python-multipart>=0.0.9
uvicorn[standard]>=0.30
pydantic>=2.7
typing-extensions>=4.12