Spaces:
Sleeping
Sleeping
Upload app.py
Browse files104 unmodified lines1051061071081091101111121131141151161171181191201211221238701 unmodified lines882588268827882888298830883188328833883435 unmodified lines887088718872887388748875887688778878887940 unmodified lines89208921892289238924892589268927892889298930893189328933893489358936893733 unmodified lines8971897289738974897589768977897889798980898189828983898489858986898721 unmodified lines9009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190322193 unmodified lines1122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257850 unmodified lines1210812109121101211112112121131211420 unmodified lines1213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215624 unmodified lines1218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203576 unmodified lines12780127811278212783127841278575 unmodified lines1286112862128631286412865128661286712868128691287012871128721287312874128751287612877128782 unmodified lines128811288212883128841288512886128871288812889105 unmodified lines12995129961299712998129991300013001104 unmodified linesprint(" 2. Place this notebook inside the aegis-reason/ directory, OR")print(" 3. Clone: !git clone <repo-url> aegis-reason")DDIR = 'aegis_dataset'# Robust search for aegis_dataset directory (handles HF Spaces path variations)if not os.path.isdir(DDIR):_script_dir = os.path.dirname(os.path.abspath(__file__)) if '__file__' in dir() else os.getcwd()_ddir_candidates = [os.path.join(_script_dir, 'aegis_dataset'),os.path.join(os.getcwd(), 'aegis_dataset'),'/home/user/app/aegis_dataset',os.path.join(REPO, 'aegis_dataset') if REPO else None,]for _dc in _ddir_candidates:if _dc and os.path.isdir(_dc):DDIR = _dcbreak# βββββββββββββββββββββββββββ DESIGN SYSTEM βββββββββββββββββββββββββββ# (rcParams already set above β dark)8701 unmodified linesscene2=_scene( xaxis_title='Pair', yaxis_title='', zaxis_title="Cohen's d"))return fig3d_html(fig)def show_ablation_both():"""Generate both ablation 3D charts: scatter overview + condition/effect-size panels."""return fig3d_html(plotly_ablation_3d()), show_ablation()def show_calibration():"""Interactive 3D calibration: reliability bars + cumulative regret trajectory."""35 unmodified lines**PLOTLY_BASE, height=550)return fig3d_html(fig)def show_calibration_both():"""Generate both calibration 3D charts: landscape overview + reliability/regret panels."""return fig3d_html(plotly_calibration_3d()), show_calibration()def impact_scenario(disaster_name, rescue_boost=0.0):d=IMPACT.get(disaster_name,{})40 unmodified linesdef explore():global DDIR# Fallback search if DDIR doesn't resolve at runtimeif not os.path.isdir(DDIR):_script_dir = os.path.dirname(os.path.abspath(__file__)) if '__file__' in dir() else os.getcwd()for _candidate in [os.path.join(_script_dir, 'aegis_dataset'),os.path.join(os.getcwd(), 'aegis_dataset'),'/home/user/app/aegis_dataset',]:if os.path.isdir(_candidate):DDIR = _candidatebreakif not os.path.isdir(DDIR): return 'β',None,EMPTY_3D_HTMLlines_e=[]for sub in ['topdown','egocentric','chains']:33 unmodified linesdef view_chain(idx):sft=os.path.join(DDIR,'sft_data.jsonl')# Fallback search if primary DDIR doesn't contain sft_data.jsonlif not os.path.exists(sft):_script_dir = os.path.dirname(os.path.abspath(__file__)) if '__file__' in dir() else os.getcwd()for _candidate in [os.path.join(_script_dir, 'aegis_dataset', 'sft_data.jsonl'),os.path.join(os.getcwd(), 'aegis_dataset', 'sft_data.jsonl'),'/home/user/app/aegis_dataset/sft_data.jsonl',]:if os.path.exists(_candidate):sft = _candidatebreakif not os.path.exists(sft): return 'No data.',Nonerecs=[json.loads(l) for l in open(sft)]; idx=max(0,min(int(idx),len(recs)-1)); r=recs[idx]ch=r['conversations'][2]['content']21 unmodified linesreturn f"ID: {r['id']}\n{len(ch)} chars\n\n{ch}",imgdef run_validation():# Resolve the repo root for all relative path lookups_root = REPO or os.path.dirname(os.path.abspath(__file__)) if '__file__' in dir() else os.getcwd()if not _root or not os.path.isdir(_root):_root = os.getcwd()out=['βββ E2E βββ']e2e_path = os.path.join(_root, 'scripts', 'aegis_e2e_test.py')if os.path.exists(e2e_path):r=subprocess.run([sys.executable, e2e_path],capture_output=True,text=True,timeout=300, cwd=_root); out.append(r.stdout[:2000])else: out.append('β Not found')out.append('\nβββ AUDIT βββ'); iss=0for pyf in glob.glob(os.path.join(_root, '*.py'))+glob.glob(os.path.join(_root, 'scripts', '*.py')):for i,ln in enumerate(open(pyf).readlines(),1):if '/home/claude/' in ln and not ln.strip().startswith('#'):out.append(f' β οΈ {os.path.relpath(pyf, _root)}:{i}'); iss+=1if iss==0: out.append(' β Clean')for f in ['README.md','configs/aegis_sft.toml','configs/aegis_grpo.toml','LICENSE','requirements.txt']:fp = os.path.join(_root, f)out.append(f' {"β " if os.path.exists(fp) else "β"} {f}')return '\n'.join(out)# βββ Interactive weight explorer βββ2193 unmodified linesoption { background: #161b22 !important; color: #e6edf3 !important; }/* ββ Sliders ββ */.slider input[type=range], input[type=range] { accent-color: #58a6ff !important; }input[type=range] { -webkit-appearance: none !important; appearance: none !important; background: transparent !important; }input[type=range]::-webkit-slider-runnable-track {background: linear-gradient(90deg, #1f6feb, #58a6ff) !important;height: 6px !important; border-radius: 3px !important; border: none !important;}input[type=range]::-moz-range-track {background: linear-gradient(90deg, #1f6feb, #58a6ff) !important;height: 6px !important; border-radius: 3px !important; border: none !important;}input[type=range]::-webkit-slider-thumb {-webkit-appearance: none !important; appearance: none !important;width: 16px !important; height: 16px !important; border-radius: 50% !important;background: #e6edf3 !important; border: 2px solid #58a6ff !important;margin-top: -5px !important; cursor: pointer !important;box-shadow: 0 0 6px rgba(88,166,255,0.4) !important;}input[type=range]::-moz-range-thumb {width: 16px !important; height: 16px !important; border-radius: 50% !important;background: #e6edf3 !important; border: 2px solid #58a6ff !important;cursor: pointer !important; box-shadow: 0 0 6px rgba(88,166,255,0.4) !important;}input[type=range]::-moz-range-progress {background: linear-gradient(90deg, #1f6feb, #58a6ff) !important;height: 6px !important; border-radius: 3px !important;}input[type=number] { color: #e6edf3 !important; background: #0d1117 !important; }/* ββ Dropdowns ββ */850 unmodified linesfont-weight: 800;}/* ββ Radio Button: Shiny selected dot ββ */.gradio-container input[type="radio"] {-webkit-appearance: none !important;appearance: none !important;20 unmodified linesborder-color: #58a6ff !important;box-shadow: 0 0 6px rgba(88,166,255,0.2) !important;}/* Gradio 6.x Radio β target Svelte-generated radio circle spans */.gradio-container .gr-radio .wrap .item.selected,.gradio-container .radio-group label.selected,.gradio-container [data-testid="radio"] label.selected,.gradio-container .gr-radio label.selected {border-color: #58a6ff !important;background: rgba(88,166,255,0.08) !important;}.gradio-container .gr-radio .wrap .item.selected .circle,.gradio-container .radio-group label.selected span.circle,.gradio-container [data-testid="radio"] label.selected span,.gradio-container .gr-radio label.selected .icon-wrap,.gradio-container .gr-radio .selected .icon {background: radial-gradient(circle at 40% 35%, #79c0ff 0%, #58a6ff 45%, #1f6feb 100%) !important;border-color: #58a6ff !important;box-shadow: 0 0 8px rgba(88,166,255,0.6), 0 0 20px rgba(88,166,255,0.25) !important;}@keyframes radio-pop {0% { transform: scale(0.85); }24 unmodified linesdocument.body.classList.add('dark');document.body.style.background = '#000000';// Force blue radio button fill for Gradio 6.x Svelte componentsconst styleEl = document.createElement('style');styleEl.textContent = `input[type="radio"] {-webkit-appearance: none !important; appearance: none !important;width: 18px !important; height: 18px !important;border: 2px solid #484f58 !important; border-radius: 50% !important;background: transparent !important; cursor: pointer !important;transition: all 0.25s ease !important; flex-shrink: 0 !important;}input[type="radio"]:checked {border-color: #58a6ff !important;background: radial-gradient(circle at 40% 35%, #79c0ff 0%, #58a6ff 45%, #1f6feb 100%) !important;box-shadow: 0 0 8px rgba(88,166,255,0.6), 0 0 20px rgba(88,166,255,0.25), inset 0 -2px 4px rgba(0,0,0,0.3) !important;}`;document.head.appendChild(styleEl);}'''_HERO_BANNER = """<div class="hero-page-wrap">576 unmodified linestags_str = ', '.join(d.get('tags', [])[:4])kb_md += f'| {d["id"]} | {d["title"][:45]} | {d["domain"]} | {tags_str} |\n'gr.Markdown(kb_md)gr.Markdown(f'---\n*AEGIS-Reason Β· CRAG Retrieval Engine Β· {len(KB_DOCS)} documents Γ {len(DOMAINS)} domains Β· P@k={RAG_PREC:.2f} Β· F1={RAG_F1:.3f} Β· [GitHub](https://github.com/AF-mygithub/aegis-reason)*')# ββββββββββββββββ TAB: DYNAMO INFERENCE ββββββββββββββββ75 unmodified lineswith gr.Tab('π¬ Ablation'):gr.Markdown("**Conditions**: A (Oracle) β B (Partial: spatial+decision only) β C (Degraded: shifted coords) β D (Vague)")with gr.Accordion("π Interactive 3D: Ablation Conditions (rotate me!)", open=True):ab_p1=gr.HTML(value=EMPTY_3D_HTML, label='3D Ablation')ab_b=gr.Button('Generate 3D Ablation',variant='primary')ab_p2=gr.HTML(value=EMPTY_3D_HTML, label='3D Interactive Ablation')ab_b.click(fn=_safe(show_ablation_both, lambda e: (EMPTY_3D_HTML, EMPTY_3D_HTML)),outputs=[ab_p1, ab_p2])# ββββββββββββββββ TAB 5: CALCULUS ββββββββββββββββwith gr.Tab('π Calibration'):with gr.Accordion("π Interactive 3D: Calibration (rotate me!)", open=True):cr_p1=gr.HTML(value=EMPTY_3D_HTML, label='3D Calibration')cr_b=gr.Button('Generate 3D Calibration',variant='primary')cr_p2=gr.HTML(value=EMPTY_3D_HTML, label='3D Interactive')cr_b.click(fn=_safe(show_calibration_both, lambda e: (EMPTY_3D_HTML, EMPTY_3D_HTML)),outputs=[cr_p1, cr_p2])# ββββββββββββββββ TAB 10: DATASET ββββββββββββββββwith gr.Tab('π Dataset 3D'):2 unmodified lineseb.click(fn=_safe(explore, lambda e: (e, None, EMPTY_3D_HTML)),outputs=[et,eg,ei])# ββββββββββββββββ TAB 11: VALIDATION ββββββββββββββββwith gr.Tab('π§ Chain Viewer'):with gr.Row(): cx=gr.Slider(0,500,0,step=1,label='Chain Index'); cxb=gr.Button('View',variant='primary')with gr.Row(): cxt=gr.Textbox(label='Reasoning Chain',lines=16,interactive=False); cxi=gr.Image(label='Isometric Frame',width=400)cxb.click(fn=_safe(view_chain, lambda e: (e, None)),inputs=cx,outputs=[cxt,cxi])105 unmodified lineslabel='β‘ Inference Backend')with gr.Row():accel_scenario = gr.Radio(choices=[v['domain'] for v in CR2_HEALTHCARE_SCENARIOS.values()],value=list(CR2_HEALTHCARE_SCENARIOS.values())[0]['domain'],label='π₯ Healthcare Scenario'104 unmodified lines1051061071081091108701 unmodified lines88128813881488158816881735 unmodified lines88538854885588568857885840 unmodified lines88998900890189028903890433 unmodified lines89388939894089418942894321 unmodified lines896589668967896889698970897189728973897489758976897789788979898089812193 unmodified lines11175111761117711178111791118011181850 unmodified lines120321203312034120351203612037120381203920 unmodified lines1206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209624 unmodified lines1212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230576 unmodified lines12807128081280912810128111281212813128141281512816128171281812819128201282175 unmodified lines128971289812899129001290112902129031290412905129061290712908129091291012911129122 unmodified lines129151291612917129181291912920129211292212923105 unmodified lines13029130301303113032130331303413035104 unmodified linesprint(" 2. Place this notebook inside the aegis-reason/ directory, OR")print(" 3. Clone: !git clone <repo-url> aegis-reason")DDIR = 'aegis_dataset'# βββββββββββββββββββββββββββ DESIGN SYSTEM βββββββββββββββββββββββββββ# (rcParams already set above β dark)8701 unmodified linesscene2=_scene( xaxis_title='Pair', yaxis_title='', zaxis_title="Cohen's d"))return fig3d_html(fig)def show_calibration():"""Interactive 3D calibration: reliability bars + cumulative regret trajectory."""35 unmodified lines**PLOTLY_BASE, height=550)return fig3d_html(fig)def impact_scenario(disaster_name, rescue_boost=0.0):d=IMPACT.get(disaster_name,{})40 unmodified linesdef explore():if not os.path.isdir(DDIR): return 'β',None,EMPTY_3D_HTMLlines_e=[]for sub in ['topdown','egocentric','chains']:33 unmodified linesdef view_chain(idx):sft=os.path.join(DDIR,'sft_data.jsonl')if not os.path.exists(sft): return 'No data.',Nonerecs=[json.loads(l) for l in open(sft)]; idx=max(0,min(int(idx),len(recs)-1)); r=recs[idx]ch=r['conversations'][2]['content']21 unmodified linesreturn f"ID: {r['id']}\n{len(ch)} chars\n\n{ch}",imgdef run_validation():out=['βββ E2E βββ']if os.path.exists('scripts/aegis_e2e_test.py'):r=subprocess.run([sys.executable,'scripts/aegis_e2e_test.py'],capture_output=True,text=True,timeout=300); out.append(r.stdout[:2000])else: out.append('β Not found')out.append('\nβββ AUDIT βββ'); iss=0for pyf in glob.glob('*.py')+glob.glob('scripts/*.py'):for i,ln in enumerate(open(pyf).readlines(),1):if '/home/claude/' in ln and not ln.strip().startswith('#'): out.append(f' β οΈ {pyf}:{i}'); iss+=1if iss==0: out.append(' β Clean')for f in ['README.md','configs/aegis_sft.toml','configs/aegis_grpo.toml','LICENSE','requirements.txt']:out.append(f' {"β " if os.path.exists(f) else "β"} {f}')return '\n'.join(out)# βββ Interactive weight explorer βββ2193 unmodified linesoption { background: #161b22 !important; color: #e6edf3 !important; }/* ββ Sliders ββ */.slider input[type=range] { accent-color: #58a6ff !important; }input[type=number] { color: #e6edf3 !important; background: #0d1117 !important; }/* ββ Dropdowns ββ */850 unmodified linesfont-weight: 800;}/* ββ Radio Button & Checkbox: Shiny selected state ββ *//* Native input approach (fallback) */.gradio-container input[type="radio"] {-webkit-appearance: none !important;appearance: none !important;20 unmodified linesborder-color: #58a6ff !important;box-shadow: 0 0 6px rgba(88,166,255,0.2) !important;}/* Checkbox styling */.gradio-container input[type="checkbox"] {-webkit-appearance: none !important;appearance: none !important;width: 18px !important;height: 18px !important;border: 2px solid #484f58 !important;border-radius: 4px !important;background: transparent !important;cursor: pointer !important;transition: all 0.25s ease !important;position: relative !important;flex-shrink: 0 !important;}.gradio-container input[type="checkbox"]:checked {border-color: #58a6ff !important;background: radial-gradient(circle at 40% 35%, #79c0ff 0%, #58a6ff 45%, #1f6feb 100%) !important;box-shadow: 0 0 8px rgba(88,166,255,0.6), 0 0 20px rgba(88,166,255,0.25), inset 0 -2px 4px rgba(0,0,0,0.3) !important;}.gradio-container input[type="checkbox"]:checked:hover {box-shadow: 0 0 12px rgba(88,166,255,0.8), 0 0 28px rgba(88,166,255,0.35), inset 0 -2px 4px rgba(0,0,0,0.3) !important;}.gradio-container input[type="checkbox"]:hover:not(:checked) {border-color: #58a6ff !important;box-shadow: 0 0 6px rgba(88,166,255,0.2) !important;}/* Gradio Svelte radio/checkbox wrapper classes */.gradio-container .gr-radio .wrap label,.gradio-container .radio-group label,.gradio-container [data-testid="radio"] label {cursor: pointer !important;}@keyframes radio-pop {0% { transform: scale(0.85); }24 unmodified linesdocument.body.classList.add('dark');document.body.style.background = '#000000';/* ββ Radio & Checkbox: Inject aggressive styles + MutationObserver ββ */const radioCSS = document.createElement('style');radioCSS.id = 'radio-checkbox-override';radioCSS.textContent = `/* Native radio inputs (Gradio may render these) */input[type="radio"] {-webkit-appearance: none !important;appearance: none !important;width: 18px !important; height: 18px !important;border: 2px solid #484f58 !important;border-radius: 50% !important;background: transparent !important;cursor: pointer !important;transition: all 0.25s ease !important;vertical-align: middle !important;margin: 0 6px 0 0 !important;flex-shrink: 0 !important;}input[type="radio"]:checked {border-color: #58a6ff !important;background: radial-gradient(circle at 40% 35%, #79c0ff 0%, #58a6ff 45%, #1f6feb 100%) !important;box-shadow: 0 0 8px rgba(88,166,255,0.6), 0 0 20px rgba(88,166,255,0.25), inset 0 -2px 4px rgba(0,0,0,0.3) !important;}input[type="radio"]:hover:not(:checked) {border-color: #58a6ff !important;box-shadow: 0 0 6px rgba(88,166,255,0.2) !important;}/* Native checkbox inputs */input[type="checkbox"] {-webkit-appearance: none !important;appearance: none !important;width: 18px !important; height: 18px !important;border: 2px solid #484f58 !important;border-radius: 4px !important;background: transparent !important;cursor: pointer !important;transition: all 0.25s ease !important;vertical-align: middle !important;margin: 0 6px 0 0 !important;flex-shrink: 0 !important;}input[type="checkbox"]:checked {border-color: #58a6ff !important;background: radial-gradient(circle at 40% 35%, #79c0ff 0%, #58a6ff 45%, #1f6feb 100%) !important;box-shadow: 0 0 8px rgba(88,166,255,0.6), 0 0 20px rgba(88,166,255,0.25), inset 0 -2px 4px rgba(0,0,0,0.3) !important;}input[type="checkbox"]:checked::after {content: "β" !important;display: block !important;color: #ffffff !important;font-size: 13px !important;font-weight: 900 !important;text-align: center !important;line-height: 15px !important;}input[type="checkbox"]:hover:not(:checked) {border-color: #58a6ff !important;box-shadow: 0 0 6px rgba(88,166,255,0.2) !important;}/* Gradio Svelte <span class="icon"> inside radio labels β covers custom circle elements */.icon.svelte-1kzox8i, .icon.svelte-1p9cw2g,span[class*="icon"][class*="svelte"],.radio-circle, .radio-dot, .circle-icon {display: none !important;}`;document.head.appendChild(radioCSS);/* Direct inline-style application for radio/checkbox (covers Svelte scoped overrides) */function styleInputs() {document.querySelectorAll('input[type="radio"], input[type="checkbox"]').forEach(el => {const isRadio = el.type === 'radio';el.style.cssText = ['-webkit-appearance: none', 'appearance: none','width: 18px', 'height: 18px','border: 2px solid ' + (el.checked ? '#58a6ff' : '#484f58'),'border-radius: ' + (isRadio ? '50%' : '4px'),'background: ' + (el.checked ? 'radial-gradient(circle at 40% 35%, #79c0ff 0%, #58a6ff 45%, #1f6feb 100%)' : 'transparent'),'box-shadow: ' + (el.checked ? '0 0 8px rgba(88,166,255,0.6), 0 0 20px rgba(88,166,255,0.25), inset 0 -2px 4px rgba(0,0,0,0.3)' : 'none'),'cursor: pointer','transition: all 0.25s ease','vertical-align: middle','margin: 0 6px 0 0','flex-shrink: 0','position: relative'].map(s => s + ' !important').join('; ');});}/* Run immediately, then on every DOM mutation (catches Svelte re-renders) */styleInputs();const obs = new MutationObserver(() => { styleInputs(); });obs.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['checked', 'class'] });/* Also run periodically for 30s to catch late Svelte mounts */let n = 0;const iv = setInterval(() => { styleInputs(); if (++n > 60) clearInterval(iv); }, 500);/* Click handler: re-style after any radio/checkbox interaction */document.addEventListener('change', (e) => {if (e.target && (e.target.type === 'radio' || e.target.type === 'checkbox')) {setTimeout(styleInputs, 50);setTimeout(styleInputs, 200);}}, true);}'''_HERO_BANNER = """<div class="hero-page-wrap">576 unmodified linestags_str = ', '.join(d.get('tags', [])[:4])kb_md += f'| {d["id"]} | {d["title"][:45]} | {d["domain"]} | {tags_str} |\n'gr.Markdown(kb_md)with gr.Accordion('π CRAG Decision Statistics', open=False):dec_total = sum(CRAG_DECISIONS.values()) or 1dec_md = '| Decision | Count | Proportion |\n|----------|-------|------------|\n'for label, count in CRAG_DECISIONS.items():dec_md += f'| {label} | {count} | {count/dec_total:.1%} |\n'dec_md += f'\n**Total queries evaluated**: {len(RAG_QUERIES)} Β· **Total retrievals**: {dec_total}\n\n'dec_md += f'**Domain coverage**: 'dec_md += ' Β· '.join(f'{dom}: {DOMAIN_COVERAGE[dom]} tags' for dom in DOMAINS if dom in DOMAIN_COVERAGE)gr.Markdown(dec_md)gr.Markdown(f'---\n*AEGIS-Reason Β· CRAG Retrieval Engine Β· {len(KB_DOCS)} documents Γ {len(DOMAINS)} domains Β· P@k={RAG_PREC:.2f} Β· F1={RAG_F1:.3f} Β· [GitHub](https://github.com/AF-mygithub/aegis-reason)*')# ββββββββββββββββ TAB: DYNAMO INFERENCE ββββββββββββββββ75 unmodified lineswith gr.Tab('π¬ Ablation'):gr.Markdown("**Conditions**: A (Oracle) β B (Partial: spatial+decision only) β C (Degraded: shifted coords) β D (Vague)")with gr.Accordion("π Interactive 3D: Ablation Conditions (rotate me!)", open=True):gr.HTML(value=fig3d_html(plotly_ablation_3d()), label='3D Ablation')ab_b=gr.Button('Generate 3D Ablation',variant='primary'); ab_p=gr.HTML(value=EMPTY_3D_HTML, label='3D Interactive Ablation')ab_b.click(fn=_safe(show_ablation, lambda e: EMPTY_3D_HTML),outputs=ab_p)# ββββββββββββββββ TAB 5: CALCULUS ββββββββββββββββwith gr.Tab('π Calibration'):with gr.Accordion("π Interactive 3D: Calibration (rotate me!)", open=True):gr.HTML(value=fig3d_html(plotly_calibration_3d()), label='3D Calibration')cr_b=gr.Button('Regenerate 3D Calibration',variant='primary'); cr_p=gr.HTML(value=EMPTY_3D_HTML, label='3D Interactive')cr_b.click(fn=_safe(show_calibration, lambda e: EMPTY_3D_HTML),outputs=cr_p)# ββββββββββββββββ TAB 10: DATASET ββββββββββββββββwith gr.Tab('π Dataset 3D'):2 unmodified lineseb.click(fn=_safe(explore, lambda e: (e, None, EMPTY_3D_HTML)),outputs=[et,eg,ei])# ββββββββββββββββ TAB 11: VALIDATION ββββββββββββββββwith gr.Tab('π§ Chain Viewer 3D'):with gr.Row(): cx=gr.Slider(0,500,0,step=1,label='Chain Index'); cxb=gr.Button('View',variant='primary')with gr.Row(): cxt=gr.Textbox(label='Reasoning Chain',lines=16,interactive=False); cxi=gr.Image(label='3D Isometric Frame',width=400)cxb.click(fn=_safe(view_chain, lambda e: (e, None)),inputs=cx,outputs=[cxt,cxi])105 unmodified lineslabel='β‘ Inference Backend')with gr.Row():accel_scenario = gr.Dropdown(choices=[v['domain'] for v in CR2_HEALTHCARE_SCENARIOS.values()],value=list(CR2_HEALTHCARE_SCENARIOS.values())[0]['domain'],label='π₯ Healthcare Scenario'
app.py+149-115