Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -81,20 +81,23 @@ def load_questions():
|
|
81 |
task_id = item.get('task_id')
|
82 |
question_text = item.get('Question')
|
83 |
final_answer = item.get('Final answer')
|
84 |
-
|
|
|
85 |
if task_id and question_text and final_answer is not None:
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
91 |
processed_count += 1
|
92 |
else:
|
93 |
logger.warning(f"Skipping item due to missing fields (task_id, Question, or Final answer): {item}")
|
94 |
|
95 |
-
logger.info(f"Successfully processed and loaded {processed_count} questions for the API.")
|
96 |
-
# print(questions_for_api) # Keep this commented unless debugging
|
97 |
-
|
98 |
if not questions_for_api:
|
99 |
logger.error("CRITICAL: No valid questions loaded after filtering. API endpoints needing questions will fail.")
|
100 |
# Depending on requirements, you might want to exit or raise an error here
|
|
|
81 |
task_id = item.get('task_id')
|
82 |
question_text = item.get('Question')
|
83 |
final_answer = item.get('Final answer')
|
84 |
+
|
85 |
+
# Validate required fields
|
86 |
if task_id and question_text and final_answer is not None:
|
87 |
+
# Create a copy of the item and remove fields we don't want
|
88 |
+
processed_item = item.copy()
|
89 |
+
processed_item.pop('Final answer', None) # Remove Final answer
|
90 |
+
processed_item.pop('Annotator Annotation', None) # Remove Annotator Annotation
|
91 |
+
|
92 |
+
# Store in questions_for_api
|
93 |
+
questions_for_api.append(processed_item)
|
94 |
+
|
95 |
+
# Still store the ground truth answers separately
|
96 |
+
ground_truth_answers[str(task_id)] = str(final_answer)
|
97 |
processed_count += 1
|
98 |
else:
|
99 |
logger.warning(f"Skipping item due to missing fields (task_id, Question, or Final answer): {item}")
|
100 |
|
|
|
|
|
|
|
101 |
if not questions_for_api:
|
102 |
logger.error("CRITICAL: No valid questions loaded after filtering. API endpoints needing questions will fail.")
|
103 |
# Depending on requirements, you might want to exit or raise an error here
|