From 74c2ef6608bdea82223c8d129f8a95c80e9d3db9 Mon Sep 17 00:00:00 2001 From: Zamil Majdy Date: Mon, 23 Sep 2024 21:30:52 -0500 Subject: [PATCH] feat(platform): Make API host configurable --- autogpt_platform/backend/backend/server/rest_api.py | 7 ++++++- autogpt_platform/backend/backend/server/ws_api.py | 6 +++++- autogpt_platform/backend/backend/util/settings.py | 10 ++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/autogpt_platform/backend/backend/server/rest_api.py b/autogpt_platform/backend/backend/server/rest_api.py index 9f3afd2fba68..9ddaa5bdc031 100644 --- a/autogpt_platform/backend/backend/server/rest_api.py +++ b/autogpt_platform/backend/backend/server/rest_api.py @@ -251,7 +251,12 @@ def run_service(self): app.include_router(api_router) - uvicorn.run(app, host="0.0.0.0", port=Config().agent_api_port, log_config=None) + uvicorn.run( + app, + host=Config().agent_api_host, + port=Config().agent_api_port, + log_config=None, + ) def set_test_dependency_overrides(self, overrides: dict): self._test_dependency_overrides = overrides diff --git a/autogpt_platform/backend/backend/server/ws_api.py b/autogpt_platform/backend/backend/server/ws_api.py index cbfe00e439d9..0bf8231eeb33 100644 --- a/autogpt_platform/backend/backend/server/ws_api.py +++ b/autogpt_platform/backend/backend/server/ws_api.py @@ -174,4 +174,8 @@ async def websocket_router( class WebsocketServer(AppProcess): def run(self): - uvicorn.run(app, host="0.0.0.0", port=Config().websocket_server_port) + uvicorn.run( + app, + host=Config().websocket_server_host, + port=Config().websocket_server_port, + ) diff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.py index 230fa14f5282..c81ac09bd8ec 100644 --- a/autogpt_platform/backend/backend/util/settings.py +++ b/autogpt_platform/backend/backend/util/settings.py @@ -80,6 +80,11 @@ class Config(UpdateTrackingModel["Config"], BaseSettings): extra="allow", ) + websocket_server_host: str = Field( + default="0.0.0.0", + description="The host for the websocket server to run on", + ) + websocket_server_port: int = Field( default=8001, description="The port for the websocket server to run on", @@ -100,6 +105,11 @@ class Config(UpdateTrackingModel["Config"], BaseSettings): description="The port for agent server daemon to run on", ) + agent_api_host: str = Field( + default="0.0.0.0", + description="The host for agent server API to run on", + ) + agent_api_port: int = Field( default=8006, description="The port for agent server API to run on",