Spaces:
Sleeping
Sleeping
| """FastAPI application for the RedVeil Environment.""" | |
| try: | |
| from openenv.core.env_server.http_server import create_app | |
| except Exception as e: | |
| raise ImportError( | |
| "openenv is required. Install with: pip install openenv-core[core]" | |
| ) from e | |
| try: | |
| from redveil.models import RedVeilAction, RedVeilObservation | |
| from redveil.server.redveil_environment import RedVeilEnvironment | |
| except (ModuleNotFoundError, ImportError): | |
| from ..models import RedVeilAction, RedVeilObservation | |
| from .redveil_environment import RedVeilEnvironment | |
| # Singleton: OpenEnv calls the factory on every request, so we return | |
| # the same instance to preserve state across reset() -> step() calls. | |
| _singleton_env = RedVeilEnvironment() | |
| def _env_factory() -> RedVeilEnvironment: | |
| return _singleton_env | |
| app = create_app( | |
| _env_factory, | |
| RedVeilAction, | |
| RedVeilObservation, | |
| env_name="redveil", | |
| max_concurrent_envs=4, | |
| ) | |
| def main(host: str = "0.0.0.0", port: int = 8000): | |
| import uvicorn | |
| uvicorn.run(app, host=host, port=port) | |
| if __name__ == "__main__": | |
| main() | |