Spaces:
Configuration error
Configuration error
Download client.py from Samad14/hackathon_repo_1: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/Samad14/hackathon_repo_1/resolve/a43cbb44a31e42b0dc9ff7fa6bce5711ceea8094/client.py
- Command line
-
hf download hf://spaces/Samad14/hackathon_repo_1@a43cbb44a31e42b0dc9ff7fa6bce5711ceea8094/client.py
-
curl -L -o client.py https://huggingface.co/spaces/Samad14/hackathon_repo_1/resolve/a43cbb44a31e42b0dc9ff7fa6bce5711ceea8094/client.py
1.08 kB
| from __future__ import annotations | |
| from typing import Any, Dict | |
| from openenv.core.client_types import StepResult | |
| from openenv.core.env_client import EnvClient | |
| from server.models import OfficeAction, OfficeObservation, OfficeState | |
| class OfficeEnvClient(EnvClient[OfficeAction, OfficeObservation, OfficeState]): | |
| def _step_payload(self, action: OfficeAction) -> Dict[str, Any]: | |
| # The env server deserializes via Pydantic, so we send only provided fields. | |
| return action.model_dump(exclude_none=True) | |
| def _parse_result(self, payload: Dict[str, Any]) -> StepResult[OfficeObservation]: | |
| obs_data = payload.get("observation", {}) or {} | |
| reward = payload.get("reward", None) | |
| done = bool(payload.get("done", False)) | |
| observation = OfficeObservation( | |
| **obs_data, | |
| done=done, | |
| reward=reward, | |
| ) | |
| return StepResult(observation=observation, reward=reward, done=done) | |
| def _parse_state(self, payload: Dict[str, Any]) -> OfficeState: | |
| return OfficeState.model_validate(payload) | |