import os | |
import requests | |
from dotenv import load_dotenv | |
load_dotenv() | |
USERNAME = os.getenv("USERNAME") | |
AGENT_CODE_URL = os.getenv("AGENT_CODE_URL") | |
BASE_URL = os.getenv("BASE_URL") | |
def get_random_question(): | |
response = requests.get(f"{BASE_URL}/random-question") | |
return response.json() | |
def submit_answer(task_id, agent_answer): | |
payload = { | |
"username": USERNAME, | |
"agent_code": AGENT_CODE_URL, | |
"answers": [{"task_id": task_id, "submitted_answer": agent_answer}] | |
} | |
response = requests.post(f"{BASE_URL}/submit", json=payload) | |
return response.json() | |
# Example usage | |
question = get_random_question() | |
print(question) | |
# Replace the following line with your agent's actual answer generation | |
agent_answer = "your_agent_generated_answer" | |
submission_result = submit_answer(question["task_id"], agent_answer) | |
print(submission_result) | |