Spaces:
Sleeping
Sleeping
Update main.py
Browse files52 unmodified lines5354555657585960616263646566676869707172737475767778798052 unmodified linesprint("------------------------------------------------------------------")filtered_dataset=tempo_filtered# Prepare data structures for the APIquestions_for_api: List[Dict[str, str]] = []ground_truth_answers: Dict[str, str] = {}for item in filtered_data:task_id = item.get('task_id')question_text = item.get('Question')final_answer = item.get('Final answer')if task_id and question_text and final_answer is not None:questions_for_api.append({"task_id": str(task_id), # Ensure ID is string"question": question_text})ground_truth_answers[str(task_id)] = str(final_answer) # Ensure answer is stringelse:logger.warning(f"Skipping item due to missing fields: {item}")logger.info(f"Loaded {len(questions_for_api)} questions for the API.")if not questions_for_api:logger.error("No valid questions loaded. API will not function correctly.")# You might want to exit or raise an error here depending on requirements# --- Pydantic Models for Data Validation ---class Question(BaseModel):52 unmodified lines5354555657585960616263646566676869707172737475767778798052 unmodified linesprint("------------------------------------------------------------------")filtered_dataset=tempo_filtered# Prepare data structures for the APIquestions_for_api: List[Dict[str, str]] = []ground_truth_answers: Dict[str, str] = {}for item in filtered_dataset:task_id = item.get('task_id')question_text = item.get('Question')final_answer = item.get('Final answer')if task_id and question_text and final_answer is not None:questions_for_api.append({"task_id": str(task_id), # Ensure ID is string"question": question_text})ground_truth_answers[str(task_id)] = str(final_answer) # Ensure answer is stringelse:logger.warning(f"Skipping item due to missing fields: {item}")logger.info(f"Loaded {len(questions_for_api)} questions for the API.")if not questions_for_api:logger.error("No valid questions loaded. API will not function correctly.")# You might want to exit or raise an error here depending on requirements# --- Pydantic Models for Data Validation ---class Question(BaseModel):
main.py+22-22