File size: 1,304 Bytes
1138ff6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Action and observation models for Five Desks."""

from typing import Any, Literal

from openenv.core.env_server.types import Action, Observation
from pydantic import ConfigDict, Field


class DeskAction(Action):
    # Unknown keys are ignored instead of failing the whole episode.
    model_config = ConfigDict(extra="ignore", validate_assignment=True)

    tool: Literal["list", "read", "calc", "submit"] = Field(
        description=(
            "list: show the workspace files. read: show one file (needs path). "
            "calc: evaluate one arithmetic expression (needs expr). "
            "submit: send the final answer (needs answer); this ends the episode."
        )
    )
    path: str = Field(default="", max_length=200, description="File name for read.")
    expr: str = Field(
        default="",
        max_length=1000,
        description="Arithmetic expression for calc, e.g. 1250*(1+0.04/12)**36.",
    )
    answer: dict[str, Any] = Field(
        default_factory=dict,
        description="For submit: an object with exactly the answer keys the task asks for.",
    )


class DeskObservation(Observation):
    output: str = Field(default="", description="Result of the last action.")
    steps_left: int = Field(default=0, description="Actions left before the episode ends.")