Spaces:
Sleeping
Sleeping
ariankhalfani
commited on
Commit
•
49e0436
1
Parent(s):
0bd6f01
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import os
|
2 |
import requests
|
3 |
import streamlit as st
|
4 |
-
import
|
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 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
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):
|