my-agent-demo / main.py
sminichiello's picture
Upload main.py
d928c3d verified
raw
history blame contribute delete
956 Bytes
# main.py
import requests
from agent import run_agent
USERNAME = "sminichiello"
SPACE_URL = "https://huggingface.co/spaces/sminichiello/my-agent-demo"
def get_question():
response = requests.get("https://gaia-benchmark.com/api/random-question")
return response.json()
def submit_answer(task_id, answer):
payload = {
"username": USERNAME,
"agent_code": SPACE_URL,
"answers": [
{
"task_id": task_id,
"submitted_answer": answer
}
]
}
res = requests.post("https://gaia-benchmark.com/api/submit", json=payload)
return res.json()
# 1. Ottieni domanda
q = get_question()
print("❓ Domanda:", q["question"])
# 2. Rispondi con l'agente
response = run_agent(q["question"])
print("🧠 Risposta:", response)
# 3. Invia a GAIA
result = submit_answer(q["task_id"], response)
print("βœ… Risultato GAIA:", result)