Download client.py from sai1906/opsguard: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/spaces/sai1906/opsguard/resolve/main/client.py
- Command line
-
hf download hf://spaces/sai1906/opsguard/client.py
-
curl -L -o client.py https://huggingface.co/spaces/sai1906/opsguard/resolve/main/client.py
1.78 kB
| from typing import Dict | |
| from openenv.core import EnvClient | |
| from openenv.core.client_types import StepResult | |
| from openenv.core.env_server.types import State | |
| try: | |
| from .models import IssueView, OpsguardAction, OpsguardObservation | |
| except (ImportError, ValueError): | |
| from models import IssueView, OpsguardAction, OpsguardObservation | |
| class OpsguardEnv(EnvClient[OpsguardAction, OpsguardObservation, State]): | |
| def _step_payload(self, action: OpsguardAction) -> Dict: | |
| return action.model_dump(mode="json") | |
| def _parse_result(self, payload: Dict) -> StepResult[OpsguardObservation]: | |
| obs_data = payload.get("observation", {}) | |
| ci = obs_data.get("current_issue") | |
| current_issue = IssueView(**ci) if ci else None | |
| observation = OpsguardObservation( | |
| scenario_id=obs_data.get("scenario_id", ""), | |
| step=obs_data.get("step", 0), | |
| step_budget=obs_data.get("step_budget", 0), | |
| queue_position=obs_data.get("queue_position", 0), | |
| queue_total=obs_data.get("queue_total", 0), | |
| current_issue=current_issue, | |
| memory_hits=obs_data.get("memory_hits", []), | |
| recent_actions=obs_data.get("recent_actions", []), | |
| feedback=obs_data.get("feedback", ""), | |
| done=payload.get("done", False), | |
| reward=payload.get("reward"), | |
| metadata=obs_data.get("metadata", {}), | |
| ) | |
| return StepResult( | |
| observation=observation, | |
| reward=payload.get("reward"), | |
| done=payload.get("done", False), | |
| ) | |
| def _parse_state(self, payload: Dict) -> State: | |
| return State( | |
| episode_id=payload.get("episode_id"), | |
| step_count=payload.get("step_count", 0), | |
| ) | |