Jofthomas commited on
Commit
c638053
·
verified ·
1 Parent(s): d085539

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +22 -22
main.py CHANGED
@@ -53,28 +53,28 @@ def load_dataset():
53
  print("------------------------------------------------------------------")
54
  filtered_dataset=tempo_filtered
55
 
56
- # Prepare data structures for the API
57
- questions_for_api: List[Dict[str, str]] = []
58
- ground_truth_answers: Dict[str, str] = {}
59
-
60
- for item in filtered_data:
61
- task_id = item.get('task_id')
62
- question_text = item.get('Question')
63
- final_answer = item.get('Final answer')
64
-
65
- if task_id and question_text and final_answer is not None:
66
- questions_for_api.append({
67
- "task_id": str(task_id), # Ensure ID is string
68
- "question": question_text
69
- })
70
- ground_truth_answers[str(task_id)] = str(final_answer) # Ensure answer is string
71
- else:
72
- logger.warning(f"Skipping item due to missing fields: {item}")
73
-
74
- logger.info(f"Loaded {len(questions_for_api)} questions for the API.")
75
- if not questions_for_api:
76
- logger.error("No valid questions loaded. API will not function correctly.")
77
- # You might want to exit or raise an error here depending on requirements
78
 
79
  # --- Pydantic Models for Data Validation ---
80
  class Question(BaseModel):
 
53
  print("------------------------------------------------------------------")
54
  filtered_dataset=tempo_filtered
55
 
56
+ # Prepare data structures for the API
57
+ questions_for_api: List[Dict[str, str]] = []
58
+ ground_truth_answers: Dict[str, str] = {}
59
+
60
+ for item in filtered_dataset:
61
+ task_id = item.get('task_id')
62
+ question_text = item.get('Question')
63
+ final_answer = item.get('Final answer')
64
+
65
+ if task_id and question_text and final_answer is not None:
66
+ questions_for_api.append({
67
+ "task_id": str(task_id), # Ensure ID is string
68
+ "question": question_text
69
+ })
70
+ ground_truth_answers[str(task_id)] = str(final_answer) # Ensure answer is string
71
+ else:
72
+ logger.warning(f"Skipping item due to missing fields: {item}")
73
+
74
+ logger.info(f"Loaded {len(questions_for_api)} questions for the API.")
75
+ if not questions_for_api:
76
+ logger.error("No valid questions loaded. API will not function correctly.")
77
+ # You might want to exit or raise an error here depending on requirements
78
 
79
  # --- Pydantic Models for Data Validation ---
80
  class Question(BaseModel):