File size: 1,205 Bytes
ef737d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
client.py — OpenEnv-Compliant Client for Autonomy Calibration
This client provides a strictly separated interface to the environment,
satisfying the hackathon's architectural requirements.
"""

from openenv.core.env_client import EnvClient
from models import Action, Observation, StepResult

class AutonomyCalibrationClient(EnvClient):
    """
    Client for interacting with the Autonomy Calibration Space.
    Inheriting from OpenEnv's EnvClient ensures standard communication protocols.
    """
    def __init__(self, base_url: str = "http://localhost:7860"):
        super().__init__(base_url=base_url)

    def reset_env(self, task: str = "email_triage", seed: int = None) -> Observation:
        """Resets the remote environment and returns a Pydantic Observation."""
        response = self._post("/api/reset", json={"task": task, "seed": seed})
        return Observation(**response.json())

    def step_env(self, action_type: str) -> StepResult:
        """Takes a step in the remote environment and returns a Pydantic StepResult."""
        action = {"type": action_type, "payload": {}}
        response = self._post("/api/step", json=action)
        return StepResult(**response.json())