Spaces:
Sleeping
Sleeping
File size: 1,263 Bytes
21c24ae | 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 | """
PERMANENCE — OpenEnv-compatible client.
Uses ``openenv.core.SyncEnvClient`` for typed, WebSocket-based
communication with a running PERMANENCE server.
Usage:
from client import PermanenceEnvClient
from models import PermanenceAction
client = PermanenceEnvClient("http://localhost:7860")
obs = client.reset()
obs = client.step(PermanenceAction(text="<action id='draft_internal_memo'/>..."))
print(obs.text, obs.reward, obs.done)
"""
from __future__ import annotations
import os
from typing import Optional
from openenv.core import SyncEnvClient
from models import PermanenceAction, PermanenceObservation, PermanenceState
DEFAULT_ENV_URL = os.getenv(
"PERMANENCE_ENV_URL",
"https://chane35-permanence.hf.space",
)
class PermanenceEnvClient(SyncEnvClient[PermanenceAction, PermanenceObservation, PermanenceState]):
"""
Typed OpenEnv client for the PERMANENCE environment.
Connects to a running PERMANENCE server and provides typed
``reset()``, ``step()``, and ``state`` access.
"""
action_type = PermanenceAction
observation_type = PermanenceObservation
state_type = PermanenceState
def __init__(self, base_url: str = DEFAULT_ENV_URL):
super().__init__(base_url=base_url)
|