Spaces:
Runtime error
Runtime error
minor
Browse files
app.py
CHANGED
|
@@ -177,6 +177,11 @@ def start_haystack():
|
|
| 177 |
|
| 178 |
return pipe
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
@st.cache_resource
|
| 181 |
def check_statement(pipe, statement: str, retriever_top_k: int = 5):
|
| 182 |
"""Run query and verify statement"""
|
|
@@ -243,8 +248,6 @@ def main():
|
|
| 243 |
run_pressed or statement != st.session_state.statement
|
| 244 |
)
|
| 245 |
|
| 246 |
-
pipe = start_haystack()
|
| 247 |
-
|
| 248 |
# Get results for query
|
| 249 |
if run_query and statement:
|
| 250 |
time_start = time.time()
|
|
@@ -252,7 +255,7 @@ def main():
|
|
| 252 |
st.session_state.statement = statement
|
| 253 |
with st.spinner(" Procurando a Similaridade no banco de sentenças..."):
|
| 254 |
try:
|
| 255 |
-
st.session_state.results =
|
| 256 |
print(f"S: {statement}")
|
| 257 |
time_end = time.time()
|
| 258 |
print(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()))
|
|
|
|
| 177 |
|
| 178 |
return pipe
|
| 179 |
|
| 180 |
+
def run_statement(statement: str, retriever_top_k: int = 5):
|
| 181 |
+
pipe = start_haystack()
|
| 182 |
+
run = check_statement(statement, retriever_top_k)
|
| 183 |
+
return run
|
| 184 |
+
|
| 185 |
@st.cache_resource
|
| 186 |
def check_statement(pipe, statement: str, retriever_top_k: int = 5):
|
| 187 |
"""Run query and verify statement"""
|
|
|
|
| 248 |
run_pressed or statement != st.session_state.statement
|
| 249 |
)
|
| 250 |
|
|
|
|
|
|
|
| 251 |
# Get results for query
|
| 252 |
if run_query and statement:
|
| 253 |
time_start = time.time()
|
|
|
|
| 255 |
st.session_state.statement = statement
|
| 256 |
with st.spinner(" Procurando a Similaridade no banco de sentenças..."):
|
| 257 |
try:
|
| 258 |
+
st.session_state.results = run_statement(statement, RETRIEVER_TOP_K)
|
| 259 |
print(f"S: {statement}")
|
| 260 |
time_end = time.time()
|
| 261 |
print(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()))
|