Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -92,23 +92,21 @@ async def process_analysis_request(request: Request):
|
|
| 92 |
questions_file_name, attached_file_names = None, []
|
| 93 |
first_txt_file_name = None
|
| 94 |
q_pattern = re.compile(r'question', re.IGNORECASE)
|
| 95 |
-
|
| 96 |
for filename in file_contents.keys():
|
| 97 |
is_txt = filename.lower().endswith(".txt")
|
| 98 |
-
if is_txt and first_txt_file_name is None:
|
| 99 |
-
first_txt_file_name = filename
|
| 100 |
if is_txt and q_pattern.search(filename):
|
| 101 |
-
|
| 102 |
-
|
|
|
|
| 103 |
else:
|
| 104 |
attached_file_names.append(filename)
|
| 105 |
|
| 106 |
-
if questions_file_name
|
| 107 |
questions_file_name = first_txt_file_name
|
| 108 |
-
if questions_file_name in attached_file_names:
|
| 109 |
-
attached_file_names.remove(questions_file_name)
|
| 110 |
|
| 111 |
-
if not questions_file_name:
|
|
|
|
| 112 |
|
| 113 |
task_content = file_contents[questions_file_name].decode("utf-8")
|
| 114 |
|
|
|
|
| 92 |
questions_file_name, attached_file_names = None, []
|
| 93 |
first_txt_file_name = None
|
| 94 |
q_pattern = re.compile(r'question', re.IGNORECASE)
|
| 95 |
+
|
| 96 |
for filename in file_contents.keys():
|
| 97 |
is_txt = filename.lower().endswith(".txt")
|
|
|
|
|
|
|
| 98 |
if is_txt and q_pattern.search(filename):
|
| 99 |
+
questions_file_name = filename
|
| 100 |
+
elif is_txt and first_txt_file_name is None:
|
| 101 |
+
first_txt_file_name = filename
|
| 102 |
else:
|
| 103 |
attached_file_names.append(filename)
|
| 104 |
|
| 105 |
+
if not questions_file_name:
|
| 106 |
questions_file_name = first_txt_file_name
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
if not questions_file_name:
|
| 109 |
+
raise HTTPException(status.HTTP_400_BAD_REQUEST, "No .txt question file found.")
|
| 110 |
|
| 111 |
task_content = file_contents[questions_file_name].decode("utf-8")
|
| 112 |
|