Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import logging
|
@@ -68,7 +69,13 @@ def query(payload, api_url):
|
|
68 |
|
69 |
# Function to load and process PDF
|
70 |
def process_pdf(uploaded_file):
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
documents = loader.load()
|
73 |
|
74 |
# Split the documents into chunks
|
|
|
1 |
+
import tempfile
|
2 |
import streamlit as st
|
3 |
import requests
|
4 |
import logging
|
|
|
69 |
|
70 |
# Function to load and process PDF
|
71 |
def process_pdf(uploaded_file):
|
72 |
+
# Save the uploaded file to a temporary file
|
73 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as temp_file:
|
74 |
+
temp_file.write(uploaded_file.getvalue())
|
75 |
+
temp_file_path = temp_file.name
|
76 |
+
|
77 |
+
# Use PDFPlumberLoader to load the PDF from the temporary file
|
78 |
+
loader = PDFPlumberLoader(temp_file_path)
|
79 |
documents = loader.load()
|
80 |
|
81 |
# Split the documents into chunks
|