File size: 3,329 Bytes
a91d88d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""
Human+ Lab-to-Protocol AI
Entry point β€” konfigurasi, health check, session state, routing.
Semua logic ada di core/, UI ada di ui/, pages ada di pages/.
"""

import streamlit as st
import warnings

warnings.filterwarnings("ignore", category=UserWarning)
warnings.filterwarnings("ignore", message=".*torchvision.*")
warnings.filterwarnings("ignore", message=".*UNEXPECTED.*")

# ── Page config (HARUS pertama) ────────────────────────────────────
st.set_page_config(
    page_title="Human+ Lab-to-Protocol AI",
    page_icon="🧬",
    layout="centered",
    initial_sidebar_state="collapsed",
    menu_items={
        "Get Help": "https://instagram.com/bennywhitethatsright",
        "Report a bug": None,
        "About": "Human+ Bali β€” From Injured β†’ Optimized",
    },
)

# ── Inject global CSS ──────────────────────────────────────────────
from ui.styles import inject_custom_css
inject_custom_css()

# ── Health check: Gemini API key ───────────────────────────────────
from core.ai_client import check_client_health
client_ok, client_msg = check_client_health()

if not client_ok:
    st.markdown("""
    <div style="
        background:rgba(239,68,68,0.08); border:1px solid rgba(239,68,68,0.25);
        border-radius:14px; padding:24px; text-align:center; margin:40px 0
    ">
        <div style="font-size:1.8rem; margin-bottom:12px">πŸ”‘</div>
        <div style="font-family:'DM Sans',sans-serif; font-weight:700;
                    color:#ef4444; font-size:1rem; margin-bottom:8px">
            GEMINI_API_KEY Tidak Ditemukan
        </div>
        <div style="font-family:'DM Sans',sans-serif; font-size:0.85rem;
                    color:#8b8ba7; line-height:1.5">
            Tambahkan <code>GEMINI_API_KEY</code> di:<br>
            HuggingFace Space β†’ Settings β†’ Repository Secrets
        </div>
    </div>
    """, unsafe_allow_html=True)
    st.stop()

# ── Global session state defaults ─────────────────────────────────
_defaults = {
    "step":                 1,
    "uploaded_pdf_bytes":   None,
    "extracted_biomarkers": None,
    "generated_protocol":   None,
    "pdf_filename":         None,
}
for key, val in _defaults.items():
    if key not in st.session_state:
        st.session_state[key] = val

# ── Render hero & step indicator ──────────────────────────────────
from ui.components import render_hero, render_step_indicator, render_footer

render_hero()
render_step_indicator(st.session_state.step)

# ── Route to current step ──────────────────────────────────────────
step = st.session_state.step

if step == 1:
    from pages.upload import render_upload_page
    render_upload_page()

elif step == 2:
    from pages.analysis import render_analysis_page
    render_analysis_page()

elif step == 3:
    from pages.protocol import render_protocol_page
    render_protocol_page()

render_footer()