Spaces:
Sleeping
Sleeping
Stefano Fiorucci
commited on
Commit
•
aeb52ef
1
Parent(s):
2340dbd
disk cache managed by streamlit
Browse files- app.py +2 -11
- cache/placeholder.txt +0 -0
- requirements.txt +0 -1
app.py
CHANGED
@@ -16,8 +16,6 @@ from haystack.pipelines import ExtractiveQAPipeline
|
|
16 |
from annotated_text import annotation
|
17 |
import shutil
|
18 |
from urllib.parse import unquote
|
19 |
-
from diskcache import Cache
|
20 |
-
|
21 |
|
22 |
|
23 |
# FAISS index directory
|
@@ -58,12 +56,7 @@ def set_state_if_absent(key, value):
|
|
58 |
st.session_state[key] = value
|
59 |
|
60 |
|
61 |
-
|
62 |
-
cache = Cache('./cache', size_limit=1*2**30)
|
63 |
-
|
64 |
-
# since our index is fixed and the following method is expensive,
|
65 |
-
# we decide to cache it
|
66 |
-
@cache.memoize()
|
67 |
def query(pipe, question, retriever_top_k=10, reader_top_k=5) -> dict:
|
68 |
"""Run query and get answers"""
|
69 |
return (pipe.run(question,
|
@@ -72,9 +65,7 @@ def query(pipe, question, retriever_top_k=10, reader_top_k=5) -> dict:
|
|
72 |
|
73 |
|
74 |
def main():
|
75 |
-
|
76 |
-
cache = Cache('./cache', size_limit=1*2**30)
|
77 |
-
|
78 |
pipe=start_haystack()
|
79 |
questions = load_questions()
|
80 |
|
|
|
16 |
from annotated_text import annotation
|
17 |
import shutil
|
18 |
from urllib.parse import unquote
|
|
|
|
|
19 |
|
20 |
|
21 |
# FAISS index directory
|
|
|
56 |
st.session_state[key] = value
|
57 |
|
58 |
|
59 |
+
@st.cache(persist=True)
|
|
|
|
|
|
|
|
|
|
|
60 |
def query(pipe, question, retriever_top_k=10, reader_top_k=5) -> dict:
|
61 |
"""Run query and get answers"""
|
62 |
return (pipe.run(question,
|
|
|
65 |
|
66 |
|
67 |
def main():
|
68 |
+
|
|
|
|
|
69 |
pipe=start_haystack()
|
70 |
questions = load_questions()
|
71 |
|
cache/placeholder.txt
DELETED
File without changes
|
requirements.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
farm-haystack[faiss]==1.4.0
|
2 |
markdown
|
3 |
st-annotated-text
|
4 |
-
diskcache==5.4.0
|
5 |
# streamlit==1.2.0
|
|
|
1 |
farm-haystack[faiss]==1.4.0
|
2 |
markdown
|
3 |
st-annotated-text
|
|
|
4 |
# streamlit==1.2.0
|