Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,8 @@ GROQ_API_KEY = "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"
|
|
12 |
client = Groq(api_key="GROQ_API_KEY")
|
13 |
|
14 |
# Function to extract text from a PDF
|
15 |
-
def extract_text_from_pdf(
|
16 |
-
doc = fitz.open(
|
17 |
text = ""
|
18 |
for page in doc:
|
19 |
text += page.get_text()
|
@@ -56,7 +56,7 @@ pdf_file = st.file_uploader("Choose a PDF file", type="pdf")
|
|
56 |
|
57 |
if pdf_file is not None:
|
58 |
# Extract the text content from the uploaded PDF
|
59 |
-
document_text = extract_text_from_pdf(
|
60 |
|
61 |
# Split the document into chunks (adjust chunk size as needed)
|
62 |
chunk_size = 1000 # Size of each chunk of text for embedding
|
|
|
12 |
client = Groq(api_key="GROQ_API_KEY")
|
13 |
|
14 |
# Function to extract text from a PDF
|
15 |
+
def extract_text_from_pdf(file):
|
16 |
+
doc = fitz.open(file) # Use the file object directly
|
17 |
text = ""
|
18 |
for page in doc:
|
19 |
text += page.get_text()
|
|
|
56 |
|
57 |
if pdf_file is not None:
|
58 |
# Extract the text content from the uploaded PDF
|
59 |
+
document_text = extract_text_from_pdf(pdf_file)
|
60 |
|
61 |
# Split the document into chunks (adjust chunk size as needed)
|
62 |
chunk_size = 1000 # Size of each chunk of text for embedding
|