Spaces:
Sleeping
Sleeping
Update src/pdf_up.py
Browse files- src/pdf_up.py +8 -11
src/pdf_up.py
CHANGED
|
@@ -8,34 +8,31 @@ def process_uploaded_file():
|
|
| 8 |
st.title("Upload File to Chat")
|
| 9 |
uploaded_file = st.file_uploader("File upload", type="pdf")
|
| 10 |
if uploaded_file:
|
|
|
|
| 11 |
temp_dir = tempfile.mkdtemp()
|
| 12 |
path = os.path.join(temp_dir, uploaded_file.name)
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
st.write("Document uploaded successfully!")
|
|
|
|
|
|
|
| 17 |
# Display the uploaded document
|
| 18 |
st.write("Preview of the document:")
|
| 19 |
st.write(uploaded_file)
|
| 20 |
|
| 21 |
# Button to start parsing and vector database creation
|
| 22 |
if st.button("Start Processing"):
|
| 23 |
-
# Placeholder for processing logic
|
| 24 |
st.write("Processing...")
|
| 25 |
-
|
| 26 |
-
# Placeholder for progress bar
|
| 27 |
with st.spinner('Processing...'):
|
| 28 |
# Call your function to parse data and create vector database
|
| 29 |
create_vector_database(path)
|
| 30 |
|
| 31 |
st.success("Processing completed!")
|
| 32 |
-
|
| 33 |
-
# Display success message
|
| 34 |
st.write("Vector database created successfully!")
|
| 35 |
|
| 36 |
# Show success image
|
| 37 |
success_image = Image.open("success_image.jpg")
|
| 38 |
st.image(success_image, caption="Success!", use_column_width=True)
|
| 39 |
-
|
| 40 |
-
# Add a footer
|
| 41 |
-
#st.text("Built with Streamlit")
|
|
|
|
| 8 |
st.title("Upload File to Chat")
|
| 9 |
uploaded_file = st.file_uploader("File upload", type="pdf")
|
| 10 |
if uploaded_file:
|
| 11 |
+
# Create a temporary directory to save the uploaded file
|
| 12 |
temp_dir = tempfile.mkdtemp()
|
| 13 |
path = os.path.join(temp_dir, uploaded_file.name)
|
| 14 |
+
|
| 15 |
+
# Write the file to the temporary path
|
| 16 |
+
with open(path, "wb") as f:
|
| 17 |
+
f.write(uploaded_file.getvalue())
|
| 18 |
+
|
| 19 |
st.write("Document uploaded successfully!")
|
| 20 |
+
st.write(f"File saved at: {path}") # Debugging aid
|
| 21 |
+
|
| 22 |
# Display the uploaded document
|
| 23 |
st.write("Preview of the document:")
|
| 24 |
st.write(uploaded_file)
|
| 25 |
|
| 26 |
# Button to start parsing and vector database creation
|
| 27 |
if st.button("Start Processing"):
|
|
|
|
| 28 |
st.write("Processing...")
|
|
|
|
|
|
|
| 29 |
with st.spinner('Processing...'):
|
| 30 |
# Call your function to parse data and create vector database
|
| 31 |
create_vector_database(path)
|
| 32 |
|
| 33 |
st.success("Processing completed!")
|
|
|
|
|
|
|
| 34 |
st.write("Vector database created successfully!")
|
| 35 |
|
| 36 |
# Show success image
|
| 37 |
success_image = Image.open("success_image.jpg")
|
| 38 |
st.image(success_image, caption="Success!", use_column_width=True)
|
|
|
|
|
|
|
|
|