Spaces:
Runtime error
Runtime error
Added progress bar
Browse files
app.py
CHANGED
@@ -58,7 +58,7 @@ def validate_questions(questions: str) -> None:
|
|
58 |
if len(questions) > MAX_QUESTIONS_COUNT:
|
59 |
raise gr.Error(f'Validation error. The maximum allowed number of questions is {MAX_QUESTIONS_COUNT}.')
|
60 |
|
61 |
-
def find_answers(tags: str, questions: str) -> str:
|
62 |
tags = tags.split('\n')
|
63 |
questions = questions.split('\n')
|
64 |
|
@@ -68,7 +68,7 @@ def find_answers(tags: str, questions: str) -> str:
|
|
68 |
tags_str = ''.join([f'[{tag}]' for tag in tags])
|
69 |
|
70 |
results = []
|
71 |
-
for question in questions:
|
72 |
tagged_question = f'{tags_str} {question}'
|
73 |
for attempt in range(MAX_ATTEMPS):
|
74 |
answer = get_answer(tagged_question)
|
@@ -100,4 +100,4 @@ with gr.Blocks(theme='soft', title='AnswerMate') as blocks:
|
|
100 |
outputs = gr.Textbox(label='Output', placeholder='Output will appear here')
|
101 |
process_button.click(fn=find_answers, inputs=[tags_input, questions_input], outputs=outputs)
|
102 |
|
103 |
-
blocks.launch()
|
|
|
58 |
if len(questions) > MAX_QUESTIONS_COUNT:
|
59 |
raise gr.Error(f'Validation error. The maximum allowed number of questions is {MAX_QUESTIONS_COUNT}.')
|
60 |
|
61 |
+
def find_answers(tags: str, questions: str, progress=gr.Progress()) -> str:
|
62 |
tags = tags.split('\n')
|
63 |
questions = questions.split('\n')
|
64 |
|
|
|
68 |
tags_str = ''.join([f'[{tag}]' for tag in tags])
|
69 |
|
70 |
results = []
|
71 |
+
for question in progress.tqdm(questions):
|
72 |
tagged_question = f'{tags_str} {question}'
|
73 |
for attempt in range(MAX_ATTEMPS):
|
74 |
answer = get_answer(tagged_question)
|
|
|
100 |
outputs = gr.Textbox(label='Output', placeholder='Output will appear here')
|
101 |
process_button.click(fn=find_answers, inputs=[tags_input, questions_input], outputs=outputs)
|
102 |
|
103 |
+
blocks.queue(concurrency_count=1).launch()
|