Spaces:
Runtime error
Runtime error
Bug fix
Browse files
app.py
CHANGED
@@ -48,16 +48,16 @@ def format_results(results: List[Tuple[str, str]]) -> str:
|
|
48 |
output = output.strip()
|
49 |
return output
|
50 |
|
51 |
-
def
|
52 |
-
if
|
53 |
raise gr.Error('Validation error. It is necessary to set at least one tag')
|
54 |
|
55 |
tags = tags.split('\n')
|
56 |
if len(tags) > max_tags_count:
|
57 |
raise gr.Error(f'Validation error. The maximum allowed number of tags is {max_tags_count}.')
|
58 |
|
59 |
-
def
|
60 |
-
if
|
61 |
raise gr.Error('Validation error. It is necessary to ask at least one question')
|
62 |
|
63 |
questions = questions.split('\n')
|
@@ -67,8 +67,8 @@ def validate_questions(questions: str) -> None:
|
|
67 |
return questions
|
68 |
|
69 |
def find_answers(tags: str, questions: str, progress=gr.Progress()) -> str:
|
70 |
-
|
71 |
-
|
72 |
|
73 |
print(f'New attempt to get answers. Got {len(tags)} tags and {len(questions)} questions')
|
74 |
print(f'Tags: {tags}')
|
|
|
48 |
output = output.strip()
|
49 |
return output
|
50 |
|
51 |
+
def validate_and_get_tags(tags: str) -> List[str]:
|
52 |
+
if not tags.strip():
|
53 |
raise gr.Error('Validation error. It is necessary to set at least one tag')
|
54 |
|
55 |
tags = tags.split('\n')
|
56 |
if len(tags) > max_tags_count:
|
57 |
raise gr.Error(f'Validation error. The maximum allowed number of tags is {max_tags_count}.')
|
58 |
|
59 |
+
def validate_and_get_questions(questions: str) -> List[str]:
|
60 |
+
if not questions.strip():
|
61 |
raise gr.Error('Validation error. It is necessary to ask at least one question')
|
62 |
|
63 |
questions = questions.split('\n')
|
|
|
67 |
return questions
|
68 |
|
69 |
def find_answers(tags: str, questions: str, progress=gr.Progress()) -> str:
|
70 |
+
tags = validate_and_get_tags(tags)
|
71 |
+
questions = validate_and_get_questions(questions)
|
72 |
|
73 |
print(f'New attempt to get answers. Got {len(tags)} tags and {len(questions)} questions')
|
74 |
print(f'Tags: {tags}')
|