File size: 967 Bytes
a709497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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()