Spaces:
Sleeping
Sleeping
Create api.py
Browse files
api.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
API_BASE = "https://gaia-benchmark.vercel.app"
|
| 4 |
+
|
| 5 |
+
def get_all_questions():
|
| 6 |
+
return requests.get(f"{API_BASE}/questions").json()
|
| 7 |
+
|
| 8 |
+
def get_random_question():
|
| 9 |
+
return requests.get(f"{API_BASE}/random-question").json()
|
| 10 |
+
|
| 11 |
+
def get_file(task_id, filename):
|
| 12 |
+
url = f"{API_BASE}/files/{task_id}/{filename}"
|
| 13 |
+
r = requests.get(url)
|
| 14 |
+
r.raise_for_status()
|
| 15 |
+
return r.content
|
| 16 |
+
|
| 17 |
+
def submit_answers(username, code_link, answers):
|
| 18 |
+
payload = {
|
| 19 |
+
"username": username,
|
| 20 |
+
"agent_code": code_link,
|
| 21 |
+
"answers": answers
|
| 22 |
+
}
|
| 23 |
+
r = requests.post(f"{API_BASE}/submit", json=payload)
|
| 24 |
+
return r.json()
|