Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -154,23 +154,46 @@ def generate_question(subject, difficulty, question_type):
|
|
| 154 |
logger.debug(f"Selected topic: {selected_topic}")
|
| 155 |
|
| 156 |
difficulty_params = get_difficulty_parameters(difficulty)
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
if
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
STRICT REQUIREMENTS:
|
| 162 |
-
1. Write exactly 1 graduate-level
|
| 163 |
2. Advanced Difficulty Requirements:
|
| 164 |
This question must be suitable for PhD qualifying exams or advanced competitions.
|
| 165 |
MUST include:
|
| 166 |
-
- Novel applications of theoretical concepts
|
| 167 |
-
- Graduate-level mathematical reasoning
|
| 168 |
-
-
|
| 169 |
- Creative problem-solving approaches
|
| 170 |
-
-
|
| 171 |
|
| 172 |
Follow these specific constraints:
|
| 173 |
{chr(10).join(f' - {c}' for c in difficulty_params['constraints'])}
|
|
|
|
| 174 |
3. Style Reference:
|
| 175 |
Question should be {difficulty_params['example_style']}
|
| 176 |
4. The question MUST:
|
|
@@ -183,16 +206,20 @@ STRICT REQUIREMENTS:
|
|
| 183 |
- Use $$ on separate lines for equations and solutions
|
| 184 |
- Put each solution step on its own line in $$ $$
|
| 185 |
- DO NOT use \\begin{{aligned}} or similar environments
|
| 186 |
-
6. Include a detailed solution with thorough explanations of
|
|
|
|
|
|
|
|
|
|
| 187 |
7. Maintain clear, precise formatting"""
|
| 188 |
-
|
| 189 |
-
|
| 190 |
STRICT REQUIREMENTS:
|
| 191 |
-
1. Write exactly 1
|
| 192 |
2. Difficulty Level Guidelines:
|
| 193 |
{difficulty_params['description'].upper()}
|
| 194 |
Follow these specific constraints:
|
| 195 |
{chr(10).join(f' - {c}' for c in difficulty_params['constraints'])}
|
|
|
|
| 196 |
3. Style Reference:
|
| 197 |
Question should be {difficulty_params['example_style']}
|
| 198 |
4. For LaTeX formatting:
|
|
@@ -200,8 +227,12 @@ STRICT REQUIREMENTS:
|
|
| 200 |
- Use $$ on separate lines for equations and solutions
|
| 201 |
- Put each solution step on its own line in $$ $$
|
| 202 |
- DO NOT use \\begin{{aligned}} or similar environments
|
| 203 |
-
5. Include a detailed solution
|
|
|
|
|
|
|
|
|
|
| 204 |
6. Maintain clear formatting"""
|
|
|
|
| 205 |
|
| 206 |
logger.debug("Sending request to Anthropic API")
|
| 207 |
message = anthropic.messages.create(
|
|
|
|
| 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 = """
|
| 161 |
+
The application question MUST:
|
| 162 |
+
- Present a real-world scenario or practical problem
|
| 163 |
+
- Require modeling the situation mathematically
|
| 164 |
+
- Connect abstract mathematical concepts to concrete situations
|
| 165 |
+
- Include realistic context and data
|
| 166 |
+
- Require students to:
|
| 167 |
+
1. Identify relevant mathematical concepts
|
| 168 |
+
2. Translate the practical problem into mathematical terms
|
| 169 |
+
3. Solve using appropriate mathematical techniques
|
| 170 |
+
4. Interpret the results in the context of the original problem
|
| 171 |
+
|
| 172 |
+
Example contexts might include:
|
| 173 |
+
- Physics applications (motion, forces, work)
|
| 174 |
+
- Engineering scenarios (optimization, rates of change)
|
| 175 |
+
- Economics problems (cost optimization, growth models)
|
| 176 |
+
- Biological systems (population growth, reaction rates)
|
| 177 |
+
- Business applications (profit maximization, inventory management)
|
| 178 |
+
- Social science applications (demographic models, social network analysis)
|
| 179 |
+
- Data science applications (regression, statistical analysis)
|
| 180 |
+
"""
|
| 181 |
+
if difficulty == 5:
|
| 182 |
+
system_prompt = f"""You are an expert mathematics professor creating a graduate-level exam question.
|
| 183 |
STRICT REQUIREMENTS:
|
| 184 |
+
1. Write exactly 1 graduate-level application question on {subject} covering {selected_topic}.
|
| 185 |
2. Advanced Difficulty Requirements:
|
| 186 |
This question must be suitable for PhD qualifying exams or advanced competitions.
|
| 187 |
MUST include:
|
| 188 |
+
- Novel applications of theoretical concepts to complex real-world scenarios
|
| 189 |
+
- Graduate-level mathematical reasoning in practical contexts
|
| 190 |
+
- Sophisticated modeling of real situations
|
| 191 |
- Creative problem-solving approaches
|
| 192 |
+
- Multiple stages of mathematical modeling and analysis
|
| 193 |
|
| 194 |
Follow these specific constraints:
|
| 195 |
{chr(10).join(f' - {c}' for c in difficulty_params['constraints'])}
|
| 196 |
+
{application_addition}
|
| 197 |
3. Style Reference:
|
| 198 |
Question should be {difficulty_params['example_style']}
|
| 199 |
4. The question MUST:
|
|
|
|
| 206 |
- Use $$ on separate lines for equations and solutions
|
| 207 |
- Put each solution step on its own line in $$ $$
|
| 208 |
- DO NOT use \\begin{{aligned}} or similar environments
|
| 209 |
+
6. Include a detailed solution with thorough explanations of:
|
| 210 |
+
- How to model the situation
|
| 211 |
+
- Why specific mathematical techniques were chosen
|
| 212 |
+
- How to interpret the results
|
| 213 |
7. Maintain clear, precise formatting"""
|
| 214 |
+
else:
|
| 215 |
+
system_prompt = f"""You are an expert mathematics professor creating a {difficulty_params['description']} exam question.
|
| 216 |
STRICT REQUIREMENTS:
|
| 217 |
+
1. Write exactly 1 application question on {subject} covering {selected_topic}.
|
| 218 |
2. Difficulty Level Guidelines:
|
| 219 |
{difficulty_params['description'].upper()}
|
| 220 |
Follow these specific constraints:
|
| 221 |
{chr(10).join(f' - {c}' for c in difficulty_params['constraints'])}
|
| 222 |
+
{application_addition}
|
| 223 |
3. Style Reference:
|
| 224 |
Question should be {difficulty_params['example_style']}
|
| 225 |
4. For LaTeX formatting:
|
|
|
|
| 227 |
- Use $$ on separate lines for equations and solutions
|
| 228 |
- Put each solution step on its own line in $$ $$
|
| 229 |
- DO NOT use \\begin{{aligned}} or similar environments
|
| 230 |
+
5. Include a detailed solution that explains:
|
| 231 |
+
- How to model the situation
|
| 232 |
+
- Why specific mathematical techniques were chosen
|
| 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(
|