Update app.py
Browse files
app.py
CHANGED
@@ -87,20 +87,19 @@ def build_prompt_from_text(chunk: str) -> str:
|
|
87 |
return f"""
|
88 |
### Unstructured Clinical Records
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
**Objective:** Identify patterns, missed diagnoses, inconsistencies, and follow-up gaps.
|
93 |
-
|
94 |
-
Here is the extracted content chunk:
|
95 |
-
|
96 |
-
{chunk}
|
97 |
-
|
98 |
-
Please analyze the above and provide:
|
99 |
- Diagnostic Patterns
|
100 |
- Medication Issues
|
101 |
- Missed Opportunities
|
102 |
- Inconsistencies
|
103 |
- Follow-up Recommendations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
"""
|
105 |
|
106 |
def init_agent():
|
@@ -177,7 +176,7 @@ def process_final_report(agent, file, chatbot_state: List[Dict[str, str]]) -> Tu
|
|
177 |
return messages, report_path
|
178 |
|
179 |
summary = "\n\n".join(valid_responses)
|
180 |
-
final_prompt = f"
|
181 |
messages.append({"role": "assistant", "content": "📊 Generating final report..."})
|
182 |
|
183 |
final_report_text = ""
|
@@ -215,37 +214,44 @@ def process_final_report(agent, file, chatbot_state: List[Dict[str, str]]) -> Tu
|
|
215 |
def create_ui(agent):
|
216 |
with gr.Blocks(css="""
|
217 |
html, body, .gradio-container {
|
218 |
-
height:
|
219 |
-
width:
|
220 |
-
margin: 0;
|
221 |
padding: 0;
|
222 |
-
|
223 |
-
|
|
|
224 |
}
|
225 |
.gr-button.primary {
|
226 |
-
background:
|
227 |
-
color:
|
228 |
-
|
229 |
border-radius: 6px;
|
|
|
230 |
}
|
231 |
-
.gr-
|
232 |
-
background
|
233 |
-
border-radius: 10px;
|
234 |
-
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
235 |
}
|
236 |
.gr-chatbot {
|
237 |
-
border
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
""") as demo:
|
241 |
gr.Markdown("""
|
242 |
-
<h2 style='color:#
|
243 |
-
<p
|
244 |
""")
|
245 |
|
246 |
with gr.Row():
|
247 |
with gr.Column(scale=3):
|
248 |
-
chatbot = gr.Chatbot(label="Clinical Assistant", height=
|
249 |
with gr.Column(scale=1):
|
250 |
file_upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
|
251 |
analyze_btn = gr.Button("🧠 Analyze", variant="primary")
|
|
|
87 |
return f"""
|
88 |
### Unstructured Clinical Records
|
89 |
|
90 |
+
Analyze the following clinical notes and provide a detailed, concise summary focusing on:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
- Diagnostic Patterns
|
92 |
- Medication Issues
|
93 |
- Missed Opportunities
|
94 |
- Inconsistencies
|
95 |
- Follow-up Recommendations
|
96 |
+
|
97 |
+
---
|
98 |
+
|
99 |
+
{chunk}
|
100 |
+
|
101 |
+
---
|
102 |
+
Respond in well-structured bullet points with medical reasoning.
|
103 |
"""
|
104 |
|
105 |
def init_agent():
|
|
|
176 |
return messages, report_path
|
177 |
|
178 |
summary = "\n\n".join(valid_responses)
|
179 |
+
final_prompt = f"Provide a structured, consolidated clinical analysis from these results:\n\n{summary}"
|
180 |
messages.append({"role": "assistant", "content": "📊 Generating final report..."})
|
181 |
|
182 |
final_report_text = ""
|
|
|
214 |
def create_ui(agent):
|
215 |
with gr.Blocks(css="""
|
216 |
html, body, .gradio-container {
|
217 |
+
height: 100vh;
|
218 |
+
width: 100vw;
|
|
|
219 |
padding: 0;
|
220 |
+
margin: 0;
|
221 |
+
font-family: 'Inter', sans-serif;
|
222 |
+
background: #ffffff;
|
223 |
}
|
224 |
.gr-button.primary {
|
225 |
+
background: #1e88e5;
|
226 |
+
color: #fff;
|
227 |
+
border: none;
|
228 |
border-radius: 6px;
|
229 |
+
font-weight: 600;
|
230 |
}
|
231 |
+
.gr-button.primary:hover {
|
232 |
+
background: #1565c0;
|
|
|
|
|
233 |
}
|
234 |
.gr-chatbot {
|
235 |
+
border: 1px solid #e0e0e0;
|
236 |
+
background: #f9f9f9;
|
237 |
+
border-radius: 10px;
|
238 |
+
padding: 1rem;
|
239 |
+
font-size: 15px;
|
240 |
+
}
|
241 |
+
.gr-markdown, .gr-file-upload {
|
242 |
+
background: #ffffff;
|
243 |
+
border-radius: 8px;
|
244 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.08);
|
245 |
}
|
246 |
""") as demo:
|
247 |
gr.Markdown("""
|
248 |
+
<h2 style='color:#1e88e5'>🩺 Patient History AI Assistant</h2>
|
249 |
+
<p>Upload a clinical Excel file and receive an advanced diagnostic summary.</p>
|
250 |
""")
|
251 |
|
252 |
with gr.Row():
|
253 |
with gr.Column(scale=3):
|
254 |
+
chatbot = gr.Chatbot(label="Clinical Assistant", height=700, type="messages")
|
255 |
with gr.Column(scale=1):
|
256 |
file_upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
|
257 |
analyze_btn = gr.Button("🧠 Analyze", variant="primary")
|