Download source/workbench/call_env.py from ajinkyamulay/analyst-workbench: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/datasets/ajinkyamulay/analyst-workbench/resolve/main/source/workbench/call_env.py
- Command line
-
hf download hf://datasets/ajinkyamulay/analyst-workbench/source/workbench/call_env.py
-
curl -L -o call_env.py https://huggingface.co/datasets/ajinkyamulay/analyst-workbench/resolve/main/source/workbench/call_env.py
1.7 kB
| """v8 environment: v7's tasks behind a tool surface drawn per episode (see surface.py).""" | |
| from .environment import WorkbenchEnvironment | |
| from .models import CallAction, WorkbenchAction, WorkbenchObservation | |
| from .surface import CallError, Surface | |
| class CallEnvironment(WorkbenchEnvironment): | |
| def reset(self, seed=None, episode_id=None, task_id=None, **kwargs): | |
| super().reset(seed=seed, episode_id=episode_id, task_id=task_id, **kwargs) | |
| if self._task.meta.get("grades_workspace"): | |
| self.close() | |
| raise ValueError(f"{task_id} edits files and is not offered with the v8 tool surface.") | |
| self._surface = Surface(self._seed) | |
| self._last = WorkbenchObservation( | |
| output=f"{self._task.instruction}\n\nFiles:\n{self._listing()}\n\n{self._surface.help()}\n" | |
| f"You have {self._last.remaining_steps} calls.", | |
| reward=0.0, | |
| remaining_steps=self._last.remaining_steps, | |
| ) | |
| return self._last | |
| def step(self, action: CallAction, timeout_s=None, **kwargs): | |
| if self._task is None or self._done: | |
| return super().step(action, timeout_s=timeout_s, **kwargs) | |
| try: | |
| op, call = self._surface.translate(action.tool, action.args) | |
| except CallError as exc: | |
| self._state.step_count += 1 | |
| self._done = True | |
| self._last = WorkbenchObservation( | |
| output=f"Error: {exc} That call does not fit the tools. Episode over. Score: 0.00", | |
| reward=0.0, done=True, remaining_steps=0) | |
| return self._last | |
| return super().step(WorkbenchAction(tool=op, **call), timeout_s=timeout_s, **kwargs) | |