Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -323,11 +323,17 @@ INTENT RULES:
|
|
| 323 |
"curriculum" β on-topic. Follow: teach β re_teach β show_and_tell β assess.
|
| 324 |
"chitchat" β casual. Respond warmly, bring up active topic.
|
| 325 |
|
| 326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
{{
|
| 328 |
"intent": "<block|questions|curriculum|chitchat>",
|
| 329 |
"response": "<reply, max 50 words>",
|
| 330 |
-
"stage_updates": [{{"topic":"{active_topic}","goal":"{active_goal}","teach":"
|
| 331 |
"thought": "<one sentence>",
|
| 332 |
"action": "<teach|re_teach|show_and_tell|assess|answer|redirect|discourage|end|chitchat>",
|
| 333 |
"observation": "<one sentence>"
|
|
@@ -440,6 +446,10 @@ def _apply_state_updates(
|
|
| 440 |
valid_statuses = {"complete", "Not_Complete"}
|
| 441 |
|
| 442 |
for upd in parsed.get("stage_updates", []):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
for item in current_learning:
|
| 444 |
if item.get("topic") == upd.get("topic"):
|
| 445 |
for obj in item.get("learning_objectives", []):
|
|
|
|
| 323 |
"curriculum" β on-topic. Follow: teach β re_teach β show_and_tell β assess.
|
| 324 |
"chitchat" β casual. Respond warmly, bring up active topic.
|
| 325 |
|
| 326 |
+
STAGE VALUE RULES β CRITICAL:
|
| 327 |
+
The fields teach / re_teach / show_and_tell / assess must ONLY ever be the exact string "complete" or "Not_Complete".
|
| 328 |
+
NEVER put a sentence, description, or any other text in these fields.
|
| 329 |
+
Set the current active stage ("{active_stage}") to "complete" if the student has completed it, else "Not_Complete".
|
| 330 |
+
All other stages keep their previous value β use "Not_Complete" if unknown.
|
| 331 |
+
|
| 332 |
+
OUTPUT β return ONLY this JSON (stage_updates: EXACTLY 1 entry):
|
| 333 |
{{
|
| 334 |
"intent": "<block|questions|curriculum|chitchat>",
|
| 335 |
"response": "<reply, max 50 words>",
|
| 336 |
+
"stage_updates": [{{"topic":"{active_topic}","goal":"{active_goal}","teach":"Not_Complete","re_teach":"Not_Complete","show_and_tell":"Not_Complete","assess":"Not_Complete"}}],
|
| 337 |
"thought": "<one sentence>",
|
| 338 |
"action": "<teach|re_teach|show_and_tell|assess|answer|redirect|discourage|end|chitchat>",
|
| 339 |
"observation": "<one sentence>"
|
|
|
|
| 446 |
valid_statuses = {"complete", "Not_Complete"}
|
| 447 |
|
| 448 |
for upd in parsed.get("stage_updates", []):
|
| 449 |
+
# Sanitise: coerce any non-enum value to "Not_Complete"
|
| 450 |
+
for stage in ("teach", "re_teach", "show_and_tell", "assess"):
|
| 451 |
+
if upd.get(stage) not in valid_statuses:
|
| 452 |
+
upd[stage] = "Not_Complete"
|
| 453 |
for item in current_learning:
|
| 454 |
if item.get("topic") == upd.get("topic"):
|
| 455 |
for obj in item.get("learning_objectives", []):
|