atz21 commited on
Commit
9fe1f3e
·
verified ·
1 Parent(s): 559b8c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -110,6 +110,18 @@ def save_as_pdf(text, filename="output.pdf"):
110
  pdf.save(filename)
111
  return filename
112
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  def compress_pdf(input_path, output_path=None, max_size=20*1024*1024):
114
  if output_path is None:
115
  base, ext = os.path.splitext(input_path)
@@ -540,8 +552,11 @@ def align_and_grade_pipeline(qp_path, ms_path, ans_path, imprint=False):
540
 
541
  # Upload files to Gemini
542
  print("🔼 Uploading files to Gemini...")
543
- merged_uploaded = genai.upload_file(path=merged_qpms_path, display_name="QP+MS (merged)")
544
- ans_uploaded = genai.upload_file(path=ans_path, display_name="Answer Sheet")
 
 
 
545
  print("✅ Upload complete.")
546
 
547
  # Create model and print which selected
 
110
  pdf.save(filename)
111
  return filename
112
 
113
+ # --- Gemini standard upload (no RAG required) ---
114
+ def upload_to_gemini(path, display_name=None):
115
+ import google.generativeai as genai
116
+ with open(path, "rb") as f:
117
+ uploaded_file = genai.upload_file(
118
+ file=f, # <- file object
119
+ mime_type="application/pdf", # <- set MIME type
120
+ display_name=display_name or os.path.basename(path)
121
+ )
122
+ return uploaded_file
123
+
124
+
125
  def compress_pdf(input_path, output_path=None, max_size=20*1024*1024):
126
  if output_path is None:
127
  base, ext = os.path.splitext(input_path)
 
552
 
553
  # Upload files to Gemini
554
  print("🔼 Uploading files to Gemini...")
555
+
556
+ merged_uploaded = upload_to_gemini(merged_qpms_path, "QP+MS (merged)")
557
+ ans_uploaded = upload_to_gemini(ans_path, "Answer Sheet")
558
+
559
+
560
  print("✅ Upload complete.")
561
 
562
  # Create model and print which selected