| from tools import fetch_questions, fetch_file | |
| import json | |
| # (Keep Constants as is) | |
| # --- Constants --- | |
| DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space" | |
| def main(): | |
| """ | |
| Main function to run the script. | |
| """ | |
| questions = fetch_questions(DEFAULT_API_URL) | |
| if questions: | |
| print("Fetched Questions:") | |
| print(json.dumps(questions, indent=2)) | |
| else: | |
| print("Failed to fetch questions.") | |
| # Check for 'file_name' in each question | |
| for idx, item in enumerate(questions): | |
| # Check if 'file_name' exists in the question item | |
| filename = item.get("file_name") | |
| if filename: | |
| task_id = item.get("task_id") | |
| print(f"Question {idx} contains file_name: {filename}") | |
| # Download the file if not already present | |
| fetch_file(DEFAULT_API_URL, task_id, filename) | |
| else: | |
| print(f"Question {idx} does not contain a file_name.") | |
| main() |