Spaces:
Runtime error
Runtime error
Commit
Β·
eb2915c
1
Parent(s):
1f1e9bd
add progress bar
Browse files
app.py
CHANGED
|
@@ -269,7 +269,7 @@ def matched_context(start_i, end_i, contexts_string, seperator='---'):
|
|
| 269 |
return None
|
| 270 |
|
| 271 |
|
| 272 |
-
def run_query(query):
|
| 273 |
# if use_query_exp == 'yes':
|
| 274 |
# query_exp = paraphrase(f"question2question: {query}")
|
| 275 |
# st.markdown(f"""
|
|
@@ -298,7 +298,7 @@ def run_query(query):
|
|
| 298 |
set(contexts_strict)
|
| 299 |
)
|
| 300 |
orig_docs = orig_docs_strict
|
| 301 |
-
|
| 302 |
|
| 303 |
if len(contexts) == 0 or not ''.join(contexts).strip():
|
| 304 |
return st.markdown("""
|
|
@@ -320,6 +320,7 @@ def run_query(query):
|
|
| 320 |
else:
|
| 321 |
contexts = contexts[:context_limit]
|
| 322 |
|
|
|
|
| 323 |
if concat_passages == 'yes':
|
| 324 |
context = '\n---'.join(contexts)
|
| 325 |
model_results = qa_model(question=query, context=context, top_k=10)
|
|
@@ -329,6 +330,7 @@ def run_query(query):
|
|
| 329 |
|
| 330 |
results = []
|
| 331 |
|
|
|
|
| 332 |
for i, result in enumerate(model_results):
|
| 333 |
if concat_passages == 'yes':
|
| 334 |
matched = matched_context(result['start'], result['end'], context)
|
|
@@ -359,6 +361,7 @@ def run_query(query):
|
|
| 359 |
sorted_result
|
| 360 |
))
|
| 361 |
|
|
|
|
| 362 |
for r in sorted_result:
|
| 363 |
ctx = remove_html(r["context"])
|
| 364 |
for answer in r['texts']:
|
|
@@ -371,4 +374,5 @@ def run_query(query):
|
|
| 371 |
query = st.text_input("Ask scientific literature a question", "")
|
| 372 |
if query != "":
|
| 373 |
with st.spinner('Loading...'):
|
| 374 |
-
|
|
|
|
|
|
| 269 |
return None
|
| 270 |
|
| 271 |
|
| 272 |
+
def run_query(query, progress_bar):
|
| 273 |
# if use_query_exp == 'yes':
|
| 274 |
# query_exp = paraphrase(f"question2question: {query}")
|
| 275 |
# st.markdown(f"""
|
|
|
|
| 298 |
set(contexts_strict)
|
| 299 |
)
|
| 300 |
orig_docs = orig_docs_strict
|
| 301 |
+
progress_bar.progress(25)
|
| 302 |
|
| 303 |
if len(contexts) == 0 or not ''.join(contexts).strip():
|
| 304 |
return st.markdown("""
|
|
|
|
| 320 |
else:
|
| 321 |
contexts = contexts[:context_limit]
|
| 322 |
|
| 323 |
+
progress_bar.progress(50)
|
| 324 |
if concat_passages == 'yes':
|
| 325 |
context = '\n---'.join(contexts)
|
| 326 |
model_results = qa_model(question=query, context=context, top_k=10)
|
|
|
|
| 330 |
|
| 331 |
results = []
|
| 332 |
|
| 333 |
+
progress_bar.progress(75)
|
| 334 |
for i, result in enumerate(model_results):
|
| 335 |
if concat_passages == 'yes':
|
| 336 |
matched = matched_context(result['start'], result['end'], context)
|
|
|
|
| 361 |
sorted_result
|
| 362 |
))
|
| 363 |
|
| 364 |
+
progress_bar.progress(100)
|
| 365 |
for r in sorted_result:
|
| 366 |
ctx = remove_html(r["context"])
|
| 367 |
for answer in r['texts']:
|
|
|
|
| 374 |
query = st.text_input("Ask scientific literature a question", "")
|
| 375 |
if query != "":
|
| 376 |
with st.spinner('Loading...'):
|
| 377 |
+
progress_bar = st.progress(0)
|
| 378 |
+
run_query(query, progress_bar)
|