Spaces:
Paused
Paused
Commit
·
01e6a62
1
Parent(s):
678ce59
fixed local running bug
Browse files
app.py
CHANGED
@@ -78,15 +78,20 @@ class RoleAgent:
|
|
78 |
|
79 |
# === Agents ===
|
80 |
summarizer = RoleAgent(
|
81 |
-
"You are a clinical summarizer trained to extract structured vignettes from doctor–patient dialogues."
|
|
|
|
|
82 |
)
|
83 |
diagnoser = RoleAgent(
|
84 |
-
"You are a board-certified diagnostician that diagnoses patients."
|
|
|
|
|
|
|
85 |
)
|
86 |
-
questioner = RoleAgent("You are a physician asking questions to diagnose a patient.")
|
87 |
-
|
88 |
treatment_agent = RoleAgent(
|
89 |
-
"You are a board-certified clinician. Based on the diagnosis and patient vignette provided below, suggest a concise treatment plan that could realistically be initiated by a primary care physician or psychiatrist."
|
|
|
|
|
90 |
)
|
91 |
|
92 |
|
@@ -104,16 +109,16 @@ def simulate_interaction(user_input, iterations=1):
|
|
104 |
for i in range(iterations):
|
105 |
# Summarize
|
106 |
sum_in = "\n".join(history) + f"\nPrevious Vignette: {summary}"
|
107 |
-
sum_out = summarizer.act(sum_in
|
108 |
summary = sum_out["output"]
|
109 |
|
110 |
# Diagnose
|
111 |
-
diag_out = diagnoser.act(summary
|
112 |
diagnosis = diag_out["output"]
|
113 |
|
114 |
# Question
|
115 |
q_in = f"Vignette: {summary}\nCurrent Estimated Diagnosis: {diag_out['thinking']} {diagnosis}"
|
116 |
-
q_out = questioner.act(q_in
|
117 |
history.append(f"Doctor: {q_out['output']}")
|
118 |
history.append("Patient: (awaiting response)")
|
119 |
|
|
|
78 |
|
79 |
# === Agents ===
|
80 |
summarizer = RoleAgent(
|
81 |
+
"You are a clinical summarizer trained to extract structured vignettes from doctor–patient dialogues.",
|
82 |
+
tokenizer,
|
83 |
+
model,
|
84 |
)
|
85 |
diagnoser = RoleAgent(
|
86 |
+
"You are a board-certified diagnostician that diagnoses patients.", tokenizer, model
|
87 |
+
)
|
88 |
+
questioner = RoleAgent(
|
89 |
+
"You are a physician asking questions to diagnose a patient.", tokenizer, model
|
90 |
)
|
|
|
|
|
91 |
treatment_agent = RoleAgent(
|
92 |
+
"You are a board-certified clinician. Based on the diagnosis and patient vignette provided below, suggest a concise treatment plan that could realistically be initiated by a primary care physician or psychiatrist.",
|
93 |
+
tokenizer,
|
94 |
+
model,
|
95 |
)
|
96 |
|
97 |
|
|
|
109 |
for i in range(iterations):
|
110 |
# Summarize
|
111 |
sum_in = "\n".join(history) + f"\nPrevious Vignette: {summary}"
|
112 |
+
sum_out = summarizer.act(sum_in)
|
113 |
summary = sum_out["output"]
|
114 |
|
115 |
# Diagnose
|
116 |
+
diag_out = diagnoser.act(summary)
|
117 |
diagnosis = diag_out["output"]
|
118 |
|
119 |
# Question
|
120 |
q_in = f"Vignette: {summary}\nCurrent Estimated Diagnosis: {diag_out['thinking']} {diagnosis}"
|
121 |
+
q_out = questioner.act(q_in)
|
122 |
history.append(f"Doctor: {q_out['output']}")
|
123 |
history.append("Patient: (awaiting response)")
|
124 |
|