atz21 commited on
Commit
dc7cfb7
·
verified ·
1 Parent(s): d9fb128

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -629,7 +629,7 @@ Grading JSON:
629
  try:
630
  contents = [prompt] + images
631
  response = client.models.generate_content(
632
- model="gemini-2.0-flash-exp",
633
  contents=contents
634
  )
635
  raw_text = response.text
@@ -794,7 +794,7 @@ def align_and_grade_pipeline(qp_path, ms_path, ans_path, subject="Maths", imprin
794
 
795
  print("1.i) Transcribing QP+MS (questions first, then full markscheme, with graph detection)...")
796
  qpms_prompt = QP_MS_TRANSCRIPTION_PROMPT["content"] + "\nAt the end, also list all questions in the markscheme where a graph is expected, in the format:\nGraph expected in:\n- Question <number> → Page <number>\n(One per line, after ==== MARKSCHEME END ====)"
797
- qpms_text = gemini_generate_content(qpms_prompt, file_upload_obj=merged_uploaded)
798
  print("📄 QP+MS transcription received. Saving debug file: debug_qpms_transcript.txt")
799
  with open("debug_qpms_transcript.txt", "w", encoding="utf-8") as f:
800
  f.write(qpms_text)
@@ -812,7 +812,7 @@ def align_and_grade_pipeline(qp_path, ms_path, ans_path, subject="Maths", imprin
812
 
813
  print("1.ii) Building AS transcription prompt with expected question IDs and graph detection, sending to Gemini...")
814
  as_prompt = build_as_cot_prompt_with_expected_ids(extracted_ids, qpms_text) + "\nAt the end, also list all answers where a graph is found, in the format:\nGraph found in:\n- Answer <number> → Page <number>\n(One per line, after all answers)"
815
- as_text = gemini_generate_content(as_prompt, file_upload_obj=ans_uploaded)
816
  print("📝 AS transcription received. Saving debug file: debug_as_transcript.txt")
817
  with open("debug_as_transcript.txt", "w", encoding="utf-8") as f:
818
  f.write(as_text)
@@ -839,7 +839,7 @@ def align_and_grade_pipeline(qp_path, ms_path, ans_path, subject="Maths", imprin
839
  grading_prompt_obj = get_grading_prompt(subject.lower())
840
  grading_prompt_system = grading_prompt_obj["content"]
841
  grading_images = ms_graph_images + as_graph_images
842
- grading_text = gemini_generate_content(grading_prompt_system + "\n\nPlease grade the following transcripts:\n" + grading_input, image_obj=grading_images if grading_images else None)
843
  print("🧾 Grading output received. Saving debug file: debug_grading.md")
844
  with open("debug_grading.md", "w", encoding="utf-8") as f:
845
  f.write(grading_text)
 
629
  try:
630
  contents = [prompt] + images
631
  response = client.models.generate_content(
632
+ model="gemini-2.5-flash",
633
  contents=contents
634
  )
635
  raw_text = response.text
 
794
 
795
  print("1.i) Transcribing QP+MS (questions first, then full markscheme, with graph detection)...")
796
  qpms_prompt = QP_MS_TRANSCRIPTION_PROMPT["content"] + "\nAt the end, also list all questions in the markscheme where a graph is expected, in the format:\nGraph expected in:\n- Question <number> → Page <number>\n(One per line, after ==== MARKSCHEME END ====)"
797
+ qpms_text = gemini_generate_content(qpms_prompt, file_upload_obj=merged_uploaded, model_name="gemini-2.5-flash")
798
  print("📄 QP+MS transcription received. Saving debug file: debug_qpms_transcript.txt")
799
  with open("debug_qpms_transcript.txt", "w", encoding="utf-8") as f:
800
  f.write(qpms_text)
 
812
 
813
  print("1.ii) Building AS transcription prompt with expected question IDs and graph detection, sending to Gemini...")
814
  as_prompt = build_as_cot_prompt_with_expected_ids(extracted_ids, qpms_text) + "\nAt the end, also list all answers where a graph is found, in the format:\nGraph found in:\n- Answer <number> → Page <number>\n(One per line, after all answers)"
815
+ as_text = gemini_generate_content(as_prompt, file_upload_obj=ans_uploaded, model_name="gemini-2.5-flash")
816
  print("📝 AS transcription received. Saving debug file: debug_as_transcript.txt")
817
  with open("debug_as_transcript.txt", "w", encoding="utf-8") as f:
818
  f.write(as_text)
 
839
  grading_prompt_obj = get_grading_prompt(subject.lower())
840
  grading_prompt_system = grading_prompt_obj["content"]
841
  grading_images = ms_graph_images + as_graph_images
842
+ grading_text = gemini_generate_content(grading_prompt_system + "\n\nPlease grade the following transcripts:\n" + grading_input, image_obj=grading_images if grading_images else None, model_name="gemini-2.5-pro")
843
  print("🧾 Grading output received. Saving debug file: debug_grading.md")
844
  with open("debug_grading.md", "w", encoding="utf-8") as f:
845
  f.write(grading_text)