trl-internal-testing/openreward-echo-env
0
1---2title: OpenReward Echo Env (TRL test fixture)3emoji: ๐ฆ4colorFrom: blue5colorTo: purple6sdk: docker7app_port: 78608pinned: false9license: apache-2.010---11 12# OpenReward Echo Env13 14Minimal [Open Reward Standard](https://openrewardstandard.io) environment used as the test fixture for [`trl.experimental.openreward`](https://github.com/huggingface/trl/tree/main/trl/experimental/openreward).15 16The model is given a target string and must call `echo(text=...)` with exactly that string. Reward is `1.0` on match, `0.0` otherwise; the episode finishes on a correct echo.17 18Pure Python โ no sandbox, no external state โ so responses are deterministic and the env can run thousands of concurrent sessions on free-tier hardware.19 20## Use21 22```python23import os24os.environ["OPENREWARD_API_URL"] = "https://trl-internal-testing-openreward-echo-env.hf.space"25os.environ["OPENREWARD_SESSION_URL"] = "https://trl-internal-testing-openreward-echo-env.hf.space"26 27from trl.experimental.openreward import OpenRewardSpec28 29spec = OpenRewardSpec(30 "https://trl-internal-testing-openreward-echo-env.hf.space",31 env_name="echoenvironment",32)33print(spec.train_dataset) # 8 rows: target โ {"hello", "world", "trl", ...}34```35 36The two `OPENREWARD_*_URL` overrides are needed because the `openreward` SDK by default expects a two-subdomain platform layout (`api.<host>` + `sessions.<host>`); for a single-host self-hosted server both have to point at the same URL.37 38## Tasks39 40| split | count | shape |41|---|---|---|42| `train` | 8 | `{"id": "echo-N", "target": "<word>"}` |43 44## Local development45 46```bash47pip install -r requirements.txt48python server.py # listens on PORT (default 8080)49```50 51## Files52 53- `server.py` โ env definition + `Server([EchoEnvironment]).run()`54- `Dockerfile` โ `python:3.11-slim` + the deps; HF Spaces serves it on port 786055- `requirements.txt` โ `openreward`, `fastapi`, `uvicorn`56 