Spaces:
Runtime error
Runtime error
Commit
·
2401693
1
Parent(s):
d25cc99
added multiple iterations feature
Browse files
app.py
CHANGED
|
@@ -151,6 +151,7 @@ diagnosis = ""
|
|
| 151 |
def simulate_interaction(user_input, iterations=1):
|
| 152 |
history = [f"Doctor: What brings you in today?", f"Patient: {user_input}"]
|
| 153 |
summary, diagnosis = "", ""
|
|
|
|
| 154 |
|
| 155 |
for i in range(iterations):
|
| 156 |
# Summarize
|
|
@@ -166,20 +167,21 @@ def simulate_interaction(user_input, iterations=1):
|
|
| 166 |
q_in = f"Vignette: {summary}\nCurrent Estimated Diagnosis: {diag_out['thinking']} {diagnosis}"
|
| 167 |
q_out = questioner.act(q_in)
|
| 168 |
history.append(f"Doctor: {q_out['output']}")
|
| 169 |
-
|
|
|
|
| 170 |
|
| 171 |
# Treatment
|
| 172 |
treatment_out = treatment_agent.act(
|
| 173 |
f"Diagnosis: {diagnosis}\nVignette: {summary}"
|
| 174 |
)
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
|
| 184 |
|
| 185 |
# === Gradio UI ===
|
|
|
|
| 151 |
def simulate_interaction(user_input, iterations=1):
|
| 152 |
history = [f"Doctor: What brings you in today?", f"Patient: {user_input}"]
|
| 153 |
summary, diagnosis = "", ""
|
| 154 |
+
treatment_out = None
|
| 155 |
|
| 156 |
for i in range(iterations):
|
| 157 |
# Summarize
|
|
|
|
| 167 |
q_in = f"Vignette: {summary}\nCurrent Estimated Diagnosis: {diag_out['thinking']} {diagnosis}"
|
| 168 |
q_out = questioner.act(q_in)
|
| 169 |
history.append(f"Doctor: {q_out['output']}")
|
| 170 |
+
# Append actual user input to keep the conversation realistic
|
| 171 |
+
history.append(f"Patient: {user_input}")
|
| 172 |
|
| 173 |
# Treatment
|
| 174 |
treatment_out = treatment_agent.act(
|
| 175 |
f"Diagnosis: {diagnosis}\nVignette: {summary}"
|
| 176 |
)
|
| 177 |
|
| 178 |
+
return {
|
| 179 |
+
"summary": sum_out,
|
| 180 |
+
"diagnosis": diag_out,
|
| 181 |
+
"question": q_out,
|
| 182 |
+
"treatment": treatment_out,
|
| 183 |
+
"conversation": "\n".join(history),
|
| 184 |
+
}
|
| 185 |
|
| 186 |
|
| 187 |
# === Gradio UI ===
|