Ali2206 commited on
Commit
3ae42d2
·
verified ·
1 Parent(s): 1c8dce8

Update ui/ui_core.py

Browse files
Files changed (1) hide show
  1. ui/ui_core.py +10 -7
ui/ui_core.py CHANGED
@@ -44,8 +44,8 @@ def extract_all_text_from_pdf(file_path, progress=None, index=0, total=1):
44
 
45
  def create_ui(agent: TxAgent):
46
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
47
- gr.Markdown("<h1 style='text-align: center;'>💊 TxAgent: Therapeutic Reasoning</h1>")
48
- chatbot = gr.Chatbot(label="TxAgent", height=600, type="messages")
49
 
50
  file_upload = gr.File(
51
  label="Upload Medical File",
@@ -58,9 +58,10 @@ def create_ui(agent: TxAgent):
58
 
59
  def handle_chat(message, history, conversation, uploaded_files, progress=gr.Progress()):
60
  context = (
61
- "You are a clinical AI reviewing medical interview or form data. "
62
- "Analyze the extracted content and reason step-by-step about what the doctor could have missed. "
63
- "Don't answer yet just reason."
 
64
  )
65
 
66
  if uploaded_files:
@@ -78,7 +79,7 @@ def create_ui(agent: TxAgent):
78
  if progress:
79
  progress((index + 1) / total_files, desc=f"Skipping unsupported file: {os.path.basename(path)}")
80
 
81
- message = f"{context}\n\n---\n{extracted_text.strip()}\n---\n\nNow reason what the doctor might have missed."
82
 
83
  generator = agent.run_gradio_chat(
84
  message=message,
@@ -99,7 +100,9 @@ def create_ui(agent: TxAgent):
99
  message_input.submit(fn=handle_chat, inputs=inputs, outputs=chatbot)
100
 
101
  gr.Examples([
102
- ["Upload the files"],
 
 
103
  ], inputs=message_input)
104
 
105
  return demo
 
44
 
45
  def create_ui(agent: TxAgent):
46
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
47
+ gr.Markdown("<h1 style='text-align: center;'>📋 CPS: Clinical Patient Support System</h1>")
48
+ chatbot = gr.Chatbot(label="CPS Assistant", height=600, type="messages")
49
 
50
  file_upload = gr.File(
51
  label="Upload Medical File",
 
58
 
59
  def handle_chat(message, history, conversation, uploaded_files, progress=gr.Progress()):
60
  context = (
61
+ "You are an advanced clinical reasoning AI. You have just received raw medical data extracted from patient forms, lab reports, or interview tables. "
62
+ "Your goal is to analyze this data like a clinical expert. Go step by step to detect patterns, spot unusual or missing info, and identify clinical red flags "
63
+ "or overlooked findings. Use medically grounded reasoning. Be detailed. At the end, explain what the doctor may have missed and why it matters. "
64
+ "Include examples, reference clinical logic, and suggest what should have been asked or done. This response will help improve real-world diagnostics."
65
  )
66
 
67
  if uploaded_files:
 
79
  if progress:
80
  progress((index + 1) / total_files, desc=f"Skipping unsupported file: {os.path.basename(path)}")
81
 
82
+ message = f"{context}\n\n---\n{extracted_text.strip()}\n---\n\nBegin your reasoning."
83
 
84
  generator = agent.run_gradio_chat(
85
  message=message,
 
100
  message_input.submit(fn=handle_chat, inputs=inputs, outputs=chatbot)
101
 
102
  gr.Examples([
103
+ ["Upload your medical form and ask what the doctor might’ve missed."],
104
+ ["This patient was treated with antibiotics for UTI. What else should we check?"],
105
+ ["Is there anything abnormal in the attached blood work report?"]
106
  ], inputs=message_input)
107
 
108
  return demo