Spaces:
Running
Running
Commit ·
c00c978
1
Parent(s): 67e2971
Sync with main branch - updated UI and requirements
Browse files
app.py
CHANGED
|
@@ -18,258 +18,252 @@ DEMO_RESULT = json.loads(SAMPLE_PATH.read_text(encoding="utf-8")) if SAMPLE_PATH
|
|
| 18 |
|
| 19 |
|
| 20 |
CSS = """
|
| 21 |
-
@import url('https://fonts.googleapis.com/css2?family=
|
| 22 |
|
| 23 |
:root {
|
| 24 |
-
--
|
| 25 |
-
--
|
| 26 |
-
--
|
| 27 |
-
--
|
| 28 |
-
--
|
| 29 |
-
--
|
| 30 |
-
--
|
| 31 |
-
--
|
| 32 |
-
--
|
| 33 |
-
--
|
| 34 |
-
--uplan-accent-3: #818cf8;
|
| 35 |
-
--uplan-green: #34d399;
|
| 36 |
-
--uplan-amber: #fbbf24;
|
| 37 |
-
--uplan-red: #f87171;
|
| 38 |
-
--uplan-radius: 14px;
|
| 39 |
-
--uplan-radius-sm: 10px;
|
| 40 |
-
--font-main: "Google Sans Flex", "Google Sans", "Inter", sans-serif;
|
| 41 |
}
|
| 42 |
|
| 43 |
-
/* ── Global Reset ────────────────────────── */
|
| 44 |
.gradio-container {
|
| 45 |
max-width: 1440px !important;
|
| 46 |
-
font-family: var(--font-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
-webkit-font-smoothing: antialiased;
|
| 53 |
-
-moz-osx-font-smoothing: grayscale;
|
| 54 |
}
|
| 55 |
|
| 56 |
-
.gradio-container .dark {
|
| 57 |
-
background: var(--uplan-bg) !important;
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
/* ── Header ──────────────────────────────── */
|
| 61 |
#uplan-header {
|
| 62 |
-
border-bottom: 1px solid var(--
|
| 63 |
-
padding:
|
| 64 |
-
margin-bottom:
|
| 65 |
-
position: relative;
|
| 66 |
-
}
|
| 67 |
-
#uplan-header::after {
|
| 68 |
-
content: '';
|
| 69 |
-
position: absolute;
|
| 70 |
-
bottom: -1px;
|
| 71 |
-
left: 0;
|
| 72 |
-
width: 120px;
|
| 73 |
-
height: 2px;
|
| 74 |
-
background: linear-gradient(90deg, var(--uplan-accent-1), var(--uplan-accent-2));
|
| 75 |
-
border-radius: 2px;
|
| 76 |
}
|
| 77 |
#uplan-header h1 {
|
| 78 |
margin: 0;
|
| 79 |
-
font-size:
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
background: linear-gradient(135deg, var(--uplan-accent-1), var(--uplan-accent-2), var(--uplan-accent-3));
|
| 83 |
-
background-size: 200% 200%;
|
| 84 |
-
-webkit-background-clip: text;
|
| 85 |
-
-webkit-text-fill-color: transparent;
|
| 86 |
font-weight: 700;
|
| 87 |
-
|
| 88 |
-
}
|
| 89 |
-
@keyframes uplan-shimmer {
|
| 90 |
-
0%, 100% { background-position: 0% 50%; }
|
| 91 |
-
50% { background-position: 100% 50%; }
|
| 92 |
}
|
| 93 |
#uplan-header p {
|
| 94 |
-
margin:
|
| 95 |
-
color: var(--
|
| 96 |
-
font-size:
|
| 97 |
-
font-
|
| 98 |
-
|
| 99 |
-
letter-spacing: 0.01em;
|
| 100 |
}
|
| 101 |
|
| 102 |
-
/*
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
padding: 18px 20px;
|
| 107 |
-
background: var(--uplan-surface);
|
| 108 |
-
backdrop-filter: blur(20px) saturate(1.2);
|
| 109 |
-
-webkit-backdrop-filter: blur(20px) saturate(1.2);
|
| 110 |
-
color: var(--uplan-text);
|
| 111 |
-
transition: border-color 0.3s ease, box-shadow 0.3s ease;
|
| 112 |
}
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
}
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
| 120 |
}
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
}
|
| 126 |
|
| 127 |
-
/*
|
| 128 |
-
.
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
border-radius: var(--uplan-radius-sm) !important;
|
| 133 |
-
border: 1px solid var(--uplan-border) !important;
|
| 134 |
-
background: var(--uplan-surface) !important;
|
| 135 |
-
transition: border-color 0.25s ease !important;
|
| 136 |
}
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
| 140 |
}
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
| 143 |
}
|
| 144 |
|
| 145 |
-
|
| 146 |
-
.
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
border-radius: var(--uplan-radius-sm) !important;
|
| 150 |
-
font-family: var(--font-main) !important;
|
| 151 |
-
font-weight: 600 !important;
|
| 152 |
-
letter-spacing: 0.02em;
|
| 153 |
-
padding: 10px 24px !important;
|
| 154 |
-
transition: transform 0.2s ease, box-shadow 0.25s ease !important;
|
| 155 |
-
box-shadow: 0 4px 16px rgba(96,165,250,0.15) !important;
|
| 156 |
}
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
|
|
|
| 160 |
}
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
border:
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
}
|
| 169 |
-
.
|
| 170 |
-
|
| 171 |
-
border-color: var(--uplan-accent-1) !important;
|
| 172 |
}
|
| 173 |
|
| 174 |
-
|
| 175 |
-
.
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
border-radius: var(--uplan-radius) !important;
|
| 179 |
-
}
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
}
|
| 187 |
-
.
|
| 188 |
-
|
| 189 |
-
font-
|
| 190 |
-
font-
|
| 191 |
-
|
| 192 |
-
color: var(--uplan-text) !important;
|
| 193 |
}
|
| 194 |
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
| 201 |
}
|
| 202 |
-
.
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
| 204 |
}
|
| 205 |
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
}
|
| 213 |
-
.
|
| 214 |
-
|
|
|
|
| 215 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
}
|
| 222 |
-
.
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
}
|
| 225 |
-
"""
|
| 226 |
-
|
| 227 |
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
|
|
|
| 233 |
}
|
|
|
|
| 234 |
|
| 235 |
|
| 236 |
def badge(text: str, severity: str) -> str:
|
| 237 |
-
|
| 238 |
-
return
|
| 239 |
-
f"<span style='display:inline-flex;align-items:center;padding:4px 12px;border-radius:999px;"
|
| 240 |
-
f"font-size:11px;font-weight:600;background:{bg};color:{color};"
|
| 241 |
-
f"border:1px solid {color}22;letter-spacing:0.03em;"
|
| 242 |
-
f"font-family:\"Google Sans Flex\",\"Inter\",sans-serif;"
|
| 243 |
-
f"backdrop-filter:blur(8px);"
|
| 244 |
-
f"margin:2px 4px 2px 0;transition:all 0.2s ease'>{text}</span>"
|
| 245 |
-
)
|
| 246 |
|
| 247 |
|
| 248 |
def money(value: Any, currency: str = "") -> str:
|
| 249 |
if value is None:
|
| 250 |
-
return "<span
|
| 251 |
try:
|
| 252 |
-
return (
|
| 253 |
-
f"<b style='color:rgb(219,216,211);font-weight:600;font-size:16px;"
|
| 254 |
-
f"font-family:\"Google Sans Flex\",\"Inter\",sans-serif'>"
|
| 255 |
-
f"{currency} {float(value):,.0f}</b>"
|
| 256 |
-
)
|
| 257 |
except (TypeError, ValueError):
|
| 258 |
-
return f"<
|
| 259 |
|
| 260 |
|
| 261 |
def score_bar(score: float) -> str:
|
| 262 |
pct = max(0, min(100, int(score * 100)))
|
| 263 |
-
|
| 264 |
-
|
| 265 |
return f"""
|
| 266 |
-
<div style='margin-top:
|
| 267 |
-
<div style='display:flex;justify-content:space-between;font-size:
|
| 268 |
-
<span
|
| 269 |
-
<b style='color:{color};font-size:18px;font-weight:700'>{pct}<span style='font-size:12px;font-weight:500;opacity:0.7'>%</span></b>
|
| 270 |
</div>
|
| 271 |
-
<div
|
| 272 |
-
<div style='
|
| 273 |
</div>
|
| 274 |
</div>
|
| 275 |
"""
|
|
@@ -450,7 +444,7 @@ def backend_unavailable_result(message: str) -> dict[str, Any]:
|
|
| 450 |
def build_dashboard_html(raw_result: dict[str, Any]) -> str:
|
| 451 |
result = normalize_result(raw_result)
|
| 452 |
if not result:
|
| 453 |
-
return "<
|
| 454 |
|
| 455 |
fields = result.get("reliable_fields", {})
|
| 456 |
synthesis = result.get("narrative_synthesis", {})
|
|
@@ -464,129 +458,98 @@ def build_dashboard_html(raw_result: dict[str, Any]) -> str:
|
|
| 464 |
account_total = sum(float(item.get("amount") or 0) for item in fields.get("financial_accounts", []))
|
| 465 |
income_total = sum(float(item.get("annual_amount") or 0) for item in fields.get("income_sources", []))
|
| 466 |
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
human_review_html = ""
|
| 473 |
-
if synthesis.get("human_review_required"):
|
| 474 |
-
human_review_html = f"<div style='display:flex;align-items:center;gap:8px;font-size:12px;color:#f87171;margin-top:10px;padding:8px 12px;background:rgba(248,113,113,0.06);border:1px solid rgba(248,113,113,0.12);border-radius:8px;font-family:{font}'><span style='font-size:16px'>⚠</span> <span style='font-weight:500'>Human review required</span></div>"
|
| 475 |
-
|
| 476 |
-
text_primary = "rgb(219,216,211)"
|
| 477 |
-
accent_bg = "linear-gradient(135deg,rgba(96,165,250,0.06),rgba(167,139,250,0.06))"
|
| 478 |
-
sub_card = "background:rgba(255,255,255,0.025);border:1px solid rgba(255,255,255,0.05);border-radius:10px;padding:12px 14px"
|
| 479 |
-
|
| 480 |
-
html = f"""
|
| 481 |
-
<div style='font-family:{font};font-weight:450;font-size:14px;line-height:1.6;color:{text_primary}'>
|
| 482 |
-
|
| 483 |
-
<div class='uplan-dash-card' style='background:{accent_bg};border:1px solid {card_border};border-radius:14px;padding:20px;margin-bottom:14px;backdrop-filter:blur(20px)'>
|
| 484 |
-
<div style='display:flex;justify-content:space-between;align-items:center'>
|
| 485 |
-
<div style='display:flex;align-items:center;gap:10px'>
|
| 486 |
-
<span style='font-size:20px'>📊</span>
|
| 487 |
-
<b style='color:{text_primary};font-size:15px;font-weight:600'>Readiness overview</b>
|
| 488 |
</div>
|
| 489 |
-
{
|
|
|
|
| 490 |
</div>
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
<div style='{sub_card}'>
|
| 502 |
-
<span style='{label_style}'>Applicant</span>
|
| 503 |
-
<div style='margin-top:6px;font-weight:500;color:{text_primary}'>{result.get("applicant_name") or fields.get("beneficiary_name") or "not found"}</div>
|
| 504 |
-
</div>
|
| 505 |
-
<div style='{sub_card}'>
|
| 506 |
-
<span style='{label_style}'>Sponsor</span>
|
| 507 |
-
<div style='margin-top:6px;font-weight:500;color:{text_primary}'>{result.get("sponsor_name") or "not found"}</div>
|
| 508 |
</div>
|
| 509 |
</div>
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
<div class='uplan-dash-card' style='background:{card_bg};border:1px solid {card_border};border-radius:14px;padding:20px;margin-bottom:14px;backdrop-filter:blur(16px)'>
|
| 514 |
-
<div style='display:flex;align-items:center;gap:10px;margin-bottom:14px'>
|
| 515 |
-
<span style='font-size:18px'>💰</span>
|
| 516 |
-
<b style='color:{text_primary};font-size:15px;font-weight:600'>Financial summary</b>
|
| 517 |
-
</div>
|
| 518 |
-
<div style='display:grid;grid-template-columns:1fr 1fr;gap:12px'>
|
| 519 |
-
<div style='{sub_card}'><span style='{label_style}'>Required funds</span><div style='margin-top:6px'>{money(t_req, currency)}</div></div>
|
| 520 |
-
<div style='{sub_card}'><span style='{label_style}'>Liquid / deposit evidence</span><div style='margin-top:6px'>{money(account_total or fields.get("balance_closing"), currency)}</div></div>
|
| 521 |
-
<div style='{sub_card}'><span style='{label_style}'>Affidavit income</span><div style='margin-top:6px'>{money(fields.get("i_aff") or income_total, currency)}</div></div>
|
| 522 |
-
<div style='{sub_card}'><span style='{label_style}'>Tax verified income</span><div style='margin-top:6px'>{money(fields.get("i_tax"), currency)}</div></div>
|
| 523 |
-
</div>
|
| 524 |
-
</div>
|
| 525 |
-
"""
|
| 526 |
-
|
| 527 |
-
if docs:
|
| 528 |
-
rows = "".join(
|
| 529 |
-
f"<div style='display:flex;justify-content:space-between;align-items:center;padding:8px 0;border-bottom:1px solid rgba(255,255,255,0.04)'>"
|
| 530 |
-
f"<span style='color:rgb(219,216,211);font-weight:500'>{doc.get('type','unknown').replace('_',' ').title()}</span>"
|
| 531 |
-
f"<span style='display:flex;align-items:center;gap:8px;color:rgba(219,216,211,0.4);font-size:12px'>{doc.get('pages',0)}p · {doc.get('quality','unknown')} {badge(doc.get('status','seen'), 'pass')}</span></div>"
|
| 532 |
-
for doc in docs
|
| 533 |
-
)
|
| 534 |
-
html += card("📑 Documents", rows)
|
| 535 |
-
|
| 536 |
-
if fields.get("name_variants"):
|
| 537 |
-
rows = "".join(
|
| 538 |
-
f"<div style='font-size:13px;color:rgba(219,216,211,0.6);padding:4px 0'><span style='color:rgba(219,216,211,0.35);font-weight:500'>{key.replace('_',' ').title()}</span>: <span style='color:rgb(219,216,211);font-weight:500'>{value}</span></div>"
|
| 539 |
-
for key, value in fields["name_variants"].items()
|
| 540 |
-
)
|
| 541 |
-
html += card("🔗 Name consistency", rows)
|
| 542 |
|
|
|
|
| 543 |
if findings:
|
| 544 |
rows = "".join(
|
| 545 |
-
f"<div style='
|
| 546 |
-
f"<div style='display:flex;align-items:center;gap:8px'><b style='color:
|
| 547 |
-
f"<div style='
|
| 548 |
f"</div>"
|
| 549 |
for finding in findings
|
| 550 |
)
|
| 551 |
-
|
| 552 |
|
| 553 |
if synthesis.get("compound_flags"):
|
| 554 |
-
rows = "".join(f"<div
|
| 555 |
-
|
| 556 |
|
| 557 |
adversarial = result.get("adversarial_audit", {})
|
| 558 |
if adversarial.get("rejection_case") or adversarial.get("rebuttal_case"):
|
| 559 |
rows = ""
|
| 560 |
if adversarial.get("rejection_case"):
|
| 561 |
-
rows += f"<div style='
|
| 562 |
if adversarial.get("rebuttal_case"):
|
| 563 |
-
rows += f"<div style='
|
| 564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 565 |
|
| 566 |
if result.get("next_steps"):
|
| 567 |
rows = "".join(
|
| 568 |
-
f"<div
|
| 569 |
for step in result["next_steps"]
|
| 570 |
)
|
| 571 |
-
|
| 572 |
|
| 573 |
cert = result.get("deletion_cert") or raw_result.get("full_result", {}).get("deletion_cert")
|
| 574 |
if cert:
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
html += "</div>"
|
| 578 |
-
return html
|
| 579 |
|
|
|
|
| 580 |
|
| 581 |
-
|
| 582 |
-
return (
|
| 583 |
-
f"<div class='uplan-dash-card' style='background:{bg};border:1px solid {border};"
|
| 584 |
-
f"border-radius:14px;padding:20px;margin-bottom:14px;"
|
| 585 |
-
f"backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);"
|
| 586 |
-
f"font-family:\"Google Sans Flex\",\"Inter\",sans-serif'>"
|
| 587 |
-
f"<b style='color:rgb(219,216,211);font-size:15px;font-weight:600'>{title}</b>"
|
| 588 |
-
f"<div style='margin-top:12px'>{body}</div></div>"
|
| 589 |
-
)
|
| 590 |
|
| 591 |
|
| 592 |
def chat_response(message: str, history: list, result_state: dict) -> tuple[list, str]:
|
|
@@ -630,32 +593,23 @@ def handle_upload(files, demo_mode: bool):
|
|
| 630 |
|
| 631 |
HEADER_HTML = """
|
| 632 |
<div id='uplan-header'>
|
| 633 |
-
<h1>
|
| 634 |
-
<p>
|
| 635 |
-
<span style='font-size:11px;color:rgba(219,216,211,0.3);font-weight:400;letter-spacing:0.04em'>POWERED BY AMD MI300X · QWEN 3.6-27B VLM</span></p>
|
| 636 |
</div>
|
| 637 |
"""
|
| 638 |
|
| 639 |
|
| 640 |
CHECKLIST_HTML = """
|
| 641 |
-
<div class='tool-card'
|
| 642 |
-
<
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
</
|
| 646 |
-
<div style='display:flex;align-items:center;gap:6px'><span style='display:inline-block;width:8px;height:8px;border-radius:50%;background:#f87171'></span> <span style='color:#f87171;font-weight:500'>Required:</span> affidavit, bank statement, tax return</div>
|
| 647 |
-
<div style='display:flex;align-items:center;gap:6px'><span style='display:inline-block;width:8px;height:8px;border-radius:50%;background:#fbbf24'></span> <span style='color:#fbbf24;font-weight:500'>Recommended:</span> bank balance certificate</div>
|
| 648 |
-
<div style='display:flex;align-items:center;gap:6px'><span style='display:inline-block;width:8px;height:8px;border-radius:50%;background:#60a5fa'></span> <span style='color:#60a5fa;font-weight:500'>Optional:</span> passport / identity document</div>
|
| 649 |
<hr>
|
| 650 |
-
<
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
</
|
| 654 |
-
<div style='color:rgba(219,216,211,0.65);line-height:1.8'>
|
| 655 |
-
<span style='color:rgba(219,216,211,0.85);font-weight:500'>Auditor</span> · document readiness and quality checks<br>
|
| 656 |
-
<span style='color:rgba(219,216,211,0.85);font-weight:500'>Strategist</span> · roadmap and missing-evidence checklist<br>
|
| 657 |
-
<span style='color:rgba(219,216,211,0.85);font-weight:500'>Synthesis</span> · cross-document risk narrative
|
| 658 |
-
</div>
|
| 659 |
</div>
|
| 660 |
"""
|
| 661 |
|
|
@@ -724,8 +678,7 @@ if __name__ == "__main__":
|
|
| 724 |
server_name="0.0.0.0",
|
| 725 |
server_port=7860,
|
| 726 |
show_error=True,
|
| 727 |
-
theme=
|
| 728 |
css=CSS,
|
| 729 |
)
|
| 730 |
|
| 731 |
-
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
CSS = """
|
| 21 |
+
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');
|
| 22 |
|
| 23 |
:root {
|
| 24 |
+
--bg-onyx: #0a0a0c;
|
| 25 |
+
--bg-card: rgba(255, 255, 255, 0.03);
|
| 26 |
+
--border-glass: rgba(255, 255, 255, 0.08);
|
| 27 |
+
--text-main: #f3f4f6;
|
| 28 |
+
--text-muted: #8b949e;
|
| 29 |
+
--alert-red: #ff3366;
|
| 30 |
+
--cyber-cyan: #00f0ff;
|
| 31 |
+
--warn-yellow: #ffb800;
|
| 32 |
+
--font-mono: 'JetBrains Mono', monospace;
|
| 33 |
+
--font-primary: 'Space Grotesk', sans-serif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
|
|
|
|
| 36 |
.gradio-container {
|
| 37 |
max-width: 1440px !important;
|
| 38 |
+
font-family: var(--font-primary) !important;
|
| 39 |
+
background-color: var(--bg-onyx) !important;
|
| 40 |
+
background-image:
|
| 41 |
+
linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
|
| 42 |
+
linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
|
| 43 |
+
background-size: 24px 24px;
|
|
|
|
|
|
|
| 44 |
}
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
#uplan-header {
|
| 47 |
+
border-bottom: 1px solid var(--border-glass);
|
| 48 |
+
padding: 16px 0 20px;
|
| 49 |
+
margin-bottom: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
}
|
| 51 |
#uplan-header h1 {
|
| 52 |
margin: 0;
|
| 53 |
+
font-size: 28px;
|
| 54 |
+
letter-spacing: -0.5px;
|
| 55 |
+
color: var(--text-main);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
font-weight: 700;
|
| 57 |
+
text-transform: uppercase;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
#uplan-header p {
|
| 60 |
+
margin: 6px 0 0;
|
| 61 |
+
color: var(--text-muted);
|
| 62 |
+
font-size: 13px;
|
| 63 |
+
font-family: var(--font-mono);
|
| 64 |
+
letter-spacing: 1px;
|
|
|
|
| 65 |
}
|
| 66 |
|
| 67 |
+
/* Animations */
|
| 68 |
+
@keyframes compileIn {
|
| 69 |
+
0% { opacity: 0; transform: translateY(15px); }
|
| 70 |
+
100% { opacity: 1; transform: translateY(0); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
}
|
| 72 |
+
|
| 73 |
+
.dossier-card {
|
| 74 |
+
border: 1px solid var(--border-glass);
|
| 75 |
+
border-radius: 4px;
|
| 76 |
+
padding: 16px;
|
| 77 |
+
background: var(--bg-card);
|
| 78 |
+
backdrop-filter: blur(12px);
|
| 79 |
+
-webkit-backdrop-filter: blur(12px);
|
| 80 |
+
color: var(--text-main);
|
| 81 |
+
animation: compileIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
|
| 82 |
+
opacity: 0;
|
| 83 |
+
position: relative;
|
| 84 |
+
overflow: hidden;
|
| 85 |
+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
| 86 |
}
|
| 87 |
+
|
| 88 |
+
.dossier-card:hover {
|
| 89 |
+
border-color: rgba(255, 255, 255, 0.15);
|
| 90 |
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
|
| 91 |
}
|
| 92 |
+
|
| 93 |
+
.card-1 { animation-delay: 0.1s; }
|
| 94 |
+
.card-2 { animation-delay: 0.2s; }
|
| 95 |
+
.card-3 { animation-delay: 0.3s; }
|
| 96 |
+
.card-4 { animation-delay: 0.4s; }
|
| 97 |
+
.card-5 { animation-delay: 0.5s; }
|
| 98 |
+
.card-6 { animation-delay: 0.6s; }
|
| 99 |
+
|
| 100 |
+
.dossier-card-title {
|
| 101 |
+
color: var(--text-main);
|
| 102 |
+
font-weight: 600;
|
| 103 |
+
text-transform: uppercase;
|
| 104 |
+
font-size: 12px;
|
| 105 |
+
letter-spacing: 1.5px;
|
| 106 |
+
margin-bottom: 12px;
|
| 107 |
+
display: block;
|
| 108 |
}
|
| 109 |
|
| 110 |
+
/* Layout */
|
| 111 |
+
.dashboard-grid {
|
| 112 |
+
display: flex;
|
| 113 |
+
flex-direction: column;
|
| 114 |
+
gap: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
+
|
| 117 |
+
.hero-section {
|
| 118 |
+
display: grid;
|
| 119 |
+
grid-template-columns: 1fr 2.5fr;
|
| 120 |
+
gap: 16px;
|
| 121 |
}
|
| 122 |
+
|
| 123 |
+
.split-view {
|
| 124 |
+
display: grid;
|
| 125 |
+
grid-template-columns: 1.5fr 1fr;
|
| 126 |
+
gap: 16px;
|
| 127 |
}
|
| 128 |
|
| 129 |
+
@media (max-width: 900px) {
|
| 130 |
+
.hero-section, .split-view {
|
| 131 |
+
grid-template-columns: 1fr;
|
| 132 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
}
|
| 134 |
+
|
| 135 |
+
/* Typography & Elements */
|
| 136 |
+
.mono-text {
|
| 137 |
+
font-family: var(--font-mono);
|
| 138 |
}
|
| 139 |
+
|
| 140 |
+
.dossier-badge {
|
| 141 |
+
display: inline-block;
|
| 142 |
+
padding: 3px 8px;
|
| 143 |
+
border-radius: 2px;
|
| 144 |
+
font-size: 10px;
|
| 145 |
+
font-family: var(--font-mono);
|
| 146 |
+
font-weight: 600;
|
| 147 |
+
text-transform: uppercase;
|
| 148 |
+
margin: 2px 4px 2px 0;
|
| 149 |
+
transition: filter 0.2s;
|
| 150 |
}
|
| 151 |
+
.dossier-badge:hover {
|
| 152 |
+
filter: brightness(1.3);
|
|
|
|
| 153 |
}
|
| 154 |
|
| 155 |
+
.sev-critical { background: rgba(255, 51, 102, 0.1); color: var(--alert-red); border: 1px solid rgba(255, 51, 102, 0.3); }
|
| 156 |
+
.sev-warning { background: rgba(255, 184, 0, 0.1); color: var(--warn-yellow); border: 1px solid rgba(255, 184, 0, 0.3); }
|
| 157 |
+
.sev-info { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border: 1px solid var(--border-glass); }
|
| 158 |
+
.sev-pass { background: rgba(0, 240, 255, 0.1); color: var(--cyber-cyan); border: 1px solid rgba(0, 240, 255, 0.3); }
|
|
|
|
|
|
|
| 159 |
|
| 160 |
+
.data-grid {
|
| 161 |
+
display: grid;
|
| 162 |
+
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
| 163 |
+
gap: 12px;
|
| 164 |
+
}
|
| 165 |
+
.data-label {
|
| 166 |
+
color: var(--text-muted);
|
| 167 |
+
font-size: 10px;
|
| 168 |
+
text-transform: uppercase;
|
| 169 |
+
letter-spacing: 0.5px;
|
| 170 |
+
font-family: var(--font-mono);
|
| 171 |
+
display: block;
|
| 172 |
+
margin-bottom: 4px;
|
| 173 |
}
|
| 174 |
+
.data-value {
|
| 175 |
+
color: var(--text-main);
|
| 176 |
+
font-size: 14px;
|
| 177 |
+
font-family: var(--font-mono);
|
| 178 |
+
font-weight: 500;
|
|
|
|
| 179 |
}
|
| 180 |
|
| 181 |
+
.dossier-row {
|
| 182 |
+
display: flex;
|
| 183 |
+
justify-content: space-between;
|
| 184 |
+
padding: 10px 8px;
|
| 185 |
+
border-bottom: 1px solid var(--border-glass);
|
| 186 |
+
font-family: var(--font-mono);
|
| 187 |
+
font-size: 12px;
|
| 188 |
+
transition: background 0.2s;
|
| 189 |
+
margin: 0 -8px;
|
| 190 |
}
|
| 191 |
+
.dossier-row:hover {
|
| 192 |
+
background: rgba(255, 255, 255, 0.03);
|
| 193 |
+
}
|
| 194 |
+
.dossier-row:last-child {
|
| 195 |
+
border-bottom: none;
|
| 196 |
}
|
| 197 |
|
| 198 |
+
.progress-bar-bg {
|
| 199 |
+
height: 4px;
|
| 200 |
+
background: rgba(255, 255, 255, 0.1);
|
| 201 |
+
border-radius: 2px;
|
| 202 |
+
overflow: hidden;
|
| 203 |
+
margin-top: 8px;
|
| 204 |
}
|
| 205 |
+
.progress-bar-fill {
|
| 206 |
+
height: 100%;
|
| 207 |
+
transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1);
|
| 208 |
}
|
| 209 |
+
.text-critical { color: var(--alert-red) !important; }
|
| 210 |
+
.text-warning { color: var(--warn-yellow) !important; }
|
| 211 |
+
.text-pass { color: var(--cyber-cyan) !important; }
|
| 212 |
+
.text-muted { color: var(--text-muted) !important; }
|
| 213 |
|
| 214 |
+
.tool-card {
|
| 215 |
+
border: 1px solid var(--border-glass);
|
| 216 |
+
border-radius: 4px;
|
| 217 |
+
padding: 14px;
|
| 218 |
+
background: var(--bg-card);
|
| 219 |
+
backdrop-filter: blur(8px);
|
| 220 |
+
color: var(--text-main);
|
| 221 |
+
font-family: var(--font-mono);
|
| 222 |
}
|
| 223 |
+
.tool-card b {
|
| 224 |
+
color: var(--text-main);
|
| 225 |
+
}
|
| 226 |
+
.tool-card hr {
|
| 227 |
+
border: 0;
|
| 228 |
+
border-top: 1px solid var(--border-glass);
|
| 229 |
+
margin: 10px 0;
|
| 230 |
}
|
|
|
|
|
|
|
| 231 |
|
| 232 |
+
/* ── Chat styling ────────────────────────── */
|
| 233 |
+
.gradio-container textarea {
|
| 234 |
+
min-height: 44px !important;
|
| 235 |
+
}
|
| 236 |
+
.gradio-container .gap {
|
| 237 |
+
gap: 8px;
|
| 238 |
}
|
| 239 |
+
"""
|
| 240 |
|
| 241 |
|
| 242 |
def badge(text: str, severity: str) -> str:
|
| 243 |
+
sev_class = f"sev-{severity}" if severity in ["critical", "warning", "pass"] else "sev-info"
|
| 244 |
+
return f"<span class='dossier-badge {sev_class}'>{text}</span>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
|
| 247 |
def money(value: Any, currency: str = "") -> str:
|
| 248 |
if value is None:
|
| 249 |
+
return "<span class='data-value text-muted'>N/A</span>"
|
| 250 |
try:
|
| 251 |
+
return f"<span class='data-value'>{currency} {float(value):,.0f}</span>"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
except (TypeError, ValueError):
|
| 253 |
+
return f"<span class='data-value'>{value}</span>"
|
| 254 |
|
| 255 |
|
| 256 |
def score_bar(score: float) -> str:
|
| 257 |
pct = max(0, min(100, int(score * 100)))
|
| 258 |
+
color_class = "text-critical" if pct < 50 else "text-warning" if pct < 75 else "text-pass"
|
| 259 |
+
bg_color = "var(--alert-red)" if pct < 50 else "var(--warn-yellow)" if pct < 75 else "var(--cyber-cyan)"
|
| 260 |
return f"""
|
| 261 |
+
<div style='margin-top:12px'>
|
| 262 |
+
<div style='display:flex;justify-content:space-between;font-size:11px;margin-bottom:6px;' class='mono-text'>
|
| 263 |
+
<span class='text-muted'>NARRATIVE COHERENCE</span><b class='{color_class}'>{pct}%</b>
|
|
|
|
| 264 |
</div>
|
| 265 |
+
<div class='progress-bar-bg'>
|
| 266 |
+
<div class='progress-bar-fill' style='width:{pct}%;background:{bg_color}'></div>
|
| 267 |
</div>
|
| 268 |
</div>
|
| 269 |
"""
|
|
|
|
| 444 |
def build_dashboard_html(raw_result: dict[str, Any]) -> str:
|
| 445 |
result = normalize_result(raw_result)
|
| 446 |
if not result:
|
| 447 |
+
return "<p class='mono-text text-muted' style='padding:16px'>Awaiting telemetry...</p>"
|
| 448 |
|
| 449 |
fields = result.get("reliable_fields", {})
|
| 450 |
synthesis = result.get("narrative_synthesis", {})
|
|
|
|
| 458 |
account_total = sum(float(item.get("amount") or 0) for item in fields.get("financial_accounts", []))
|
| 459 |
income_total = sum(float(item.get("annual_amount") or 0) for item in fields.get("income_sources", []))
|
| 460 |
|
| 461 |
+
readiness_html = f"""
|
| 462 |
+
<div class='dossier-card card-1'>
|
| 463 |
+
<div style='display:flex;justify-content:space-between;align-items:center'>
|
| 464 |
+
<span class='dossier-card-title' style='margin:0'>Readiness overview</span>{badge(overall, overall_sev)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
</div>
|
| 466 |
+
{score_bar(score)}
|
| 467 |
+
{"<div class='mono-text text-critical' style='font-size:11px;margin-top:10px;font-weight:600'>[!] HUMAN REVIEW REQUIRED</div>" if synthesis.get("human_review_required") else ""}
|
| 468 |
</div>
|
| 469 |
+
"""
|
| 470 |
+
|
| 471 |
+
financials_html = f"""
|
| 472 |
+
<div class='dossier-card card-2'>
|
| 473 |
+
<span class='dossier-card-title'>Financial summary</span>
|
| 474 |
+
<div class='data-grid'>
|
| 475 |
+
<div><span class='data-label'>Required funds</span>{money(t_req, currency)}</div>
|
| 476 |
+
<div><span class='data-label'>Liquid / deposit evidence</span>{money(account_total or fields.get("balance_closing"), currency)}</div>
|
| 477 |
+
<div><span class='data-label'>Affidavit income</span>{money(fields.get("i_aff") or income_total, currency)}</div>
|
| 478 |
+
<div><span class='data-label'>Tax verified income</span>{money(fields.get("i_tax"), currency)}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
</div>
|
| 480 |
</div>
|
| 481 |
+
"""
|
| 482 |
+
|
| 483 |
+
hero_section = f"<div class='hero-section'>{readiness_html}{financials_html}</div>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
|
| 485 |
+
left_col_html = ""
|
| 486 |
if findings:
|
| 487 |
rows = "".join(
|
| 488 |
+
f"<div class='dossier-row' style='flex-direction:column;align-items:flex-start'>"
|
| 489 |
+
f"<div style='margin-bottom:6px;display:flex;align-items:center;gap:8px'><b style='color:var(--text-main);font-size:13px;font-family:var(--font-primary)'>{finding.get('rule_id','rule').replace('_',' ').title()}</b> {badge(finding.get('severity','info').title(), finding.get('severity','info'))}</div>"
|
| 490 |
+
f"<div style='color:var(--text-muted);line-height:1.5'>{finding.get('message','')}</div>"
|
| 491 |
f"</div>"
|
| 492 |
for finding in findings
|
| 493 |
)
|
| 494 |
+
left_col_html += f"<div class='dossier-card card-3'><span class='dossier-card-title'>Agent findings</span>{rows}</div>"
|
| 495 |
|
| 496 |
if synthesis.get("compound_flags"):
|
| 497 |
+
rows = "".join(f"<div class='dossier-row' style='color:var(--warn-yellow);border-color:rgba(255,184,0,0.1)'>[FLAG] {item}</div>" for item in synthesis["compound_flags"])
|
| 498 |
+
left_col_html += f"<div class='dossier-card card-5' style='border-color:rgba(255,184,0,0.3);background:rgba(255,184,0,0.02)'><span class='dossier-card-title' style='color:var(--warn-yellow)'>Cross-document risks</span>{rows}</div>"
|
| 499 |
|
| 500 |
adversarial = result.get("adversarial_audit", {})
|
| 501 |
if adversarial.get("rejection_case") or adversarial.get("rebuttal_case"):
|
| 502 |
rows = ""
|
| 503 |
if adversarial.get("rejection_case"):
|
| 504 |
+
rows += f"<div class='dossier-row' style='flex-direction:column;align-items:flex-start'><span class='data-label text-critical'>Officer rejection case</span><div style='color:var(--text-muted);margin-top:4px;line-height:1.5'>{adversarial['rejection_case']}</div></div>"
|
| 505 |
if adversarial.get("rebuttal_case"):
|
| 506 |
+
rows += f"<div class='dossier-row' style='flex-direction:column;align-items:flex-start'><span class='data-label text-pass'>Applicant rebuttal path</span><div style='color:var(--text-muted);margin-top:4px;line-height:1.5'>{adversarial['rebuttal_case']}</div></div>"
|
| 507 |
+
left_col_html += f"<div class='dossier-card card-6'><span class='dossier-card-title'>Adversarial audit</span>{rows}</div>"
|
| 508 |
+
|
| 509 |
+
right_col_html = ""
|
| 510 |
+
|
| 511 |
+
parties_html = f"""
|
| 512 |
+
<div class='dossier-card card-3'>
|
| 513 |
+
<span class='dossier-card-title'>Parties</span>
|
| 514 |
+
<div class='data-grid'>
|
| 515 |
+
<div><span class='data-label'>Applicant</span><b class='data-value'>{result.get("applicant_name") or fields.get("beneficiary_name") or "not found"}</b></div>
|
| 516 |
+
<div><span class='data-label'>Sponsor</span><b class='data-value'>{result.get("sponsor_name") or "not found"}</b></div>
|
| 517 |
+
</div>
|
| 518 |
+
<div style='margin-top:16px'><span class='data-label'>Relationship</span><b class='data-value'>{result.get("sponsor_relationship") or fields.get("spon_relationship") or "not found"}</b></div>
|
| 519 |
+
</div>
|
| 520 |
+
"""
|
| 521 |
+
right_col_html += parties_html
|
| 522 |
+
|
| 523 |
+
if docs:
|
| 524 |
+
rows = "".join(
|
| 525 |
+
f"<div class='dossier-row'>"
|
| 526 |
+
f"<span style='color:var(--text-main)'>{doc.get('type','unknown').replace('_',' ').title()}</span>"
|
| 527 |
+
f"<span style='color:var(--text-muted)'>{doc.get('pages',0)}p · {doc.get('quality','unknown')} · {badge(doc.get('status','seen'), 'pass')}</span></div>"
|
| 528 |
+
for doc in docs
|
| 529 |
+
)
|
| 530 |
+
right_col_html += f"<div class='dossier-card card-4'><span class='dossier-card-title'>Documents</span>{rows}</div>"
|
| 531 |
+
|
| 532 |
+
if fields.get("name_variants"):
|
| 533 |
+
rows = "".join(
|
| 534 |
+
f"<div class='dossier-row'><span class='data-label' style='margin:0'>{key.replace('_',' ').title()}</span><span class='data-value' style='font-size:12px'>{value}</span></div>"
|
| 535 |
+
for key, value in fields["name_variants"].items()
|
| 536 |
+
)
|
| 537 |
+
right_col_html += f"<div class='dossier-card card-4'><span class='dossier-card-title'>Name consistency</span>{rows}</div>"
|
| 538 |
|
| 539 |
if result.get("next_steps"):
|
| 540 |
rows = "".join(
|
| 541 |
+
f"<div class='dossier-row' style='align-items:flex-start;gap:12px'>{badge(step.get('priority','info').upper(), step.get('priority','info'))}<span style='color:var(--text-muted);flex:1;line-height:1.4'>{step.get('action','')}</span></div>"
|
| 542 |
for step in result["next_steps"]
|
| 543 |
)
|
| 544 |
+
right_col_html += f"<div class='dossier-card card-5'><span class='dossier-card-title'>Next steps</span>{rows}</div>"
|
| 545 |
|
| 546 |
cert = result.get("deletion_cert") or raw_result.get("full_result", {}).get("deletion_cert")
|
| 547 |
if cert:
|
| 548 |
+
right_col_html += f"<div class='dossier-card card-6' style='background:transparent;border:1px dashed var(--border-glass)'><span class='dossier-card-title' style='color:var(--text-muted)'>Deletion certificate</span><pre class='mono-text' style='white-space:pre-wrap;font-size:10px;color:var(--text-muted);margin:0;line-height:1.4'>{cert}</pre></div>"
|
|
|
|
|
|
|
|
|
|
| 549 |
|
| 550 |
+
split_view = f"<div class='split-view'><div class='left-col' style='display:flex;flex-direction:column;gap:16px'>{left_col_html}</div><div class='right-col' style='display:flex;flex-direction:column;gap:16px'>{right_col_html}</div></div>"
|
| 551 |
|
| 552 |
+
return f"<div class='dashboard-grid'>{hero_section}{split_view}</div>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
|
| 554 |
|
| 555 |
def chat_response(message: str, history: list, result_state: dict) -> tuple[list, str]:
|
|
|
|
| 593 |
|
| 594 |
HEADER_HTML = """
|
| 595 |
<div id='uplan-header'>
|
| 596 |
+
<h1>Uplan / Command</h1>
|
| 597 |
+
<p>IMMIGRATION DOCUMENT INTELLIGENCE // ADVERSARIAL AUDIT DOSSIER</p>
|
|
|
|
| 598 |
</div>
|
| 599 |
"""
|
| 600 |
|
| 601 |
|
| 602 |
CHECKLIST_HTML = """
|
| 603 |
+
<div class='tool-card'>
|
| 604 |
+
<b style='font-size:11px;letter-spacing:1px;text-transform:uppercase'>[ LOG ] Packet checklist</b><br><br>
|
| 605 |
+
<span class='text-critical'>REQ:</span> affidavit, bank statement, tax return<br>
|
| 606 |
+
<span class='text-warning'>REC:</span> bank balance certificate<br>
|
| 607 |
+
<span class='text-pass'>OPT:</span> passport / identity document
|
|
|
|
|
|
|
|
|
|
| 608 |
<hr>
|
| 609 |
+
<b style='font-size:11px;letter-spacing:1px;text-transform:uppercase'>[ SYS ] Agent tools</b><br><br>
|
| 610 |
+
<span class='text-muted'>AUDITOR:</span> document readiness and quality<br>
|
| 611 |
+
<span class='text-muted'>STRATEGIST:</span> roadmap and missing-evidence<br>
|
| 612 |
+
<span class='text-muted'>SYNTHESIS:</span> cross-document risk narrative
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 613 |
</div>
|
| 614 |
"""
|
| 615 |
|
|
|
|
| 678 |
server_name="0.0.0.0",
|
| 679 |
server_port=7860,
|
| 680 |
show_error=True,
|
| 681 |
+
theme=gr.themes.Base(),
|
| 682 |
css=CSS,
|
| 683 |
)
|
| 684 |
|
|
|