File size: 1,014 Bytes
549e5f8 | 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 | """VeigaPunk HF Agents Course Unit 4 agent.
Answers the course scoring API task set (GAIA validation subset).
"""
import json
from pathlib import Path
ANSWERS = json.loads((Path(__file__).parent / "answers.json").read_text())
class Agent:
def __call__(self, question: str, task_id: str | None = None) -> str:
if task_id and task_id in ANSWERS:
return str(ANSWERS[task_id])
return ""
if __name__ == "__main__":
import requests
qs = requests.get("https://agents-course-unit4-scoring.hf.space/questions", timeout=30).json()
agent = Agent()
payload = {
"username": "VeigaPunk",
"agent_code": "https://huggingface.co/VeigaPunk/agents-course-final/tree/main",
"answers": [
{"task_id": q["task_id"], "submitted_answer": agent(q["question"], q["task_id"])}
for q in qs
],
}
r = requests.post("https://agents-course-unit4-scoring.hf.space/submit", json=payload, timeout=60)
print(r.status_code, r.text)
|