Spaces:
Sleeping
Sleeping
github-actions[bot] commited on
Commit ·
a3925c9
1
Parent(s): c1bbffd
deploy: backend from 8a361cd
Browse files- main.py +4 -4
- rag/curriculum_rag.py +1 -0
- routes/deepseek_rag_routes.py +2 -0
- routes/diagnostic.py +1 -0
- routes/quiz_generation_routes.py +1 -0
- services/memory_service.py +9 -9
main.py
CHANGED
|
@@ -2436,8 +2436,7 @@ YOUR BEHAVIOR RULES:
|
|
| 2436 |
- Inline: \\( expression \\)
|
| 2437 |
- Block/display: \\[ expression \\]
|
| 2438 |
Never use dollar signs ($) — they break the KaTeX renderer.
|
| 2439 |
-
6.
|
| 2440 |
-
(e.g., "Kaya mo yan!", "Subukan natin...") to keep the tone warm.
|
| 2441 |
7. When a student answers a "try_it" problem, evaluate their answer:
|
| 2442 |
- If correct: Celebrate briefly, explain WHY it's correct, then offer a harder challenge.
|
| 2443 |
- If wrong: Say "Good try! Let's check your steps..." then walk through the error.
|
|
@@ -2497,8 +2496,8 @@ Only use the out-of-scope response when:
|
|
| 2497 |
When in doubt, ask a clarifying math question rather than triggering out-of-scope.
|
| 2498 |
|
| 2499 |
LANGUAGE:
|
| 2500 |
-
|
| 2501 |
-
|
| 2502 |
Treat all Filipino conversational replies as normal student communication, never as
|
| 2503 |
off-topic or unrecognized input."""
|
| 2504 |
|
|
@@ -13660,6 +13659,7 @@ Student Context:
|
|
| 13660 |
|
| 13661 |
{rag_instruction}
|
| 13662 |
|
|
|
|
| 13663 |
Use Filipino context (₱, local scenarios).
|
| 13664 |
Follow SDO Navotas step-by-step: "Given → Formula → Substitute → Compute → Conclude"
|
| 13665 |
|
|
|
|
| 2436 |
- Inline: \\( expression \\)
|
| 2437 |
- Block/display: \\[ expression \\]
|
| 2438 |
Never use dollar signs ($) — they break the KaTeX renderer.
|
| 2439 |
+
6. Write EVERYTHING in English. Do NOT use Tagalog, Filipino, or any other language.
|
|
|
|
| 2440 |
7. When a student answers a "try_it" problem, evaluate their answer:
|
| 2441 |
- If correct: Celebrate briefly, explain WHY it's correct, then offer a harder challenge.
|
| 2442 |
- If wrong: Say "Good try! Let's check your steps..." then walk through the error.
|
|
|
|
| 2496 |
When in doubt, ask a clarifying math question rather than triggering out-of-scope.
|
| 2497 |
|
| 2498 |
LANGUAGE:
|
| 2499 |
+
IMPORTANT: Write EVERYTHING in English. Do NOT use Tagalog, Filipino, or any other language.
|
| 2500 |
+
Understand Filipino, Tagalog, and Taglish student input, but always respond in English.
|
| 2501 |
Treat all Filipino conversational replies as normal student communication, never as
|
| 2502 |
off-topic or unrecognized input."""
|
| 2503 |
|
|
|
|
| 13659 |
|
| 13660 |
{rag_instruction}
|
| 13661 |
|
| 13662 |
+
IMPORTANT: Write EVERYTHING in English. Do NOT use Tagalog, Filipino, or any other language.
|
| 13663 |
Use Filipino context (₱, local scenarios).
|
| 13664 |
Follow SDO Navotas step-by-step: "Given → Formula → Substitute → Compute → Conclude"
|
| 13665 |
|
rag/curriculum_rag.py
CHANGED
|
@@ -650,6 +650,7 @@ def build_lesson_prompt(
|
|
| 650 |
return (
|
| 651 |
"You are a DepEd-aligned Grade 11 mathematics instructional designer.\n"
|
| 652 |
"Generate a lesson in JSON format. Use ONLY the retrieved curriculum evidence below.\n"
|
|
|
|
| 653 |
"Do NOT invent content. Do NOT add generic motivational text. All content must be grounded in the retrieved excerpts.\n\n"
|
| 654 |
f"Lesson title: {lesson_title}\n"
|
| 655 |
f"Competency code: {competency_code or 'n/a'}\n"
|
|
|
|
| 650 |
return (
|
| 651 |
"You are a DepEd-aligned Grade 11 mathematics instructional designer.\n"
|
| 652 |
"Generate a lesson in JSON format. Use ONLY the retrieved curriculum evidence below.\n"
|
| 653 |
+
"IMPORTANT: Write EVERYTHING in English. Do NOT use Tagalog, Filipino, or any other language.\n"
|
| 654 |
"Do NOT invent content. Do NOT add generic motivational text. All content must be grounded in the retrieved excerpts.\n\n"
|
| 655 |
f"Lesson title: {lesson_title}\n"
|
| 656 |
f"Competency code: {competency_code or 'n/a'}\n"
|
routes/deepseek_rag_routes.py
CHANGED
|
@@ -228,6 +228,7 @@ async def generate_module_preview(req: ModulePreviewRequest):
|
|
| 228 |
|
| 229 |
system_prompt = (
|
| 230 |
"You are a DepEd K-12 SHS math educator writing for Grade 11 Filipino students. "
|
|
|
|
| 231 |
"Generate content ONLY from the retrieved DepEd curriculum excerpts provided. "
|
| 232 |
"Do NOT add generic filler. Do NOT invent examples or definitions not present "
|
| 233 |
"in the retrieved context."
|
|
@@ -312,6 +313,7 @@ async def generate_study_tips(req: StudyTipsRequest):
|
|
| 312 |
|
| 313 |
system_prompt = (
|
| 314 |
"You are a math tutor helping a Filipino SHS student improve weak areas. "
|
|
|
|
| 315 |
"Base ALL study tips strictly on the retrieved DepEd curriculum content below. "
|
| 316 |
"Do not invent practice problems or examples not found in the curriculum context."
|
| 317 |
)
|
|
|
|
| 228 |
|
| 229 |
system_prompt = (
|
| 230 |
"You are a DepEd K-12 SHS math educator writing for Grade 11 Filipino students. "
|
| 231 |
+
"IMPORTANT: Write EVERYTHING in English. Do NOT use Tagalog, Filipino, or any other language. "
|
| 232 |
"Generate content ONLY from the retrieved DepEd curriculum excerpts provided. "
|
| 233 |
"Do NOT add generic filler. Do NOT invent examples or definitions not present "
|
| 234 |
"in the retrieved context."
|
|
|
|
| 313 |
|
| 314 |
system_prompt = (
|
| 315 |
"You are a math tutor helping a Filipino SHS student improve weak areas. "
|
| 316 |
+
"IMPORTANT: Write EVERYTHING in English. Do NOT use Tagalog, Filipino, or any other language. "
|
| 317 |
"Base ALL study tips strictly on the retrieved DepEd curriculum content below. "
|
| 318 |
"Do not invent practice problems or examples not found in the curriculum context."
|
| 319 |
)
|
routes/diagnostic.py
CHANGED
|
@@ -324,6 +324,7 @@ Finite Math: FM1-MAT-01, FM2-PROB-01, FM2-PROB-02
|
|
| 324 |
- Hard (Bloom: analyzing): 3 questions (20%)
|
| 325 |
|
| 326 |
QUESTION RULES:
|
|
|
|
| 327 |
1. All questions are 4-option multiple choice (A, B, C, D).
|
| 328 |
2. Use Filipino real-life context: peso amounts, Filipino names
|
| 329 |
(Juan, Maria, Jose), Philippine institutions (SSS, PhilHealth,
|
|
|
|
| 324 |
- Hard (Bloom: analyzing): 3 questions (20%)
|
| 325 |
|
| 326 |
QUESTION RULES:
|
| 327 |
+
IMPORTANT: Write EVERYTHING in English. Do NOT use Tagalog, Filipino, or any other language.
|
| 328 |
1. All questions are 4-option multiple choice (A, B, C, D).
|
| 329 |
2. Use Filipino real-life context: peso amounts, Filipino names
|
| 330 |
(Juan, Maria, Jose), Philippine institutions (SSS, PhilHealth,
|
routes/quiz_generation_routes.py
CHANGED
|
@@ -136,6 +136,7 @@ Generate a "Try It Yourself" quiz for the following lesson.
|
|
| 136 |
- Point value per question: {points}
|
| 137 |
|
| 138 |
## Instructions
|
|
|
|
| 139 |
1. Generate EXACTLY {question_count} questions covering the topic above.
|
| 140 |
2. Question types to use: {qt_str}
|
| 141 |
3. BLOOM'S TAXONOMY DISTRIBUTION (for {question_count} questions):
|
|
|
|
| 136 |
- Point value per question: {points}
|
| 137 |
|
| 138 |
## Instructions
|
| 139 |
+
IMPORTANT: Write EVERYTHING in English. Do NOT use Tagalog, Filipino, or any other language.
|
| 140 |
1. Generate EXACTLY {question_count} questions covering the topic above.
|
| 141 |
2. Question types to use: {qt_str}
|
| 142 |
3. BLOOM'S TAXONOMY DISTRIBUTION (for {question_count} questions):
|
services/memory_service.py
CHANGED
|
@@ -106,7 +106,7 @@ class ProfileMemory:
|
|
| 106 |
self.weak_topics = weak_topics or []
|
| 107 |
self.learning_style = learning_style
|
| 108 |
self.explanation_depth = explanation_depth # "auto", "basic", "detailed", "advanced"
|
| 109 |
-
self.language_tone = language_tone
|
| 110 |
self.prior_goals = prior_goals or []
|
| 111 |
self.stable_tutoring_facts = stable_tutoring_facts or []
|
| 112 |
self.recurring_mistakes = recurring_mistakes or []
|
|
@@ -522,9 +522,9 @@ def extract_profile_info_from_message(text: str) -> dict:
|
|
| 522 |
else:
|
| 523 |
updates[field] = matched
|
| 524 |
|
| 525 |
-
#
|
| 526 |
if re.search(r"(?:tagalog|filipino|bisaya|ilocano)", text, re.IGNORECASE):
|
| 527 |
-
updates["language_tone"] = "
|
| 528 |
|
| 529 |
return updates
|
| 530 |
|
|
@@ -583,9 +583,6 @@ def _maybe_record_stable_fact(uid: str, profile: ProfileMemory, message: str) ->
|
|
| 583 |
facts_to_record.append(f"Student struggles with: {', '.join(profile.weak_topics[-3:])}")
|
| 584 |
if profile.explanation_depth and profile.explanation_depth != "auto":
|
| 585 |
facts_to_record.append(f"Student prefers {profile.explanation_depth} explanations")
|
| 586 |
-
if profile.language_tone == "filipino-friendly":
|
| 587 |
-
facts_to_record.append("Student prefers Filipino-friendly language")
|
| 588 |
-
|
| 589 |
if facts_to_record:
|
| 590 |
for fact in facts_to_record:
|
| 591 |
if fact not in profile.stable_tutoring_facts:
|
|
@@ -801,10 +798,13 @@ def _format_profile_context(profile: ProfileMemory) -> str:
|
|
| 801 |
lines.append(f"Weak Topics: {', '.join(profile.weak_topics[:5])}")
|
| 802 |
if profile.explanation_depth and profile.explanation_depth != "auto":
|
| 803 |
lines.append(f"Explanation Preference: {profile.explanation_depth} explanations")
|
| 804 |
-
if profile.language_tone and profile.language_tone != "english":
|
| 805 |
-
lines.append(f"Language: {profile.language_tone}")
|
| 806 |
if profile.stable_tutoring_facts:
|
| 807 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 808 |
if profile.prior_goals:
|
| 809 |
lines.append(f"Prior Goals: {'; '.join(profile.prior_goals[-3:])}")
|
| 810 |
if profile.recurring_mistakes:
|
|
|
|
| 106 |
self.weak_topics = weak_topics or []
|
| 107 |
self.learning_style = learning_style
|
| 108 |
self.explanation_depth = explanation_depth # "auto", "basic", "detailed", "advanced"
|
| 109 |
+
self.language_tone = language_tone
|
| 110 |
self.prior_goals = prior_goals or []
|
| 111 |
self.stable_tutoring_facts = stable_tutoring_facts or []
|
| 112 |
self.recurring_mistakes = recurring_mistakes or []
|
|
|
|
| 522 |
else:
|
| 523 |
updates[field] = matched
|
| 524 |
|
| 525 |
+
# Accept Filipino-language input without changing the English output preference.
|
| 526 |
if re.search(r"(?:tagalog|filipino|bisaya|ilocano)", text, re.IGNORECASE):
|
| 527 |
+
updates["language_tone"] = "english"
|
| 528 |
|
| 529 |
return updates
|
| 530 |
|
|
|
|
| 583 |
facts_to_record.append(f"Student struggles with: {', '.join(profile.weak_topics[-3:])}")
|
| 584 |
if profile.explanation_depth and profile.explanation_depth != "auto":
|
| 585 |
facts_to_record.append(f"Student prefers {profile.explanation_depth} explanations")
|
|
|
|
|
|
|
|
|
|
| 586 |
if facts_to_record:
|
| 587 |
for fact in facts_to_record:
|
| 588 |
if fact not in profile.stable_tutoring_facts:
|
|
|
|
| 798 |
lines.append(f"Weak Topics: {', '.join(profile.weak_topics[:5])}")
|
| 799 |
if profile.explanation_depth and profile.explanation_depth != "auto":
|
| 800 |
lines.append(f"Explanation Preference: {profile.explanation_depth} explanations")
|
|
|
|
|
|
|
| 801 |
if profile.stable_tutoring_facts:
|
| 802 |
+
active_facts = [
|
| 803 |
+
fact for fact in profile.stable_tutoring_facts
|
| 804 |
+
if fact != "Student prefers Filipino-friendly language"
|
| 805 |
+
]
|
| 806 |
+
if active_facts:
|
| 807 |
+
lines.append(f"Tutoring Facts: {'; '.join(active_facts[-3:])}")
|
| 808 |
if profile.prior_goals:
|
| 809 |
lines.append(f"Prior Goals: {'; '.join(profile.prior_goals[-3:])}")
|
| 810 |
if profile.recurring_mistakes:
|