Spaces:
Sleeping
Sleeping
Update llm_utils.py
Browse files- llm_utils.py +27 -8
llm_utils.py
CHANGED
|
@@ -39,14 +39,33 @@ def explain_with_llm(solution_text, equation_type, llm_url):
|
|
| 39 |
context = generate_context(theorems, equation_type)
|
| 40 |
|
| 41 |
prompt = (
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
response = requests.post(
|
| 52 |
f"{llm_url}/explain",
|
|
|
|
| 39 |
context = generate_context(theorems, equation_type)
|
| 40 |
|
| 41 |
prompt = (
|
| 42 |
+
f"You are a mathematical reasoning assistant trained to give clear and insightful explanations.\n"
|
| 43 |
+
f"You are provided below with a curated database of mathematical theorems.\n"
|
| 44 |
+
f"Each theorem includes:\n"
|
| 45 |
+
f"- A name\n"
|
| 46 |
+
f"- A formal statement\n"
|
| 47 |
+
f"- Tags (keywords indicating the topics it's related to)\n"
|
| 48 |
+
f"- A brief note on 'When to Use'\n"
|
| 49 |
+
f"- A short explanation that sometimes refers to previous theorems\n\n"
|
| 50 |
+
f"---\n\n"
|
| 51 |
+
f"### 📘 Theorem Database:\n\n"
|
| 52 |
+
f"{context}\n\n"
|
| 53 |
+
f"---\n\n"
|
| 54 |
+
f"### 🧮 Problem Solving Steps for a {equation_type} Equation:\n\n"
|
| 55 |
+
f"{solution_text}\n\n"
|
| 56 |
+
f"---\n\n"
|
| 57 |
+
f"### 🎯 Task:\n"
|
| 58 |
+
f"Provide a detailed and understandable explanation of how the above solution works.\n"
|
| 59 |
+
f"Make sure to:\n"
|
| 60 |
+
f"- Explain **why** each step is valid.\n"
|
| 61 |
+
f"- **Cite the relevant theorems** by name and number when appropriate.\n"
|
| 62 |
+
f"- Maintain a **teaching tone** aimed at a high school or undergraduate student.\n"
|
| 63 |
+
f"- If multiple theorems apply, mention them and clarify how they connect.\n"
|
| 64 |
+
f"- Avoid simply repeating the theorems — integrate them meaningfully.\n"
|
| 65 |
+
f"- Include both **symbolic reasoning** and **conceptual insights**.\n\n"
|
| 66 |
+
f"End the explanation once the reasoning and result are fully justified."
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
|
| 70 |
response = requests.post(
|
| 71 |
f"{llm_url}/explain",
|