Ali2206 commited on
Commit
ac2fc78
·
verified ·
1 Parent(s): 6eaf941

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -162,7 +162,10 @@ def process_final_report(agent, file, chatbot_state: List[Tuple[str, str]]) -> T
162
  with open(report_path, 'w') as f:
163
  f.write(f"# 🧠 Final Patient Report\n\n{cleaned}")
164
 
 
165
  messages.append(("assistant", f"✅ Report generated and saved: {os.path.basename(report_path)}"))
 
 
166
  return messages, report_path, cleaned
167
 
168
  def create_ui(agent):
@@ -201,12 +204,18 @@ def create_ui(agent):
201
  .gr-button:hover {
202
  background: linear-gradient(135deg, #37b6e9, #4b4ced);
203
  }
 
 
 
 
 
 
 
204
  """) as demo:
205
  gr.Markdown("""# 🧠 Clinical Reasoning Assistant
206
  Upload clinical Excel records below and click **Analyze** to generate a medical summary.
207
  """)
208
  chatbot = gr.Chatbot(label="Chatbot", elem_classes="chatbot", type="tuples")
209
- report_output_markdown = gr.Markdown(visible=False)
210
  file_upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
211
  analyze_btn = gr.Button("Analyze")
212
  report_output = gr.File(label="Download Report", visible=False)
@@ -214,12 +223,12 @@ Upload clinical Excel records below and click **Analyze** to generate a medical
214
 
215
  def update_ui(file, current_state):
216
  messages, report_path, final_text = process_final_report(agent, file, current_state)
217
- return messages, gr.update(visible=report_path is not None, value=report_path), messages, gr.update(visible=True, value=final_text)
218
 
219
  analyze_btn.click(
220
  fn=update_ui,
221
  inputs=[file_upload, chatbot_state],
222
- outputs=[chatbot, report_output, chatbot_state, report_output_markdown]
223
  )
224
 
225
  return demo
@@ -231,4 +240,4 @@ if __name__ == "__main__":
231
  demo.launch(server_name="0.0.0.0", server_port=7860, allowed_paths=["/data/hf_cache/reports"], share=False)
232
  except Exception as e:
233
  print(f"Error: {str(e)}")
234
- sys.exit(1)
 
162
  with open(report_path, 'w') as f:
163
  f.write(f"# 🧠 Final Patient Report\n\n{cleaned}")
164
 
165
+ # Add the report content to the chat messages
166
  messages.append(("assistant", f"✅ Report generated and saved: {os.path.basename(report_path)}"))
167
+ messages.append(("assistant", f"## Final Report\n\n{cleaned}"))
168
+
169
  return messages, report_path, cleaned
170
 
171
  def create_ui(agent):
 
204
  .gr-button:hover {
205
  background: linear-gradient(135deg, #37b6e9, #4b4ced);
206
  }
207
+ .report-content {
208
+ background-color: #1a1f2e;
209
+ padding: 15px;
210
+ border-radius: 8px;
211
+ margin-top: 10px;
212
+ border: 1px solid #2c3344;
213
+ }
214
  """) as demo:
215
  gr.Markdown("""# 🧠 Clinical Reasoning Assistant
216
  Upload clinical Excel records below and click **Analyze** to generate a medical summary.
217
  """)
218
  chatbot = gr.Chatbot(label="Chatbot", elem_classes="chatbot", type="tuples")
 
219
  file_upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
220
  analyze_btn = gr.Button("Analyze")
221
  report_output = gr.File(label="Download Report", visible=False)
 
223
 
224
  def update_ui(file, current_state):
225
  messages, report_path, final_text = process_final_report(agent, file, current_state)
226
+ return messages, gr.update(visible=report_path is not None, value=report_path), messages
227
 
228
  analyze_btn.click(
229
  fn=update_ui,
230
  inputs=[file_upload, chatbot_state],
231
+ outputs=[chatbot, report_output, chatbot_state]
232
  )
233
 
234
  return demo
 
240
  demo.launch(server_name="0.0.0.0", server_port=7860, allowed_paths=["/data/hf_cache/reports"], share=False)
241
  except Exception as e:
242
  print(f"Error: {str(e)}")
243
+ sys.exit(1)