Spaces:
No application file
No application file
Download client.py from Pankaj10346/Openenv-Hackathon: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/spaces/Pankaj10346/Openenv-Hackathon/resolve/main/client.py
- Command line
-
hf download hf://spaces/Pankaj10346/Openenv-Hackathon/client.py
-
curl -L -o client.py https://huggingface.co/spaces/Pankaj10346/Openenv-Hackathon/resolve/main/client.py
1.49 kB
| """ | |
| WebSocket client for legal_contract_env (simulation mode). | |
| """ | |
| from __future__ import annotations | |
| from typing import Any, Dict | |
| from openenv.core.client_types import StepResult | |
| from openenv.core.env_client import EnvClient | |
| from .models import ContractAction, ContractObservation, ContractState | |
| class LegalContractEnv(EnvClient[ContractAction, ContractObservation, ContractState]): | |
| def _step_payload(self, action: ContractAction) -> dict: | |
| return action.model_dump(mode="json", exclude_none=True) | |
| def _parse_result(self, payload: Dict[str, Any]) -> StepResult[ContractObservation]: | |
| obs = ContractObservation(**payload["observation"]) | |
| return StepResult( | |
| observation=obs, | |
| reward=payload.get("reward"), | |
| done=bool(payload.get("done", False)), | |
| ) | |
| def _parse_state(self, payload: Dict[str, Any]) -> ContractState: | |
| return ContractState( | |
| episode_id=payload.get("episode_id"), | |
| step_count=payload.get("step_count", 0), | |
| current_task=payload.get("current_task", "classify"), | |
| current_clause_index=payload.get("current_clause_index", 0), | |
| completed_actions=payload.get("completed_actions", []), | |
| remaining_clauses=payload.get("remaining_clauses", 0), | |
| episode_reward=payload.get("episode_reward", 0.0), | |
| last_grader_score=payload.get("last_grader_score"), | |
| last_info=payload.get("last_info", {}), | |
| ) | |