""" Simple web interface for CodeRefactor Gym Space. This provides a basic HTML page to show the environment is running. """ from fastapi import FastAPI from fastapi.responses import HTMLResponse app = FastAPI() @app.get("/", response_class=HTMLResponse) async def root(): """Display environment info page.""" return """
✓ RUNNING
Un environnement OpenEnv qui apprend aux agents RL à refactoriser du code legacy en code moderne et maintenable.
GET /health - Health checkPOST /reset - Reset environmentPOST /step - Execute actionGET /state - Get current stateGET /docs - API documentation (OpenAPI)from openenv.client import Client
from models import CodeRefactorGymAction
# Connecter
client = Client(base_url="https://mo35-code-refactor-gym.hf.space")
# Reset
obs = client.reset()
print(f"Legacy code: {obs.legacy_code}")
# Refactoriser
action = CodeRefactorGymAction(
refactored_code="...",
reasoning="Added type hints and docstrings"
)
result = client.step(action)
print(f"Reward: {result.reward}")
print(f"Improvement: {result.improvement_score}/100")
Créé par mo35 pour l'OpenEnv Hackathon.
Framework: OpenEnv + TRL (GRPO) + Unsloth
GPU: Northflank H100 80GB