atz21 commited on
Commit
52a0043
·
verified ·
1 Parent(s): de357f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -46
app.py CHANGED
@@ -20,53 +20,48 @@ genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
20
  GRID_ROWS, GRID_COLS = 20, 14
21
 
22
  # ---------------- PROMPTS ----------------
23
- PROMPTS = {
24
- # Updated QP+MS transcription prompt:
25
- "QP_MS_TRANSCRIPTION": {
26
- "role": "system",
27
- "content": """You are a high-quality OCR/Transcription assistant.
28
-
29
- INPUT: This file is a scanned/printed PDF that first contains the Question Paper and then, after all questions, the Markscheme.
30
- TASK: Produce an exact transcription in plain text with clear separators.
31
-
32
- IMPORTANT: Output **ALL QUESTIONS FIRST** (in the same order they appear in the PDF).
33
- For each question, output:
34
- - Question ID (exact as printed, e.g., "1", "2(a)", "3.b", "4(ii)")
35
- - Question text (exact wording; do not change punctuation)
36
- - Total marks for that question (exact number if printed; if not printed leave blank)
37
-
38
- After you have outputted **all questions** (and their total marks), output the **entire markscheme block** exactly as it appears in the PDF. In the markscheme section, ensure notation is explicit and clear: represent M, A, R notation **in brackets** after each mark item where applicable. For example:
39
- [M1] Description...
40
- [A1] Description...
41
- [R1] Description...
42
-
43
- Also include at the top a single line stating the total marks of the paper (if present in the paper).
44
-
45
- KEY REQUIREMENTS:
46
- - Do NOT interleave question and markscheme. First: questions + totals. Second: markscheme (verbatim, preserving mark IDs/formatting).
47
- - Transcribe the markscheme verbatim; do NOT correct or reformat content (only ensure M/A/R are shown in brackets if present).
48
- - Represent M, A, R marks explicitly and consistently (e.g., M1, A2, R1). If mark IDs are missing, transcribe as-is.
49
- - Ignore any N1, N2, N3 notations (do not use them).
50
-
51
- OUTPUT FORMAT (use these exact markers to make parsing straightforward):
52
- ==== PAPER TOTAL MARKS ====
53
- <integer or blank>
54
-
55
- ==== QUESTIONS BEGIN ====
56
- Question: <id>
57
- Total Marks: <integer or blank>
58
- QP:
59
- <question text (multiline)>
60
- --QUESTION-END--
61
-
62
- (repeat the Question block for all questions, in order)
63
- ==== QUESTIONS END ====
64
-
65
- ==== MARKSCHEME BEGIN ====
66
- <verbatim markscheme text exactly as in PDF; include mark IDs and use brackets for M/A/R notations where they appear>
67
- ==== MARKSCHEME END ====
68
  """
69
- },
 
70
 
71
  # GRADING_PROMPT unchanged except we will print steps around calling it
72
  "GRADING_PROMPT": {
 
20
  GRID_ROWS, GRID_COLS = 20, 14
21
 
22
  # ---------------- PROMPTS ----------------
23
+ PROMPTS["QP_MS_TRANSCRIPTION"] = {
24
+ "role": "system",
25
+ "content": """You are a high-quality OCR/Transcription assistant.
26
+
27
+ INPUT: This file is a PDF that first contains the Question Paper and immediately after it the Markscheme.
28
+
29
+ TASK:
30
+ 1. Transcribe EXACTLY all the questions FIRST (with their total marks).
31
+ 2. After ALL questions, transcribe the Markscheme exactly, preserving M/A/R notation in brackets.
32
+ 3. Always number the questions sequentially (Question 1, Question 2, Question 3, …) **in the order they appear in the PDF**, even if the PDF shows a different number or leaves it blank. Do NOT skip or leave Question: blank.
33
+
34
+ FORMAT:
35
+ ==== PAPER TOTAL MARKS ====
36
+ <total marks>
37
+
38
+ ==== QUESTIONS BEGIN ====
39
+ Question 1
40
+ Total Marks: <number>
41
+ QP: <question text>
42
+ --QUESTION-END--
43
+
44
+ Question 2
45
+ Total Marks: <number>
46
+ QP: <question text>
47
+ --QUESTION-END--
48
+
49
+ (repeat for all questions in order of appearance)
50
+
51
+ ==== QUESTIONS END ====
52
+
53
+ ==== MARKSCHEME BEGIN ====
54
+ Answer 1:
55
+ <exact MS for Q1 with notations M1, A1, R1 etc>
56
+
57
+ Answer 2:
58
+ <exact MS for Q2 with notations>
59
+
60
+ (repeat for all answers)
61
+ ==== MARKSCHEME END ====
 
 
 
 
 
 
62
  """
63
+ }
64
+ ,
65
 
66
  # GRADING_PROMPT unchanged except we will print steps around calling it
67
  "GRADING_PROMPT": {