digifreely commited on
Commit
d36fd1b
Β·
verified Β·
1 Parent(s): 6908ccf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
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
- OUTPUT β€” return ONLY this JSON (stage_updates: EXACTLY 1 entry for the active objective only):
 
 
 
 
 
 
327
  {{
328
  "intent": "<block|questions|curriculum|chitchat>",
329
  "response": "<reply, max 50 words>",
330
- "stage_updates": [{{"topic":"{active_topic}","goal":"{active_goal}","teach":"<complete|Not_Complete>","re_teach":"<complete|Not_Complete>","show_and_tell":"<complete|Not_Complete>","assess":"<complete|Not_Complete>"}}],
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", []):