| |
| |
| |
| |
| |
|
|
| """ |
| FastAPI application for the AML Investigator Environment. |
| |
| Wraps AmlEnvironment with OpenEnv's create_app utility, exposing the |
| standard OpenEnv HTTP endpoints required by the evaluator: |
| |
| POST /reset β Reset episode, returns initial AmlObservation |
| POST /step β Execute an AmlAction, returns AmlObservation |
| GET /state β Return current internal State object |
| GET /schema β Return action/observation JSON schemas |
| WS /ws β WebSocket endpoint for persistent sessions |
| |
| CORS is configured to allow all origins so the hackathon evaluator |
| can reach the Space without origin restrictions. |
| |
| Usage (local dev): |
| uvicorn server.app:app --reload --host 0.0.0.0 --port 7860 |
| |
| Usage (production / HF Spaces): |
| uvicorn server.app:app --host 0.0.0.0 --port 7860 |
| """ |
|
|
| try: |
| from openenv.core.env_server.http_server import create_app |
| except Exception as e: |
| raise ImportError( |
| "openenv is required. Install with:\n pip install -r server/requirements.txt" |
| ) from e |
|
|
| from fastapi.middleware.cors import CORSMiddleware |
|
|
| try: |
| |
| from ..models import AmlAction, AmlObservation |
| from .AML_env_environment import AmlEnvironment |
| except ImportError: |
| |
| from models import AmlAction, AmlObservation |
| from server.AML_env_environment import AmlEnvironment |
|
|
|
|
| |
| |
| |
| app = create_app( |
| AmlEnvironment, |
| AmlAction, |
| AmlObservation, |
| env_name="AML_env", |
| |
| |
| max_concurrent_envs=10, |
| ) |
|
|
| |
| |
| |
| app.add_middleware( |
| CORSMiddleware, |
| allow_origins=["*"], |
| allow_credentials=True, |
| allow_methods=["*"], |
| allow_headers=["*"], |
| ) |
|
|
|
|
| |
| |
| |
| def main(host: str = "0.0.0.0", port: int = 7860) -> None: |
| """ |
| Run the server directly. |
| |
| Examples: |
| python -m server.app |
| python -m server.app --port 7860 |
| """ |
| import uvicorn |
|
|
| uvicorn.run("server.app:app", host=host, port=port, reload=False) |
|
|
|
|
| if __name__ == "__main__": |
| import argparse |
|
|
| parser = argparse.ArgumentParser(description="AML Investigator OpenEnv server") |
| parser.add_argument("--host", default="0.0.0.0", help="Bind host") |
| parser.add_argument("--port", type=int, default=7860, help="Bind port") |
| args = parser.parse_args() |
| |
| main() |
|
|