Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -145,35 +145,37 @@ def generate_test(total_marks, topic_name, level):
|
|
| 145 |
]].to_string(index=False)
|
| 146 |
|
| 147 |
# --- Prompt for the LLM ---
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
| 177 |
|
| 178 |
try:
|
| 179 |
response = model.generate_content(prompt)
|
|
|
|
| 145 |
]].to_string(index=False)
|
| 146 |
|
| 147 |
# --- Prompt for the LLM ---
|
| 148 |
+
prompt = f"""
|
| 149 |
+
You are an expert test creator for the International Baccalaureate (IB) Mathematics program.
|
| 150 |
+
Your task is to create a test paper based on the user's request using a provided question bank.
|
| 151 |
+
|
| 152 |
+
**User Request:**
|
| 153 |
+
- Total Marks: {total_marks}
|
| 154 |
+
- Topic: "{topic_name}"
|
| 155 |
+
- Level: {level}
|
| 156 |
+
|
| 157 |
+
**Instructions:**
|
| 158 |
+
1. Carefully select a combination of questions from the provided **QUESTION BANK** that best fit the requested topic and level.
|
| 159 |
+
2. The total marks of all selected questions should be as close as possible to the requested **Total Marks ({total_marks})**.
|
| 160 |
+
3. When selecting questions, **prioritize the most recent questions** (based on the 'Date' field) within the requested topic and level.
|
| 161 |
+
4. If multiple questions have similar relevance or marks, **prefer newer questions** over older ones.
|
| 162 |
+
5. Present the final test in a clean, well-formatted markdown format. It should look like a real test paper.
|
| 163 |
+
6. For each question, you **MUST** include its ID (from the 'Question Number' column), Date, Topic code, and the maximum marks.
|
| 164 |
+
7. Display the full question content, including all sub-questions and any included diagrams or formulas, exactly as it appears in the 'QP Content' column.
|
| 165 |
+
8. Use the provided **TOPICS LIST** to understand which topic codes fall under the user's requested topic name. For example, if the user requests 'Calculus', you should look for questions with topic codes like SL 5.1, SL 5.2, ..., AHL 5.19.
|
| 166 |
+
|
| 167 |
+
**TOPICS LIST:**
|
| 168 |
+
---
|
| 169 |
+
{TOPICS}
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
+
**QUESTION BANK:**
|
| 173 |
+
---
|
| 174 |
+
{question_data}
|
| 175 |
+
---
|
| 176 |
+
|
| 177 |
+
Now, create the test based on the user's request, ensuring that the **latest available questions** for the topic are prioritized.
|
| 178 |
+
"""
|
| 179 |
|
| 180 |
try:
|
| 181 |
response = model.generate_content(prompt)
|