feat(cli): add debugger host CLI flag to specify default base URL (#900)

This commit is contained in:
David Duong
2024-07-08 20:47:50 -04:00
committed by GitHub
parent bb6785bbef
commit 293bc2c11f
3 changed files with 51 additions and 16 deletions
+17 -1
View File
@@ -134,6 +134,12 @@ OPT_DEBUGGER_PORT = click.option(
type=int,
help="Pull the debugger image locally and serve the UI on specified port",
)
OPT_DEBUGGER_BASE_URL = click.option(
"--debugger-base-url",
type=str,
help="URL used by the debugger to access LangGraph API. Defaults to http://127.0.0.1:[PORT]",
)
OPT_POSTGRES_URI = click.option(
"--postgres-uri",
help="Postgres URI to use for the database. Defaults to launching a local database",
@@ -152,6 +158,7 @@ def cli():
@OPT_CONFIG
@OPT_VERBOSE
@OPT_DEBUGGER_PORT
@OPT_DEBUGGER_BASE_URL
@OPT_WATCH
@OPT_POSTGRES_URI
@click.option(
@@ -173,6 +180,7 @@ def up(
wait: bool,
verbose: bool,
debugger_port: Optional[int],
debugger_base_url: Optional[str],
postgres_uri: Optional[str],
):
click.secho("Starting LangGraph API server...", fg="green")
@@ -193,6 +201,7 @@ For production use, requires a license key in env var LANGGRAPH_CLOUD_LICENSE_KE
watch=watch,
verbose=verbose,
debugger_port=debugger_port,
debugger_base_url=debugger_base_url,
postgres_uri=postgres_uri,
)
# add up + options
@@ -221,12 +230,15 @@ For production use, requires a license key in env var LANGGRAPH_CLOUD_LICENSE_KE
if debugger_port
else "https://smith.langchain.com"
)
debugger_base_url_query = (
debugger_base_url or f"http://127.0.0.1:{port}"
)
set("")
sys.stdout.write(
f"""Ready!
- API: http://localhost:{port}
- Docs: http://localhost:{port}/docs
- Debugger: {debugger_origin}/studio/?baseUrl=http://127.0.0.1:{port}
- Debugger: {debugger_origin}/studio/?baseUrl={debugger_base_url_query}
"""
)
sys.stdout.flush()
@@ -449,6 +461,7 @@ def prepare_args_and_stdin(
port: int,
watch: bool,
debugger_port: Optional[int] = None,
debugger_base_url: Optional[str] = None,
postgres_uri: Optional[str] = None,
):
# prepare args
@@ -456,6 +469,7 @@ def prepare_args_and_stdin(
capabilities,
port=port,
debugger_port=debugger_port,
debugger_base_url=debugger_base_url,
postgres_uri=postgres_uri,
)
args = [
@@ -487,6 +501,7 @@ def prepare(
watch: bool,
verbose: bool,
debugger_port: Optional[int] = None,
debugger_base_url: Optional[str] = None,
postgres_uri: Optional[str] = None,
):
with open(config_path) as f:
@@ -510,6 +525,7 @@ def prepare(
port=port,
watch=watch,
debugger_port=debugger_port,
debugger_base_url=debugger_base_url or f"http://127.0.0.1:{port}",
postgres_uri=postgres_uri,
)
return args, stdin