Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +69 -34
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,75 @@
|
|
| 1 |
-
import altair as alt
|
| 2 |
-
import numpy as np
|
| 3 |
-
import pandas as pd
|
| 4 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
|
| 11 |
-
forums](https://discuss.streamlit.io).
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
"""
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
"
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
st.
|
| 34 |
-
.
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
from google import genai
|
| 4 |
+
from google.genai import types
|
| 5 |
|
| 6 |
+
# --- 1. CONFIG & UI SETUP ---
|
| 7 |
+
st.set_page_config(page_title="Abyssinia Scribe", page_icon="π", layout="wide")
|
| 8 |
+
|
| 9 |
+
# Custom CSS for a professional medical dashboard
|
| 10 |
+
st.markdown("""
|
| 11 |
+
<style>
|
| 12 |
+
.reportview-container { background: #fdfdfd; }
|
| 13 |
+
.stTextArea textarea { font-family: 'Courier New', monospace; font-size: 14px; }
|
| 14 |
+
</style>
|
| 15 |
+
""", unsafe_allow_html=True)
|
| 16 |
|
| 17 |
+
client = genai.Client(api_key=os.environ.get("GOOGLE_API_KEY"))
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# --- 2. CORE SCRIBE LOGIC ---
|
| 20 |
+
SCRIBE_PROMPT = """
|
| 21 |
+
Act as an expert Clinical Scribe for Abyssinia Intelligence.
|
| 22 |
+
Analyze the provided medical transcript or summary and produce a high-fidelity SOAP note.
|
| 23 |
+
Ensure all medical terms are standardized (ICD-11/SNOMED).
|
| 24 |
"""
|
| 25 |
|
| 26 |
+
st.title("π₯ Abyssinia Intelligence Scribe")
|
| 27 |
+
st.info("Clinical Documentation & SOAP Note Automation System")
|
| 28 |
+
|
| 29 |
+
# Layout: 2 Columns (Input | Output)
|
| 30 |
+
col1, col2 = st.columns([1, 1], gap="large")
|
| 31 |
+
|
| 32 |
+
with col1:
|
| 33 |
+
st.subheader("π Clinical Input")
|
| 34 |
+
input_text = st.text_area("Patient Encounter / Transcript:", height=450,
|
| 35 |
+
placeholder="Patient presents with 3 days of productive cough and low-grade fever...")
|
| 36 |
+
|
| 37 |
+
# Advanced 2026 Settings
|
| 38 |
+
with st.expander("Scribe Engine Settings"):
|
| 39 |
+
reasoning_depth = st.select_slider("Reasoning Depth", options=["low", "high"], value="high")
|
| 40 |
+
specialty = st.selectbox("Medical Specialty", ["General Practice", "Cardiology", "Pediatrics"])
|
| 41 |
+
|
| 42 |
+
with col2:
|
| 43 |
+
st.subheader("π Structured SOAP Note")
|
| 44 |
+
if st.button("Generate Final Note", type="primary"):
|
| 45 |
+
if input_text:
|
| 46 |
+
with st.spinner("Abyssinia AI is analyzing clinical data..."):
|
| 47 |
+
try:
|
| 48 |
+
# Utilizing Gemini 3.0 Flash with Thinking Level
|
| 49 |
+
response = client.models.generate_content(
|
| 50 |
+
model="gemini-3-flash-preview",
|
| 51 |
+
config=types.GenerateContentConfig(
|
| 52 |
+
system_instruction=f"{SCRIBE_PROMPT} Context: {specialty}",
|
| 53 |
+
thinking_config=types.ThinkingConfig(
|
| 54 |
+
thinking_level=reasoning_depth
|
| 55 |
+
),
|
| 56 |
+
temperature=0.2, # Low temperature for medical precision
|
| 57 |
+
),
|
| 58 |
+
contents=input_text
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
st.success("Analysis Complete")
|
| 62 |
+
final_note = response.text
|
| 63 |
+
st.text_area("Review/Edit Note:", value=final_note, height=450)
|
| 64 |
+
|
| 65 |
+
# Download Feature
|
| 66 |
+
st.download_button("Export as TXT", final_note, file_name="Abyssinia_Note.txt")
|
| 67 |
+
|
| 68 |
+
except Exception as e:
|
| 69 |
+
st.error(f"Scribe Error: {e}")
|
| 70 |
+
else:
|
| 71 |
+
st.warning("Please enter encounter data first.")
|
| 72 |
+
|
| 73 |
+
# --- 3. AUDIT TRAIL ---
|
| 74 |
+
st.markdown("---")
|
| 75 |
+
st.caption("Abyssinia Scribe | v3.0-Flash | Powered by AHRI (Ethiopia)")
|