|
5 | 5 | # LICENSE file in the root directory of this source tree. |
6 | 6 |
|
7 | 7 | """ |
8 | | -FastAPI application for the WebSearch Env Environment. |
| 8 | +FastAPI application for the Websearch Env Environment. |
9 | 9 |
|
10 | 10 | This module creates an HTTP server that exposes the WebSearchEnvironment |
11 | 11 | over HTTP endpoints, making it compatible with HTTPEnvClient. |
|
22 | 22 | """ |
23 | 23 |
|
24 | 24 | try: |
25 | | - from core.env_server.http_server import create_app |
| 25 | + from openenv_core.env_server.http_server import create_app |
26 | 26 | except Exception as e: # pragma: no cover |
27 | 27 | raise ImportError( |
28 | | - "openenv_core is required for the web interface. Install template deps with '\n" |
29 | | - " pip install -r server/requirements.txt\n'" |
| 28 | + "openenv_core is required for the web interface. Install dependencies with '\n" |
| 29 | + " uv sync\n'" |
30 | 30 | ) from e |
31 | 31 |
|
32 | 32 | from .websearch_env_environment import WebSearchEnvironment |
33 | | -from ..models import WebSearchAction, WebSearchObservation |
| 33 | +from models import WebSearchAction, WebSearchObservation |
34 | 34 |
|
35 | 35 | # Create the environment instance |
36 | 36 | env = WebSearchEnvironment() |
37 | 37 |
|
38 | 38 | # Create the app with web interface and README integration |
39 | | -app = create_app(env, WebSearchAction, WebSearchObservation, env_name="websearch_env") |
| 39 | +app = create_app( |
| 40 | + env, |
| 41 | + WebSearchAction, |
| 42 | + WebSearchObservation, |
| 43 | + env_name="websearch_env", |
| 44 | +) |
40 | 45 |
|
41 | 46 |
|
42 | | -if __name__ == "__main__": |
| 47 | +def main(host: str = "0.0.0.0", port: int = 8000): |
| 48 | + """ |
| 49 | + Entry point for direct execution via uv run or python -m. |
| 50 | +
|
| 51 | + This function enables running the server without Docker: |
| 52 | + uv run --project . server |
| 53 | + uv run --project . server --port 8001 |
| 54 | + python -m websearch_env.server.app |
| 55 | +
|
| 56 | + Args: |
| 57 | + host: Host address to bind to (default: "0.0.0.0") |
| 58 | + port: Port number to listen on (default: 8000) |
| 59 | +
|
| 60 | + For production deployments, consider using uvicorn directly with |
| 61 | + multiple workers: |
| 62 | + uvicorn websearch_env.server.app:app --workers 4 |
| 63 | + """ |
43 | 64 | import uvicorn |
44 | 65 |
|
45 | | - uvicorn.run(app, host="0.0.0.0", port=8000) |
| 66 | + uvicorn.run(app, host=host, port=port) |
| 67 | + |
| 68 | + |
| 69 | +if __name__ == "__main__": |
| 70 | + main() |
0 commit comments