--- title: Ai Econsult Demo emoji: 🚀 colorFrom: red colorTo: red sdk: streamlit app_port: 8501 tags: - streamlit pinned: false short_description: Streamlit template space sdk_version: 1.51.0 --- # AI‑Native E‑Consult Prototype (V1) This Space hosts a Streamlit app for an AI‑native e‑consult workflow (PCP ↔ Specialist). - **UI:** Streamlit - **AI:** MedGemma‑27B‑text + optional RAG grounding - **Storage:** Hugging Face Spaces persistent volume (`/data/econsult/...`) ## Modes available - **🧠 Guideline‑grounded (RAG):** Injects top guideline snippets into the prompt. Expects inline bracket citations `[1]..[k]` plus a compact reference list. - **✨ AI‑only (post‑hoc):** No in‑prompt evidence. Performs post‑hoc claim→guideline mapping and returns a compact reference list. > The previous **Hybrid (AI → RAG)** option has been removed (redundant for this prototype). ## Hardware - Primary: **1× L40s** (works well for `google/medgemma-27b-text-it`) - Optional upgrade: **A100 (large)** - Budget fallback for demos: **L4** with `google/medgemma-4b-it` > CPU fallback is supported **for resilience only** and will cap tokens for responsiveness. You can disable CPU generation with `ALLOW_CPU_GENERATION=false`. ## Setup 1. Add your Hugging Face token in **Settings → Variables** as `HF_TOKEN` (required to pull gated models). 2. (Optional) Set environment variables: - `ALLOW_CPU_GENERATION=true|false` (default: `true`) - `FORCE_CPU_LLM=1` to force CPU fallback to the 4B model - `MODEL_FALLBACK_ID=google/medgemma-4b-it` to override the fallback id 3. Upload guideline PDFs on the **“Step 1 – RAG Corpus Prep”** page. Filenames should follow: `[specialty]_guideline_[condition]_year.pdf` ## What changed in this revision - Removed **AI triage** across UI and storage. The PCP must choose a **Consult specialty**. - Removed the **Hybrid** button on the Specialist tab. - Added a **demo‑only / de‑identified** banner to all pages. - Preserved citations from AI‑only generation (post‑hoc mapping). - Improved guideline filename parsing to your taxonomy (`[specialty]_guideline_...`). - Added a per‑specialty count widget on the RAG page. - Cleaned up docs for native Spaces runtime. **Removed the Dockerfile** (not used). ## Notes - This prototype is **not for clinical use**. Use only de‑identified/mock data in demos. - After you confirm stability on Spaces, we can pin dependency minor versions for reproducibility.