Spaces:
Sleeping
Sleeping
Upload main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# main.py
|
| 2 |
+
|
| 3 |
+
import requests
|
| 4 |
+
from agent import run_agent
|
| 5 |
+
|
| 6 |
+
USERNAME = "sminichiello"
|
| 7 |
+
SPACE_URL = "https://huggingface.co/spaces/sminichiello/my-agent-demo"
|
| 8 |
+
|
| 9 |
+
def get_question():
|
| 10 |
+
response = requests.get("https://gaia-benchmark.com/api/random-question")
|
| 11 |
+
return response.json()
|
| 12 |
+
|
| 13 |
+
def submit_answer(task_id, answer):
|
| 14 |
+
payload = {
|
| 15 |
+
"username": USERNAME,
|
| 16 |
+
"agent_code": SPACE_URL,
|
| 17 |
+
"answers": [
|
| 18 |
+
{
|
| 19 |
+
"task_id": task_id,
|
| 20 |
+
"submitted_answer": answer
|
| 21 |
+
}
|
| 22 |
+
]
|
| 23 |
+
}
|
| 24 |
+
res = requests.post("https://gaia-benchmark.com/api/submit", json=payload)
|
| 25 |
+
return res.json()
|
| 26 |
+
|
| 27 |
+
# 1. Ottieni domanda
|
| 28 |
+
q = get_question()
|
| 29 |
+
print("❓ Domanda:", q["question"])
|
| 30 |
+
|
| 31 |
+
# 2. Rispondi con l'agente
|
| 32 |
+
response = run_agent(q["question"])
|
| 33 |
+
print("🧠 Risposta:", response)
|
| 34 |
+
|
| 35 |
+
# 3. Invia a GAIA
|
| 36 |
+
result = submit_answer(q["task_id"], response)
|
| 37 |
+
print("✅ Risultato GAIA:", result)
|