Spaces:
Sleeping
Sleeping
Mahdi Naser Moghadasi commited on
Commit ·
12fde5c
1
Parent(s): d2eb486
🔓 Remove math-only restriction: Allow MathMind to answer any educational question, not just math
Browse files
app.py
CHANGED
|
@@ -2503,23 +2503,6 @@ def mathmind_chat_with_typing(message: str, grade_level: str, chat_history: List
|
|
| 2503 |
if not message.strip():
|
| 2504 |
return chat_history, ""
|
| 2505 |
|
| 2506 |
-
# Validate if the question is math-related
|
| 2507 |
-
if not validate_question_is_math_related(message):
|
| 2508 |
-
non_math_response = """🤖 I appreciate your question, but that's beyond my scope!
|
| 2509 |
-
|
| 2510 |
-
I'm specifically designed to help with **mathematics** topics like:
|
| 2511 |
-
• Algebra and equations
|
| 2512 |
-
• Geometry and shapes
|
| 2513 |
-
• Calculus and functions
|
| 2514 |
-
• Statistics and probability
|
| 2515 |
-
• Arithmetic and fractions
|
| 2516 |
-
• Trigonometry and more!
|
| 2517 |
-
|
| 2518 |
-
Could you ask me a math-related question instead? I'd love to help you with any mathematical concept! 🧮✨"""
|
| 2519 |
-
|
| 2520 |
-
chat_history.append([message, non_math_response])
|
| 2521 |
-
return chat_history, ""
|
| 2522 |
-
|
| 2523 |
# Add user message to conversation history
|
| 2524 |
mathmind_conversation_history.append({
|
| 2525 |
"role": "user",
|
|
@@ -2570,10 +2553,10 @@ def call_hugging_face_math_api(prompt: str, conversation_history: List[Dict], pd
|
|
| 2570 |
grade_info = grade_mapping.get(grade_level, grade_mapping["6-8"])
|
| 2571 |
|
| 2572 |
# Build context-aware interactive prompt
|
| 2573 |
-
context_prompt = f"""You are an enthusiastic, interactive
|
| 2574 |
|
| 2575 |
PERSONALITY & INTERACTION STYLE:
|
| 2576 |
-
- Be conversational, friendly, and genuinely excited about
|
| 2577 |
- Ask engaging follow-up questions to keep the conversation going
|
| 2578 |
- Share fascinating real-world connections and "did you know?" facts
|
| 2579 |
- Use age-appropriate humor and analogies for {grade_info['age']} students
|
|
|
|
| 2503 |
if not message.strip():
|
| 2504 |
return chat_history, ""
|
| 2505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2506 |
# Add user message to conversation history
|
| 2507 |
mathmind_conversation_history.append({
|
| 2508 |
"role": "user",
|
|
|
|
| 2553 |
grade_info = grade_mapping.get(grade_level, grade_mapping["6-8"])
|
| 2554 |
|
| 2555 |
# Build context-aware interactive prompt
|
| 2556 |
+
context_prompt = f"""You are an enthusiastic, interactive educational tutor for {grade_info['age']} students. While you specialize in mathematics, you can help with various educational topics and make learning exciting and memorable!
|
| 2557 |
|
| 2558 |
PERSONALITY & INTERACTION STYLE:
|
| 2559 |
+
- Be conversational, friendly, and genuinely excited about learning
|
| 2560 |
- Ask engaging follow-up questions to keep the conversation going
|
| 2561 |
- Share fascinating real-world connections and "did you know?" facts
|
| 2562 |
- Use age-appropriate humor and analogies for {grade_info['age']} students
|