Spaces:
Sleeping
Sleeping
import tempfile | |
import streamlit as st | |
from PIL import Image | |
import os | |
from utils.ingest1 import create_vector_database | |
def process_uploaded_file(): | |
st.title("Upload File to Chat") | |
uploaded_file = st.file_uploader("File upload", type="pdf") | |
if uploaded_file: | |
# Create a temporary directory to save the uploaded file | |
temp_dir = tempfile.mkdtemp() | |
path = os.path.join(temp_dir, uploaded_file.name) | |
# Write the file to the temporary path | |
with open(path, "wb") as f: | |
f.write(uploaded_file.getvalue()) | |
st.write("Document uploaded successfully!") | |
st.write(f"File saved at: {path}") # Debugging aid | |
# Display the uploaded document | |
st.write("Preview of the document:") | |
st.write(uploaded_file) | |
# Button to start parsing and vector database creation | |
if st.button("Start Processing"): | |
st.write("Processing...") | |
with st.spinner('Processing...'): | |
# Call your function to parse data and create vector database | |
create_vector_database(path) | |
st.success("Processing completed!") | |
st.write("Vector database created successfully!") | |
# Show success image | |
#success_image = Image.open("success_image.jpg") | |
##st.image(success_image, caption="Success!", use_column_width=True) | |