ariankhalfani commited on
Commit
49e0436
1 Parent(s): 0bd6f01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
  import requests
3
  import streamlit as st
4
- import PyMuPDF
5
 
6
  # Get the Hugging Face API Token from environment variables
7
  HF_API_TOKEN = os.getenv("HF_API_KEY")
@@ -19,9 +19,11 @@ def query_model(api_url, payload):
19
 
20
  def extract_pdf_text(uploaded_file):
21
  pdf_text = ""
22
- pdf_doc = PyMuPDF.open(uploaded_file)
23
- for page_num in range(len(pdf_doc)):
24
- pdf_text += pdf_doc.getPageText(page_num)
 
 
25
  return pdf_text
26
 
27
  def add_message_to_conversation(user_message, bot_message, model_name):
 
1
  import os
2
  import requests
3
  import streamlit as st
4
+ import PyPDF2
5
 
6
  # Get the Hugging Face API Token from environment variables
7
  HF_API_TOKEN = os.getenv("HF_API_KEY")
 
19
 
20
  def extract_pdf_text(uploaded_file):
21
  pdf_text = ""
22
+ pdf_reader = PyPDF2.PdfFileReader(uploaded_file)
23
+ num_pages = pdf_reader.numPages
24
+ for page_num in range(num_pages):
25
+ page = pdf_reader.getPage(page_num)
26
+ pdf_text += page.extract_text()
27
  return pdf_text
28
 
29
  def add_message_to_conversation(user_message, bot_message, model_name):