Skip to content

Commit 136c647

Browse files
Make blocking calls non-blocking from UI #44
1 parent 88973fc commit 136c647

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ui/app.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import concurrent.futures
12
import gc
23
import json
34
import os
@@ -364,14 +365,14 @@ async def chatbot(q: Q):
364365
)
365366
else:
366367
q.client.query = question
367-
llm_response, alt_response, err = ask(
368-
question=q.client.query,
369-
sample_queries_path=q.user.sample_qna_path,
370-
table_info_path=q.user.table_info_path,
371-
table_name=q.user.table_name,
372-
model_name=q.user.model_choice_dropdown,
373-
debug_mode=q.args.debug_mode
374-
)
368+
with concurrent.futures.ThreadPoolExecutor() as pool:
369+
llm_response, alt_response, err = await q.exec(pool, ask, question=q.client.query,
370+
sample_queries_path=q.user.sample_qna_path,
371+
table_info_path=q.user.table_info_path,
372+
table_name=q.user.table_name,
373+
model_name=q.user.model_choice_dropdown,
374+
debug_mode=q.args.debug_mode
375+
)
375376
llm_response = "\n".join(llm_response)
376377
except (MemoryError, RuntimeError) as e:
377378
logging.error(f"Something went wrong while generating response: {e}")

0 commit comments

Comments
 (0)