Spaces:
Runtime error
Runtime error
Update appStore/multiapp.py
Browse files- appStore/multiapp.py +5 -18
appStore/multiapp.py
CHANGED
@@ -1,15 +1,10 @@
|
|
1 |
-
|
2 |
-
|
|
|
3 |
import streamlit as st
|
4 |
from PIL import Image
|
5 |
import tempfile
|
6 |
import logging
|
7 |
-
from sklearn.feature_extraction import _stop_words
|
8 |
-
from haystack.document_stores import InMemoryDocumentStore
|
9 |
-
from haystack.pipelines import ExtractiveQAPipeline
|
10 |
-
from haystack.nodes import FARMReader, TfidfRetriever
|
11 |
-
import scripts.process as pre
|
12 |
-
import scripts.clean as clean
|
13 |
logger = logging.getLogger(__name__)
|
14 |
|
15 |
# Initialization
|
@@ -19,13 +14,6 @@ if 'file' not in st.session_state:
|
|
19 |
#Haystack Components
|
20 |
@st.cache(hash_funcs={"builtins.SwigPyObject": lambda _: None},allow_output_mutation=True)
|
21 |
|
22 |
-
def start_haystack(documents_processed):
|
23 |
-
document_store = InMemoryDocumentStore()
|
24 |
-
document_store.write_documents(documents_processed)
|
25 |
-
retriever = TfidfRetriever(document_store=document_store)
|
26 |
-
reader = FARMReader(model_name_or_path="deepset/tinyroberta-squad2", use_gpu=True) #deepset/roberta-base-squad2
|
27 |
-
pipeline = ExtractiveQAPipeline(reader, retriever)
|
28 |
-
return pipeline
|
29 |
|
30 |
class MultiApp:
|
31 |
"""
|
@@ -51,7 +39,7 @@ class MultiApp:
|
|
51 |
|
52 |
def run(self):
|
53 |
if 'file' not in st.session_state:
|
54 |
-
st.session_state['
|
55 |
|
56 |
st.sidebar.write(format_func=lambda app: app['title'])
|
57 |
image = Image.open('appStore/img/sdsn.png')
|
@@ -77,5 +65,4 @@ class MultiApp:
|
|
77 |
# load document
|
78 |
documents = pre.load_document(temp.name,file_name)
|
79 |
documents_processed = pre.preprocessing(documents)
|
80 |
-
|
81 |
-
st.session_state['pipeline'] = pipeline
|
|
|
1 |
+
|
2 |
+
import scripts.process as pre
|
3 |
+
|
4 |
import streamlit as st
|
5 |
from PIL import Image
|
6 |
import tempfile
|
7 |
import logging
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
logger = logging.getLogger(__name__)
|
9 |
|
10 |
# Initialization
|
|
|
14 |
#Haystack Components
|
15 |
@st.cache(hash_funcs={"builtins.SwigPyObject": lambda _: None},allow_output_mutation=True)
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
class MultiApp:
|
19 |
"""
|
|
|
39 |
|
40 |
def run(self):
|
41 |
if 'file' not in st.session_state:
|
42 |
+
st.session_state['document'] = None
|
43 |
|
44 |
st.sidebar.write(format_func=lambda app: app['title'])
|
45 |
image = Image.open('appStore/img/sdsn.png')
|
|
|
65 |
# load document
|
66 |
documents = pre.load_document(temp.name,file_name)
|
67 |
documents_processed = pre.preprocessing(documents)
|
68 |
+
st.session_state['documents'] = documents_processed
|
|