Ali2206 commited on
Commit
b929a03
·
verified ·
1 Parent(s): 3e386fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -27
app.py CHANGED
@@ -87,20 +87,19 @@ def build_prompt_from_text(chunk: str) -> str:
87
  return f"""
88
  ### Unstructured Clinical Records
89
 
90
- You are reviewing unstructured, mixed-format clinical documentation from various forms, tables, and sheets.
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"Summarize the key findings from the following analyses:\n\n{summary}"
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: 100% !important;
219
- width: 100% !important;
220
- margin: 0;
221
  padding: 0;
222
- font-family: 'Segoe UI', sans-serif;
223
- background-color: #f0f2f5;
 
224
  }
225
  .gr-button.primary {
226
- background: linear-gradient(to right, #5c6bc0, #3949ab);
227
- color: white;
228
- font-weight: bold;
229
  border-radius: 6px;
 
230
  }
231
- .gr-chatbot, .gr-markdown, .gr-file-upload {
232
- background-color: white;
233
- border-radius: 10px;
234
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
235
  }
236
  .gr-chatbot {
237
- border-left: 4px solid #5c6bc0;
238
- padding: 0.5rem;
 
 
 
 
 
 
 
 
239
  }
240
  """) as demo:
241
  gr.Markdown("""
242
- <h2 style='color:#3949ab; margin-bottom: 0.5em;'>🏥 Patient History Analysis Tool</h2>
243
- <p style='color:#333; font-size: 1rem;'>Upload an Excel file to receive a structured, professional diagnostic summary.</p>
244
  """)
245
 
246
  with gr.Row():
247
  with gr.Column(scale=3):
248
- chatbot = gr.Chatbot(label="Clinical Assistant", height=650, type="messages")
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")