Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -148,13 +148,19 @@ def generate_question(subject, difficulty, question_type):
|
|
148 |
"Single Variable Calculus": ["limits", "derivatives", "integrals", "series", "applications"],
|
149 |
"Multivariable Calculus": ["partial derivatives", "multiple integrals", "vector fields", "optimization"],
|
150 |
"Linear Algebra": ["matrices", "vector spaces", "eigenvalues", "linear transformations"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
|
153 |
selected_topic = random.choice(topics.get(subject, ["general"]))
|
154 |
logger.debug(f"Selected topic: {selected_topic}")
|
155 |
|
156 |
difficulty_params = get_difficulty_parameters(difficulty)
|
157 |
-
[Previous code remains the same until the system_prompt section...]
|
158 |
|
159 |
if question_type == "application":
|
160 |
application_addition = """
|
@@ -233,6 +239,53 @@ STRICT REQUIREMENTS:
|
|
233 |
- How to interpret the results
|
234 |
6. Maintain clear formatting"""
|
235 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
logger.debug("Sending request to Anthropic API")
|
238 |
message = anthropic.messages.create(
|
|
|
148 |
"Single Variable Calculus": ["limits", "derivatives", "integrals", "series", "applications"],
|
149 |
"Multivariable Calculus": ["partial derivatives", "multiple integrals", "vector fields", "optimization"],
|
150 |
"Linear Algebra": ["matrices", "vector spaces", "eigenvalues", "linear transformations"],
|
151 |
+
"Differential Equations": ["first order equations", "second order equations", "systems", "stability analysis"],
|
152 |
+
"Real Analysis": ["sequences", "series", "continuity", "differentiation", "integration"],
|
153 |
+
"Complex Analysis": ["complex functions", "analyticity", "contour integration", "residues"],
|
154 |
+
"Abstract Algebra": ["groups", "rings", "fields", "homomorphisms"],
|
155 |
+
"Probability Theory": ["probability spaces", "random variables", "distributions", "limit theorems"],
|
156 |
+
"Numerical Analysis": ["approximation", "interpolation", "numerical integration", "error analysis"],
|
157 |
+
"Topology": ["metric spaces", "continuity", "compactness", "connectedness"]
|
158 |
}
|
159 |
|
160 |
selected_topic = random.choice(topics.get(subject, ["general"]))
|
161 |
logger.debug(f"Selected topic: {selected_topic}")
|
162 |
|
163 |
difficulty_params = get_difficulty_parameters(difficulty)
|
|
|
164 |
|
165 |
if question_type == "application":
|
166 |
application_addition = """
|
|
|
239 |
- How to interpret the results
|
240 |
6. Maintain clear formatting"""
|
241 |
else:
|
242 |
+
# Standard prompts for computation and proof questions
|
243 |
+
if difficulty == 5:
|
244 |
+
system_prompt = f"""You are an expert mathematics professor creating a graduate-level exam question.
|
245 |
+
STRICT REQUIREMENTS:
|
246 |
+
1. Write exactly 1 graduate-level {question_type} question on {subject} covering {selected_topic}.
|
247 |
+
2. Advanced Difficulty Requirements:
|
248 |
+
This question must be suitable for PhD qualifying exams or advanced competitions.
|
249 |
+
MUST include:
|
250 |
+
- Novel applications of theoretical concepts
|
251 |
+
- Graduate-level mathematical reasoning
|
252 |
+
- Unexpected connections between different areas of {subject}
|
253 |
+
- Creative problem-solving approaches
|
254 |
+
- Rigorous proof requirements where applicable
|
255 |
+
|
256 |
+
Follow these specific constraints:
|
257 |
+
{chr(10).join(f' - {c}' for c in difficulty_params['constraints'])}
|
258 |
+
3. Style Reference:
|
259 |
+
Question should be {difficulty_params['example_style']}
|
260 |
+
4. The question MUST:
|
261 |
+
- Bridge multiple mathematical domains
|
262 |
+
- Require deep theoretical understanding
|
263 |
+
- Test mastery of advanced concepts
|
264 |
+
- Demand innovative solution approaches
|
265 |
+
5. For LaTeX formatting:
|
266 |
+
- Use $ for inline math
|
267 |
+
- Use $$ on separate lines for equations and solutions
|
268 |
+
- Put each solution step on its own line in $$ $$
|
269 |
+
- DO NOT use \\begin{{aligned}} or similar environments
|
270 |
+
6. Include a detailed solution with thorough explanations of advanced concepts used
|
271 |
+
7. Maintain clear, precise formatting"""
|
272 |
+
else:
|
273 |
+
system_prompt = f"""You are an expert mathematics professor creating a {difficulty_params['description']} exam question.
|
274 |
+
STRICT REQUIREMENTS:
|
275 |
+
1. Write exactly 1 {question_type} question on {subject} covering {selected_topic}.
|
276 |
+
2. Difficulty Level Guidelines:
|
277 |
+
{difficulty_params['description'].upper()}
|
278 |
+
Follow these specific constraints:
|
279 |
+
{chr(10).join(f' - {c}' for c in difficulty_params['constraints'])}
|
280 |
+
3. Style Reference:
|
281 |
+
Question should be {difficulty_params['example_style']}
|
282 |
+
4. For LaTeX formatting:
|
283 |
+
- Use $ for inline math
|
284 |
+
- Use $$ on separate lines for equations and solutions
|
285 |
+
- Put each solution step on its own line in $$ $$
|
286 |
+
- DO NOT use \\begin{{aligned}} or similar environments
|
287 |
+
5. Include a detailed solution
|
288 |
+
6. Maintain clear formatting"""
|
289 |
|
290 |
logger.debug("Sending request to Anthropic API")
|
291 |
message = anthropic.messages.create(
|