Spaces:
Sleeping
Sleeping
File size: 956 Bytes
b52d174 |
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 |
import requests
# CONFIGURA TUS DATOS AQUÍ
API_URL = "https://<API_DE_EVALUACION>/questions"
SUBMIT_URL = "https://<API_DE_EVALUACION>/submit"
SPACE_URL = "https://huggingface.co/spaces/<TU_USUARIO>/<NOMBRE_DEL_SPACE>/tree/main"
USERNAME = "<TU_USUARIO>"
# Obtener las preguntas
response = requests.get(API_URL)
questions = response.json()
answers = []
for q in questions:
task_id = q["task_id"]
task_data = q["question"]
# Llamada al agente
agent_response = requests.post(
"<URL_DEL_SPACE>/predict",
json={"task_id": task_id, "task_data": task_data}
)
submitted_answer = agent_response.json()["submitted_answer"]
answers.append({"task_id": task_id, "submitted_answer": submitted_answer})
# Enviar respuestas
payload = {
"username": USERNAME,
"agent_code": SPACE_URL,
"answers": answers
}
submit_response = requests.post(SUBMIT_URL, json=payload)
print(submit_response.json())
|