Spaces:
Sleeping
Sleeping
| from environments import register_env | |
| import gradio as gr | |
| class CountToTen: | |
| def __init__(self): | |
| self.counter = None | |
| def reset(self) -> tuple[dict, float, bool]: | |
| self.counter = 0 | |
| return f"Counter reset to {self.counter}", 0.0, False | |
| def step(self) -> tuple[dict, float, bool]: | |
| if self.counter is None or self.counter >= 10: | |
| return "Try resetting first", 0.0, False | |
| self.counter += 1 | |
| return f"Counter is now {self.counter}", 1.0, self.counter >= 10 | |
| with gr.Blocks() as demo: | |
| gr.Markdown( | |
| """# Count to Ten Environment | |
| Usage: | |
| ```shell | |
| pip install git+https://github.com/huggingface/environments.git | |
| ``` | |
| ```python | |
| from environments import load | |
| env = load("qgallouedec/counter") | |
| Loaded as API: https://qgallouedec-counter.hf.space/ ✔ | |
| env.reset() | |
| ('Counter reset to 0', 0.0, False) | |
| env.step() | |
| ('Counter is now 1', 1.0, False) | |
| ``` | |
| """ | |
| ) | |
| register_env(CountToTen) | |
| demo.launch(mcp_server=True) | |