-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
67 lines (56 loc) · 2.18 KB
/
app.py
File metadata and controls
67 lines (56 loc) · 2.18 KB
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
import sys
import torch
sys.modules["torch.classes"] = torch.classes = type("classes", (), {"__path__": []})()
import streamlit as st
from src.retriever import Retriever
from src.generator import Generator
# 🎨 Custom CSS
st.markdown("""
<style>
.main { background-color: #f5f7fa; font-family: 'Segoe UI', sans-serif; }
h1, h2, h3 { color: #0F52BA; }
.stButton>button {
background-color: #0F52BA;
color: white;
border-radius: 10px;
padding: 10px 20px;
}
.stTextInput>div>div>input {
border-radius: 10px;
padding: 10px;
border: 1px solid #ccc;
}
</style>
""", unsafe_allow_html=True)
# 🖼️ Optional Banner
st.image("assets/banner.png", use_container_width=True)
# 🩺 Title
st.title("🩺 RAGnosis: Know More. Diagnose Better.")
st.markdown("Enter a clinical query to retrieve relevant patient cases and generate diagnostic insights.")
# 📥 Input
query = st.text_input("🔍 Clinical Query", placeholder="e.g., What is the cause of the patient's shortness of breath?")
# 📌 Sidebar
st.sidebar.title("ℹ️ Instructions")
st.sidebar.markdown("""
- Enter a clinical question based on patient symptoms, history, or labs.
- The system retrieves relevant patient cases.
- It uses an AI model to generate a diagnosis or reasoning.
""")
# 🚀 Trigger RAG
if query:
with st.spinner("🔍 Retrieving relevant clinical cases..."):
retriever = Retriever()
docs = retriever.search(query)
contexts = docs["text"].tolist()
st.markdown("### 📄 Top Retrieved Clinical Notes:")
for i, ctx in enumerate(contexts):
with st.expander(f"Context {i+1}"):
st.code(ctx[:1000], language="text")
with st.spinner("💡 Generating diagnostic insight..."):
generator = Generator()
answer = generator.generate(query, contexts)
st.markdown("### ✅ AI-Suggested Diagnosis:")
st.success(answer)
# 📎 Footer
st.markdown("""---""")
st.markdown("Made with ❤️ by **Absar Raashid** | Clinical RAG | [GitHub](https://github.com/AbsarRaashid3)")