Seth0330 commited on
Commit
bcd91a9
·
verified ·
1 Parent(s): 2a34e42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -6,7 +6,7 @@ import re
6
  import os
7
  import time
8
 
9
- from main import extract_key_phrases, score_sentences, summarize_text # Optional, keep if you use them elsewhere
10
 
11
  st.set_page_config(page_title="PDF Tools", layout="wide")
12
 
@@ -238,13 +238,15 @@ UNSTRACT_API_KEY = os.getenv("UNSTRACT_API_KEY") # Set this in your environment
238
 
239
  def extract_text_from_pdf_unstract(pdf_file):
240
  headers = {"unstract-key": UNSTRACT_API_KEY}
241
- pdf_file.seek(0) # Make sure pointer is at start!
242
  filename = getattr(pdf_file, "name", "uploaded.pdf")
243
  files = {
244
- "file": (filename, pdf_file, "application/pdf"),
245
  }
246
  whisper_url = f"{UNSTRACT_BASE}/whisper"
247
  with st.spinner("Uploading and processing PDF with Unstract..."):
 
 
248
  r = requests.post(whisper_url, files=files, headers=headers)
249
  if r.status_code != 202:
250
  st.error(f"Unstract: Error uploading PDF: {r.status_code} - {r.text}")
 
6
  import os
7
  import time
8
 
9
+ from main import extract_key_phrases, score_sentences, summarize_text # Optional, keep if used elsewhere
10
 
11
  st.set_page_config(page_title="PDF Tools", layout="wide")
12
 
 
238
 
239
  def extract_text_from_pdf_unstract(pdf_file):
240
  headers = {"unstract-key": UNSTRACT_API_KEY}
241
+ pdf_bytes = pdf_file.read()
242
  filename = getattr(pdf_file, "name", "uploaded.pdf")
243
  files = {
244
+ "file": (filename, io.BytesIO(pdf_bytes), "application/pdf"),
245
  }
246
  whisper_url = f"{UNSTRACT_BASE}/whisper"
247
  with st.spinner("Uploading and processing PDF with Unstract..."):
248
+ # For debugging, uncomment next line:
249
+ # st.write("DEBUG UPLOAD:", files)
250
  r = requests.post(whisper_url, files=files, headers=headers)
251
  if r.status_code != 202:
252
  st.error(f"Unstract: Error uploading PDF: {r.status_code} - {r.text}")