Spaces:
Paused
Paused
Commit
·
19f6384
1
Parent(s):
c20d411
switched duplicates
Browse files
app.py
CHANGED
@@ -176,8 +176,6 @@ def simulate_interaction(user_input, iterations=1):
|
|
176 |
q_in = f"Vignette: {summary}\n" f"Current Estimated Diagnosis:\n" f"{diagnosis}"
|
177 |
q_out = questioner.act(q_in)
|
178 |
history.append(f"Doctor: {q_out['output']}")
|
179 |
-
# Append actual user input to keep the conversation realistic
|
180 |
-
history.append(f"Patient: {user_input}")
|
181 |
|
182 |
# Treatment
|
183 |
treatment_out = treatment_agent.act(f"Diagnosis: {diagnosis}\n")
|
@@ -213,6 +211,7 @@ ANSWER: {res['question']['output']}
|
|
213 |
{res['conversation']}
|
214 |
"""
|
215 |
|
|
|
216 |
# === Stateful Gradio UI ===
|
217 |
def stateful_ui_fn(user_input, history):
|
218 |
# Initialize or retrieve history list
|
@@ -222,7 +221,7 @@ def stateful_ui_fn(user_input, history):
|
|
222 |
# Run one round of simulation
|
223 |
res = simulate_interaction(user_input)
|
224 |
# Extract last doctor line from the fresh conversation
|
225 |
-
last_line = res[
|
226 |
# Append the doctor's new line
|
227 |
history.append(last_line)
|
228 |
# Build the displayed conversation
|
@@ -230,6 +229,7 @@ def stateful_ui_fn(user_input, history):
|
|
230 |
# Return both the display text and updated history
|
231 |
return convo, history
|
232 |
|
|
|
233 |
demo = gr.Interface(
|
234 |
fn=stateful_ui_fn,
|
235 |
inputs=[
|
@@ -238,7 +238,7 @@ demo = gr.Interface(
|
|
238 |
],
|
239 |
outputs=[
|
240 |
gr.Textbox(label="Doctor Simulation Output"),
|
241 |
-
gr.State(),
|
242 |
],
|
243 |
title="🧠 AI Doctor Multi-Agent Reasoning",
|
244 |
)
|
|
|
176 |
q_in = f"Vignette: {summary}\n" f"Current Estimated Diagnosis:\n" f"{diagnosis}"
|
177 |
q_out = questioner.act(q_in)
|
178 |
history.append(f"Doctor: {q_out['output']}")
|
|
|
|
|
179 |
|
180 |
# Treatment
|
181 |
treatment_out = treatment_agent.act(f"Diagnosis: {diagnosis}\n")
|
|
|
211 |
{res['conversation']}
|
212 |
"""
|
213 |
|
214 |
+
|
215 |
# === Stateful Gradio UI ===
|
216 |
def stateful_ui_fn(user_input, history):
|
217 |
# Initialize or retrieve history list
|
|
|
221 |
# Run one round of simulation
|
222 |
res = simulate_interaction(user_input)
|
223 |
# Extract last doctor line from the fresh conversation
|
224 |
+
last_line = res["q_out"].splitlines()[-1]
|
225 |
# Append the doctor's new line
|
226 |
history.append(last_line)
|
227 |
# Build the displayed conversation
|
|
|
229 |
# Return both the display text and updated history
|
230 |
return convo, history
|
231 |
|
232 |
+
|
233 |
demo = gr.Interface(
|
234 |
fn=stateful_ui_fn,
|
235 |
inputs=[
|
|
|
238 |
],
|
239 |
outputs=[
|
240 |
gr.Textbox(label="Doctor Simulation Output"),
|
241 |
+
gr.State(), # returns the updated history
|
242 |
],
|
243 |
title="🧠 AI Doctor Multi-Agent Reasoning",
|
244 |
)
|