dawit45 commited on
Commit
13b80b5
Β·
verified Β·
1 Parent(s): dc1618e

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- # Welcome to Streamlit!
 
 
 
 
 
 
 
 
8
 
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
 
13
- In the meantime, below is an example of what you can do with just a few lines of code:
 
 
 
 
14
  """
15
 
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
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)")