3v324v23 commited on
Commit
8deed34
·
1 Parent(s): b267db5

Enforce strict Socratic tutor wrap-up and termination rules when the problem is solved or limits are reached

Browse files
Files changed (2) hide show
  1. backend/main.py +7 -5
  2. backend/test_sentiment.py +1 -1
backend/main.py CHANGED
@@ -131,10 +131,12 @@ def run_flow_b(message: str, api_key: str, history: Optional[List[ChatMessage]]
131
  custom_system = (
132
  f"Socratic tutor: guide with clear, substantial hints. "
133
  f"Current conversation: {num_user_turns} user turns so far. "
134
- "Dynamically decide whether to nudge or give the final direct solution. "
135
- "Provide the final direct answer/solution immediately if: the user is close, highly frustrated, "
136
- "asks directly for the answer, or if hints exceed topic complexity (e.g., 2 hints for simple topics, 4 for complex topics). "
137
- "Otherwise, continue guiding with a hint and ask exactly 1 Socratic question."
 
 
138
  )
139
 
140
  tone_instruction = (
@@ -144,7 +146,7 @@ def run_flow_b(message: str, api_key: str, history: Optional[List[ChatMessage]]
144
  "- Sympathize with s implicitly (tone/style); never name or mention the sentiment/emotion itself.\n"
145
  "- NEVER use 'if you' (use direct phrasing: 'think about', 'imagine').\n"
146
  "- Ask 1 question max.\n"
147
- "Responses:\n"
148
  "- frustration: acknowledge sentiment but not explicitly + simplify + question.\n"
149
  "- starting_to_get_bored: acknowledge sentiment but not explicitly + puzzle/analogy + question.\n"
150
  "- other: hint + question."
 
131
  custom_system = (
132
  f"Socratic tutor: guide with clear, substantial hints. "
133
  f"Current conversation: {num_user_turns} user turns so far. "
134
+ "CRITICAL RULES:\n"
135
+ "- If the user has answered correctly, solved the problem, or if hints exceed topic complexity "
136
+ "(e.g., 2 user turns for simple topics, 4 user turns for complex topics): DO NOT ask any more math/science/concept questions. "
137
+ "Immediately confirm their success (or provide the direct solution) and ask exactly: 'Do you want to learn something else?'\n"
138
+ "- If the user is close, highly frustrated, or asks directly: give the solution and ask exactly: 'Do you want to learn something else?'\n"
139
+ "- Otherwise, guide with a hint and ask exactly 1 Socratic question."
140
  )
141
 
142
  tone_instruction = (
 
146
  "- Sympathize with s implicitly (tone/style); never name or mention the sentiment/emotion itself.\n"
147
  "- NEVER use 'if you' (use direct phrasing: 'think about', 'imagine').\n"
148
  "- Ask 1 question max.\n"
149
+ "Responses (unless wrapping up / giving final answer):\n"
150
  "- frustration: acknowledge sentiment but not explicitly + simplify + question.\n"
151
  "- starting_to_get_bored: acknowledge sentiment but not explicitly + puzzle/analogy + question.\n"
152
  "- other: hint + question."
backend/test_sentiment.py CHANGED
@@ -56,7 +56,7 @@ def test_run_flow_b_force_wrap_up():
56
 
57
  # Verify that turn counting and dynamic decision instructions are injected correctly
58
  assert "current conversation: 2 user turns so far" in context.lower()
59
- assert "dynamically decide" in context.lower()
60
  print("Mocked force wrap-up test passed!")
61
 
62
  if __name__ == "__main__":
 
56
 
57
  # Verify that turn counting and dynamic decision instructions are injected correctly
58
  assert "current conversation: 2 user turns so far" in context.lower()
59
+ assert "critical rules" in context.lower()
60
  print("Mocked force wrap-up test passed!")
61
 
62
  if __name__ == "__main__":