Spaces:
Running
Running
File size: 851 Bytes
eec444f | 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 31 32 33 34 35 36 37 38 39 40 41 42 43 | import requests
from agent import BasicAgent
API_URL = "https://agents-course-unit4-scoring.hf.space"
USERNAME = "egor-fedosov"
AGENT_CODE = "https://huggingface.co/spaces/egor-fedosov/finalagent/tree/main"
agent = BasicAgent()
questions = requests.get(f"{API_URL}/questions", timeout=30).json()
answers = []
for item in questions:
task_id = item["task_id"]
question = item["question"]
try:
answer = agent(question)
except Exception as e:
answer = f"ERROR: {e}"
print(task_id, answer)
answers.append({
"task_id": task_id,
"submitted_answer": answer
})
payload = {
"username": USERNAME,
"agent_code": AGENT_CODE,
"answers": answers
}
response = requests.post(
f"{API_URL}/submit",
json=payload,
timeout=120
)
print(response.status_code)
print(response.text) |