From 60cce4e579463c6af5980b47a6efff7824bdf28e Mon Sep 17 00:00:00 2001 From: Markus Sagen Date: Fri, 6 Aug 2021 17:45:36 +0200 Subject: [PATCH] Allow to upload multiple files simultaneously in Haystack UI (#1323) * Fix only one file upload for Haystack UI When using Haystack UI and streamlit, the default behavior is to upload one file at at time and override the file you have already uploaded. Streamlit now supports uploading multiple files and may be more intuitive for users of Haystack to use it as the default behavior. Return type for `st.sidebar.file_uploader` when `accept_multiple_files=True` is a list of the files and empty if no files are provided * Update requirements.txt * Update requirements.txt Co-authored-by: Malte Pietsch --- ui/requirements.txt | 2 +- ui/webapp.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ui/requirements.txt b/ui/requirements.txt index 7563be733..14d9d9fa3 100644 --- a/ui/requirements.txt +++ b/ui/requirements.txt @@ -1,2 +1,2 @@ -streamlit==0.84.0 +streamlit>=0.84.0 st-annotated-text==1.1.0 diff --git a/ui/webapp.py b/ui/webapp.py index c630f9c82..e5a4a299c 100644 --- a/ui/webapp.py +++ b/ui/webapp.py @@ -65,14 +65,15 @@ eval_mode = st.sidebar.checkbox("Evaluation mode") debug = st.sidebar.checkbox("Show debug info") st.sidebar.write("## File Upload:") -data_file = st.sidebar.file_uploader("", type=["pdf", "txt", "docx"]) -# Upload file -if data_file: - raw_json = upload_doc(data_file) - st.sidebar.write(raw_json) - if debug: - st.subheader("REST API JSON response") +data_files = st.sidebar.file_uploader("", type=["pdf", "txt", "docx"], accept_multiple_files=True) +for data_file in data_files: + # Upload file + if data_file: + raw_json = upload_doc(data_file) st.sidebar.write(raw_json) + if debug: + st.subheader("REST API JSON response") + st.sidebar.write(raw_json) # load csv into pandas dataframe if eval_mode: