Spaces:
Sleeping
Sleeping
File size: 1,062 Bytes
2f97d42 27fb993 2f97d42 27fb993 2f97d42 27fb993 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | """FastAPI application for the RedVeil Environment."""
import sys
import os
# Ensure project root is on path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
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
from redveil.models import RedVeilAction, RedVeilObservation
from redveil.server.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()
|