Enforce strict Socratic tutor wrap-up and termination rules when the problem is solved or limits are reached
Browse files- backend/main.py +7 -5
- 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 |
-
"
|
| 135 |
-
"
|
| 136 |
-
"
|
| 137 |
-
"
|
|
|
|
|
|
|
| 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 "
|
| 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__":
|