File size: 831 Bytes
6ac8934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import requests
import pandas as pd

API_URL = "https://agents-course-unit4-scoring.hf.space/questions"

def fetch_and_print_questions():
    try:
        response = requests.get(API_URL, timeout=10)
        response.raise_for_status()
        questions = response.json()

        print(f" Retrieved {len(questions)} questions:\n")
        for q in questions:
            task_id = q.get("task_id")
            text = q.get("question")
            print(f"[{task_id}] {text}")

        # Save to CSV
        df = pd.DataFrame(questions)
        df.to_csv("gaia_questions.csv", index=False)
        print("\n Questions saved to gaia_questions.csv")

    except Exception as e:
        print(f" Failed to fetch questions: {e}")

# Run this once manually (outside of Gradio)
if __name__ == "__main__":
    fetch_and_print_questions()