From d51c61e91c4d7b20d89bf040b2dde2f1db8e3bd7 Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Thu, 14 Dec 2023 13:01:33 -0800 Subject: [PATCH] allow passing custom host to uvicorn (#618) --- memgpt/cli/cli.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/memgpt/cli/cli.py b/memgpt/cli/cli.py index c1270606..7cc2d58d 100644 --- a/memgpt/cli/cli.py +++ b/memgpt/cli/cli.py @@ -31,7 +31,9 @@ class ServerChoice(Enum): def server( - type: ServerChoice = typer.Option("rest", help="Server to run"), port: int = typer.Option(None, help="Port to run the server on") + type: ServerChoice = typer.Option("rest", help="Server to run"), + port: int = typer.Option(None, help="Port to run the server on"), + host: str = typer.Option(None, help="Host to run the server on (default to localhost)"), ): """Launch a MemGPT server process""" @@ -44,7 +46,10 @@ def server( script_dir = script_path.parent server_directory = os.path.join(script_dir.parent, "server", "rest_api") - command = f"uvicorn server:app --reload --port {port}" + if host is None: + command = f"uvicorn server:app --reload --port {port}" + else: + command = f"uvicorn server:app --reload --port {port} --host {host}" # Run the command print(f"Running REST server: {command} (inside {server_directory})")