File size: 878 Bytes
58b2d80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)