File size: 1,492 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | """
models.py β OpenEnv Pydantic contracts v2.0
Autonomy Calibration Environment
"""
from __future__ import annotations
from typing import Any, Optional
from pydantic import BaseModel, Field
class Action(BaseModel):
type: str = Field(..., description="Action type from available_actions")
payload: dict[str, Any] = Field(default_factory=dict)
class Observation(BaseModel):
task_id: str
step: int
state: dict[str, Any]
history: list[dict[str, Any]] = Field(default_factory=list)
available_actions: list[str]
done: bool = False
prompt: str = ""
seed: Optional[int] = Field(default=None, description="Episode seed for reproducibility")
# βββ Legacy Fields (Backward Compatibility for UI) βββββββββββββββββββ
context: str = ""
task: str = ""
action_to_evaluate: str = ""
class Reward(BaseModel):
# OpenEnv v2 requirement: scores strictly in (0.01, 0.99)
value: float = Field(..., ge=0.01, le=0.99)
breakdown: dict[str, Any] = Field(default_factory=dict)
raw: float = 0.0
class StepResult(BaseModel):
observation: Observation
reward: Reward
done: bool
info: dict[str, Any] = Field(default_factory=dict)
class ResetRequest(BaseModel):
task: str = Field(default="email_triage")
seed: Optional[int] = Field(
default=None,
description="Integer seed for reproducibility. Same seed β same episode. None = auto-increment."
)
|