# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. """ FastAPI application for the Episteme environment. """ import os from fastapi.responses import JSONResponse try: from openenv.core.env_server.http_server import create_app except Exception as e: raise ImportError( "openenv is required. Install dependencies with 'uv sync'" ) from e try: from ..models import EpistemeAction, EpistemeObservation from .episteme_env_environment import EpistemeEnvironment except ImportError: from models import EpistemeAction, EpistemeObservation from server.episteme_env_environment import EpistemeEnvironment app = create_app( EpistemeEnvironment, EpistemeAction, EpistemeObservation, env_name="episteme_env", max_concurrent_envs=int(os.getenv("MAX_CONCURRENT_ENVS", "10")), ) @app.get("/") async def root(): return JSONResponse({"status": "ok", "environment": "episteme"}) def main(host: str = "0.0.0.0", port: int = 8000): import uvicorn uvicorn.run(app, host=host, port=port) if __name__ == "__main__": import argparse parser = argparse.ArgumentParser() parser.add_argument("--port", type=int, default=8000) args = parser.parse_args() main(port=args.port)