Spaces:
Runtime error
Runtime error
Update requirements and refactor interface components
Browse files- Upgrade package versions in requirements.txt
- Improve import and formatting in interface/components.py
- Minor code style and readability improvements
Signed-off-by: Unai Garay <[email protected]>
- interface/components.py +19 -10
- requirements.txt +11 -11
interface/components.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
from interface.utils import (
|
| 3 |
-
get_pipelines,
|
| 4 |
-
extract_text_from_url,
|
| 5 |
extract_text_from_file,
|
|
|
|
|
|
|
| 6 |
reset_vars_data,
|
| 7 |
)
|
| 8 |
-
from interface.draw_pipelines import get_pipeline_graph
|
| 9 |
|
| 10 |
|
| 11 |
def component_select_pipeline(container):
|
|
@@ -15,9 +16,11 @@ def component_select_pipeline(container):
|
|
| 15 |
selected_pipeline = st.selectbox(
|
| 16 |
"Select pipeline",
|
| 17 |
pipeline_names,
|
| 18 |
-
index=
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
)
|
| 22 |
index_pipe = pipeline_names.index(selected_pipeline)
|
| 23 |
st.write("---")
|
|
@@ -41,7 +44,10 @@ def component_select_pipeline(container):
|
|
| 41 |
!= list(pipeline_func_parameters[index_pipe].values())
|
| 42 |
):
|
| 43 |
st.session_state["pipeline_func_parameters"] = pipeline_func_parameters
|
| 44 |
-
(
|
|
|
|
|
|
|
|
|
|
| 45 |
index_pipe
|
| 46 |
](**pipeline_func_parameters[index_pipe])
|
| 47 |
st.session_state["pipeline"] = {
|
|
@@ -55,7 +61,10 @@ def component_select_pipeline(container):
|
|
| 55 |
# Reload if Keyword Search is selected
|
| 56 |
elif st.session_state["pipeline"]["name"] == "Keyword Search":
|
| 57 |
st.session_state["pipeline_func_parameters"] = pipeline_func_parameters
|
| 58 |
-
(
|
|
|
|
|
|
|
|
|
|
| 59 |
index_pipe
|
| 60 |
](**pipeline_func_parameters[index_pipe])
|
| 61 |
st.session_state["pipeline"] = {
|
|
@@ -141,9 +150,9 @@ def component_file_input(container, doc_id):
|
|
| 141 |
file = st.file_uploader(
|
| 142 |
"Upload a .txt, .pdf, .csv, image file, audio file", key=doc_id
|
| 143 |
)
|
| 144 |
-
if file
|
| 145 |
extracted_text = extract_text_from_file(file)
|
| 146 |
-
if extracted_text
|
| 147 |
files.append({"text": extracted_text, "doc_id": doc_id})
|
| 148 |
doc_id += 1
|
| 149 |
st.markdown("---")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from interface.draw_pipelines import get_pipeline_graph
|
| 4 |
from interface.utils import (
|
|
|
|
|
|
|
| 5 |
extract_text_from_file,
|
| 6 |
+
extract_text_from_url,
|
| 7 |
+
get_pipelines,
|
| 8 |
reset_vars_data,
|
| 9 |
)
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
def component_select_pipeline(container):
|
|
|
|
| 16 |
selected_pipeline = st.selectbox(
|
| 17 |
"Select pipeline",
|
| 18 |
pipeline_names,
|
| 19 |
+
index=(
|
| 20 |
+
pipeline_names.index("Keyword Search")
|
| 21 |
+
if "Keyword Search" in pipeline_names
|
| 22 |
+
else 0
|
| 23 |
+
),
|
| 24 |
)
|
| 25 |
index_pipe = pipeline_names.index(selected_pipeline)
|
| 26 |
st.write("---")
|
|
|
|
| 44 |
!= list(pipeline_func_parameters[index_pipe].values())
|
| 45 |
):
|
| 46 |
st.session_state["pipeline_func_parameters"] = pipeline_func_parameters
|
| 47 |
+
(
|
| 48 |
+
search_pipeline,
|
| 49 |
+
index_pipeline,
|
| 50 |
+
) = pipeline_funcs[
|
| 51 |
index_pipe
|
| 52 |
](**pipeline_func_parameters[index_pipe])
|
| 53 |
st.session_state["pipeline"] = {
|
|
|
|
| 61 |
# Reload if Keyword Search is selected
|
| 62 |
elif st.session_state["pipeline"]["name"] == "Keyword Search":
|
| 63 |
st.session_state["pipeline_func_parameters"] = pipeline_func_parameters
|
| 64 |
+
(
|
| 65 |
+
search_pipeline,
|
| 66 |
+
index_pipeline,
|
| 67 |
+
) = pipeline_funcs[
|
| 68 |
index_pipe
|
| 69 |
](**pipeline_func_parameters[index_pipe])
|
| 70 |
st.session_state["pipeline"] = {
|
|
|
|
| 150 |
file = st.file_uploader(
|
| 151 |
"Upload a .txt, .pdf, .csv, image file, audio file", key=doc_id
|
| 152 |
)
|
| 153 |
+
if file is not None:
|
| 154 |
extracted_text = extract_text_from_file(file)
|
| 155 |
+
if extracted_text is not None:
|
| 156 |
files.append({"text": extracted_text, "doc_id": doc_id})
|
| 157 |
doc_id += 1
|
| 158 |
st.markdown("---")
|
requirements.txt
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
-
streamlit==1.
|
| 2 |
-
streamlit_option_menu==0.
|
| 3 |
-
farm-haystack==1.
|
| 4 |
-
black==
|
| 5 |
-
plotly==5.
|
| 6 |
newspaper3k==0.2.8
|
| 7 |
-
PyPDF2==
|
| 8 |
-
pytesseract==0.3.
|
| 9 |
-
soundfile==0.
|
| 10 |
-
espnet
|
| 11 |
pydub==0.25.1
|
| 12 |
espnet_model_zoo==0.1.7
|
| 13 |
-
|
| 14 |
-
altair
|
|
|
|
| 1 |
+
streamlit==1.40.1
|
| 2 |
+
streamlit_option_menu==0.4.0
|
| 3 |
+
farm-haystack==1.26.4
|
| 4 |
+
black==24.8.0
|
| 5 |
+
plotly==5.24.1
|
| 6 |
newspaper3k==0.2.8
|
| 7 |
+
PyPDF2==3.0.1
|
| 8 |
+
pytesseract==0.3.13
|
| 9 |
+
soundfile==0.13.1
|
| 10 |
+
espnet==202412
|
| 11 |
pydub==0.25.1
|
| 12 |
espnet_model_zoo==0.1.7
|
| 13 |
+
openai-whisper==20240930
|
| 14 |
+
altair==5.4.1
|