Spaces:
Sleeping
Sleeping
Commit
·
bdf01f6
1
Parent(s):
d50fa2e
changed password, added modal for upload button
Browse files- app.py +26 -11
- hashed_password.pkl +0 -0
app.py
CHANGED
|
@@ -17,10 +17,13 @@ import pandas as pd
|
|
| 17 |
import haystack
|
| 18 |
|
| 19 |
from datetime import datetime
|
| 20 |
-
|
| 21 |
import streamlit_authenticator as stauth
|
| 22 |
import pickle
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
names = ['admin']
|
| 26 |
usernames = ['admin']
|
|
@@ -35,7 +38,7 @@ DISABLE_FILE_UPLOAD = bool(os.getenv("DISABLE_FILE_UPLOAD"))
|
|
| 35 |
# Define a function to handle file uploads
|
| 36 |
def upload_files():
|
| 37 |
uploaded_files = upload_container.file_uploader(
|
| 38 |
-
"upload", type=["pdf", "txt", "docx"], accept_multiple_files=True, label_visibility="hidden"
|
| 39 |
)
|
| 40 |
return uploaded_files
|
| 41 |
|
|
@@ -67,8 +70,6 @@ def process_file(data_file, preprocesor, document_store):
|
|
| 67 |
|
| 68 |
# Define a function to upload the documents to haystack document store
|
| 69 |
def upload_document():
|
| 70 |
-
print(f'Uploading document store at {datetime.now()}')
|
| 71 |
-
upload_status = 0
|
| 72 |
if data_files is not None:
|
| 73 |
for data_file in data_files:
|
| 74 |
# Upload file
|
|
@@ -86,8 +87,10 @@ def upload_document():
|
|
| 86 |
# Define a function to reset the documents in haystack document store
|
| 87 |
def reset_documents():
|
| 88 |
print('\nReseting documents list at ' + str(datetime.now()) + '\n')
|
|
|
|
| 89 |
document_store.delete_documents()
|
| 90 |
|
|
|
|
| 91 |
try:
|
| 92 |
args = parser.parse_args()
|
| 93 |
preprocesor = start_preprocessor_node()
|
|
@@ -117,6 +120,7 @@ try:
|
|
| 117 |
st.warning("Please enter your username and password")
|
| 118 |
|
| 119 |
if authentication_status:
|
|
|
|
| 120 |
# Sidebar for Task Selection
|
| 121 |
st.sidebar.header('Options:')
|
| 122 |
|
|
@@ -139,17 +143,28 @@ try:
|
|
| 139 |
|
| 140 |
set_initial_state()
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
st.write('# ' + args.name)
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
# File upload block
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
# Button to update files in the documentStore
|
| 152 |
-
|
| 153 |
|
| 154 |
# Button to reset the documents in DocumentStore
|
| 155 |
st.sidebar.button("Reset documents", on_click=reset_documents, args=())
|
|
|
|
| 17 |
import haystack
|
| 18 |
|
| 19 |
from datetime import datetime
|
| 20 |
+
import streamlit.components.v1 as components
|
| 21 |
import streamlit_authenticator as stauth
|
| 22 |
import pickle
|
| 23 |
|
| 24 |
+
from streamlit_modal import Modal
|
| 25 |
+
|
| 26 |
+
|
| 27 |
|
| 28 |
names = ['admin']
|
| 29 |
usernames = ['admin']
|
|
|
|
| 38 |
# Define a function to handle file uploads
|
| 39 |
def upload_files():
|
| 40 |
uploaded_files = upload_container.file_uploader(
|
| 41 |
+
"upload", type=["pdf", "txt", "docx"], accept_multiple_files=True, label_visibility="hidden", key=1
|
| 42 |
)
|
| 43 |
return uploaded_files
|
| 44 |
|
|
|
|
| 70 |
|
| 71 |
# Define a function to upload the documents to haystack document store
|
| 72 |
def upload_document():
|
|
|
|
|
|
|
| 73 |
if data_files is not None:
|
| 74 |
for data_file in data_files:
|
| 75 |
# Upload file
|
|
|
|
| 87 |
# Define a function to reset the documents in haystack document store
|
| 88 |
def reset_documents():
|
| 89 |
print('\nReseting documents list at ' + str(datetime.now()) + '\n')
|
| 90 |
+
st.session_state.data_files = None
|
| 91 |
document_store.delete_documents()
|
| 92 |
|
| 93 |
+
|
| 94 |
try:
|
| 95 |
args = parser.parse_args()
|
| 96 |
preprocesor = start_preprocessor_node()
|
|
|
|
| 120 |
st.warning("Please enter your username and password")
|
| 121 |
|
| 122 |
if authentication_status:
|
| 123 |
+
|
| 124 |
# Sidebar for Task Selection
|
| 125 |
st.sidebar.header('Options:')
|
| 126 |
|
|
|
|
| 143 |
|
| 144 |
set_initial_state()
|
| 145 |
|
| 146 |
+
modal = Modal("Upload Files", key="demo-modal")
|
| 147 |
+
open_modal = st.sidebar.button("Upload Files")
|
| 148 |
+
if open_modal:
|
| 149 |
+
modal.open()
|
| 150 |
+
|
| 151 |
st.write('# ' + args.name)
|
| 152 |
+
if modal.is_open():
|
| 153 |
+
with modal.container():
|
| 154 |
+
if not DISABLE_FILE_UPLOAD:
|
| 155 |
+
upload_container = st.container()
|
| 156 |
+
upload_container.write("## File Upload:")
|
| 157 |
+
data_files = upload_files()
|
| 158 |
+
upload_document()
|
| 159 |
+
st.session_state.sidebar_state = 'collapsed'
|
| 160 |
|
| 161 |
# File upload block
|
| 162 |
+
# if not DISABLE_FILE_UPLOAD:
|
| 163 |
+
# upload_container = st.sidebar.container()
|
| 164 |
+
# upload_container.write("## File Upload:")
|
| 165 |
+
# data_files = upload_files()
|
|
|
|
| 166 |
# Button to update files in the documentStore
|
| 167 |
+
# upload_container.button('Upload Files', on_click=upload_document, args=())
|
| 168 |
|
| 169 |
# Button to reset the documents in DocumentStore
|
| 170 |
st.sidebar.button("Reset documents", on_click=reset_documents, args=())
|
hashed_password.pkl
CHANGED
|
Binary files a/hashed_password.pkl and b/hashed_password.pkl differ
|
|
|