captain-awesome commited on
Commit
72fb9e5
·
1 Parent(s): 66b8021

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -362,6 +362,8 @@ def main():
362
  loaded_documents = []
363
 
364
  if uploaded_files:
 
 
365
  # Create a temporary directory
366
  # with tempfile.TemporaryDirectory() as td:
367
  # # Move the uploaded files to the temporary directory and process them
@@ -385,7 +387,6 @@ def main():
385
  # Use Langchain loader to process the file
386
  loader = loader_class(os.path.join(td, file), **loader_args)
387
  loaded_documents.extend(loader.load())
388
- st.write(f"loaded_documents: {loaded_documents}")
389
  # # Check if the extension is in FILE_LOADER_MAPPING
390
  # if ext in FILE_LOADER_MAPPING:
391
  # loader_class, loader_args = FILE_LOADER_MAPPING[ext]
@@ -401,7 +402,7 @@ def main():
401
  # loader = loader_class(os.path.join(td, file), **loader_args)
402
  # loaded_documents.extend(loader.load())
403
  # st.write(f"loaded_documents: {loaded_documents}")
404
-
405
  st.write("Chat with the Document:")
406
  query = st.text_input("Ask a question:")
407
 
 
362
  loaded_documents = []
363
 
364
  if uploaded_files:
365
+ if not uploaded_documents:
366
+ st.warning("Please upload some documents.")
367
  # Create a temporary directory
368
  # with tempfile.TemporaryDirectory() as td:
369
  # # Move the uploaded files to the temporary directory and process them
 
387
  # Use Langchain loader to process the file
388
  loader = loader_class(os.path.join(td, file), **loader_args)
389
  loaded_documents.extend(loader.load())
 
390
  # # Check if the extension is in FILE_LOADER_MAPPING
391
  # if ext in FILE_LOADER_MAPPING:
392
  # loader_class, loader_args = FILE_LOADER_MAPPING[ext]
 
402
  # loader = loader_class(os.path.join(td, file), **loader_args)
403
  # loaded_documents.extend(loader.load())
404
  # st.write(f"loaded_documents: {loaded_documents}")
405
+ st.write(f"loaded_documents: {loaded_documents}")
406
  st.write("Chat with the Document:")
407
  query = st.text_input("Ask a question:")
408