WebashalarForML commited on
Commit
942a20d
·
verified ·
1 Parent(s): 83d027f

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +122 -9
server.py CHANGED
@@ -18,21 +18,134 @@ def get_local_resource():
18
 
19
  @mcp.tool()
20
  async def generate_chapter_summary(chapter_name: str) -> str:
21
- """Provides source material and instructions for a math summary."""
 
 
22
  raw_data = get_local_resource()
 
23
  return f"""
24
- <source_material>
25
- {raw_data[:4000]}
26
- </source_material>
27
- SYSTEM_INSTRUCTION: You are a Mathematics Expert.
28
- 1. Summarize in 3 bullets.
29
- 2. List formulas like $x = \\frac{{-b \\pm \\sqrt{{b^2-4ac}}}}{{2a}}$.
30
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  @mcp.tool()
33
  async def generate_quiz(chapter_name: str, difficulty: str = "medium") -> str:
 
 
 
34
  raw_data = get_local_resource()
35
- return f"Material: {raw_data[:2000]}\nDifficulty: {difficulty}\nCreate a 3-question quiz."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  if __name__ == "__main__":
38
  print("Starting FastMCP server on port 7860...")
 
18
 
19
  @mcp.tool()
20
  async def generate_chapter_summary(chapter_name: str) -> str:
21
+ """
22
+ Provides source material + strict instructions for a math chapter summary.
23
+ """
24
  raw_data = get_local_resource()
25
+
26
  return f"""
27
+ You are a Mathematics Expert and Academic Tutor.
28
+
29
+ TASK:
30
+ Generate a structured summary of the chapter titled: "{chapter_name}"
31
+
32
+ IMPORTANT RULES:
33
+ - Use ONLY the provided <source_material>.
34
+ - If something is missing in the material, explicitly write: "Not found in source".
35
+ - Do NOT invent formulas, theorems, or examples.
36
+ - Prefer mathematical notation and LaTeX formatting.
37
+ - Output must be clean Markdown.
38
+
39
+ OUTPUT FORMAT (STRICT):
40
+ ## Chapter: {chapter_name}
41
+
42
+ ### 1. 3-Line High-Level Summary (3 bullets max)
43
+ - ...
44
+ - ...
45
+ - ...
46
+
47
+ ### 2. Key Concepts (Definitions / Theorems / Properties)
48
+ List important definitions and results.
49
+ Each bullet must follow:
50
+ - **Concept Name**: Explanation (1–2 lines)
51
+
52
+ ### 3. Important Formulas (LaTeX only)
53
+ Provide all important formulas mentioned in the chapter.
54
+ Format each as:
55
+ - **Formula Name**: $...$
56
+
57
+ ### 4. Step-by-Step Core Method(s)
58
+ If the chapter contains any algorithm/method (example: solving quadratic, integration steps),
59
+ list the procedure in numbered steps.
60
+
61
+ ### 5. Common Mistakes / Traps
62
+ List 3–6 common mistakes students make.
63
+
64
+ ### 6. Quick Worked Example (If present in source)
65
+ - Problem:
66
+ - Solution (brief but clear):
67
+ - Final Answer:
68
+
69
+ If no example exists in the source, write: "Not found in source".
70
+
71
+ SOURCE:
72
+ <source_material>
73
+ {raw_data[:10000]}
74
+ </source_material>
75
+ """
76
+
77
 
78
  @mcp.tool()
79
  async def generate_quiz(chapter_name: str, difficulty: str = "medium") -> str:
80
+ """
81
+ Generates quiz questions based on chapter material.
82
+ """
83
  raw_data = get_local_resource()
84
+
85
+ return f"""
86
+ You are a Mathematics Professor designing an exam.
87
+
88
+ CHAPTER: "{chapter_name}"
89
+ DIFFICULTY: "{difficulty}"
90
+
91
+ DIFFICULTY RULES:
92
+ - easy: direct definition/formula substitution questions
93
+ - medium: multi-step numeric problems + conceptual reasoning
94
+ - hard: tricky reasoning, proofs, edge cases, mixed-concept questions
95
+
96
+ IMPORTANT RULES:
97
+ - Use ONLY the provided source material.
98
+ - Do NOT invent topics not present in the material.
99
+ - Every question must match the difficulty level.
100
+ - Provide answer key + short solution steps.
101
+ - Format must be clean Markdown.
102
+ - Use LaTeX for all formulas.
103
+
104
+ OUTPUT FORMAT (STRICT):
105
+
106
+ ## Quiz: {chapter_name} ({difficulty})
107
+
108
+ ### Q1. (Conceptual / Definition Based)
109
+ Question text...
110
+
111
+ **Options (if MCQ):**
112
+ A) ...
113
+ B) ...
114
+ C) ...
115
+ D) ...
116
+
117
+ ### Q2. (Formula/Application Based)
118
+ Question text...
119
+
120
+ ### Q3. (Multi-step Problem / Reasoning Based)
121
+ Question text...
122
+
123
+ ---
124
+
125
+ ## Answer Key + Solutions
126
+
127
+ ### Q1 Solution
128
+ - Correct Answer: ...
129
+ - Explanation: ...
130
+
131
+ ### Q2 Solution
132
+ Step 1: ...
133
+ Step 2: ...
134
+ Final Answer: ...
135
+
136
+ ### Q3 Solution
137
+ Step 1: ...
138
+ Step 2: ...
139
+ Step 3: ...
140
+ Final Answer: ...
141
+
142
+ SOURCE:
143
+ <source_material>
144
+ {raw_data[:10000]}
145
+ </source_material>
146
+ """
147
+
148
+
149
 
150
  if __name__ == "__main__":
151
  print("Starting FastMCP server on port 7860...")