From f1024f7341cd5a51bfe7c998797c5ae5ef726e4c Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Thu, 6 Mar 2025 17:55:42 +0100 Subject: [PATCH] feat(cli): allow sending UI args --- libs/cli/langgraph_cli/config.py | 7 +++++++ libs/cli/tests/unit_tests/test_config.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/libs/cli/langgraph_cli/config.py b/libs/cli/langgraph_cli/config.py index 2b7e4bbcc..5082bb017 100644 --- a/libs/cli/langgraph_cli/config.py +++ b/libs/cli/langgraph_cli/config.py @@ -334,6 +334,10 @@ class Config(TypedDict, total=False): and how cross-origin requests are handled. """ + ui: Optional[dict[str, str]] + """Optional. Named definitions of UI components emitted by the agent, each pointing to a JS/TS file. + """ + def _parse_version(version_str: str) -> tuple[int, int]: """Parse a version string into a tuple of (major, minor).""" @@ -369,6 +373,7 @@ def validate_config(config: Config) -> Config: "store": config.get("store"), "auth": config.get("auth"), "http": config.get("http"), + "ui": config.get("ui"), } if config.get("node_version") else { @@ -381,6 +386,7 @@ def validate_config(config: Config) -> Config: "store": config.get("store"), "auth": config.get("auth"), "http": config.get("http"), + "ui": config.get("ui"), } ) @@ -1029,6 +1035,7 @@ ADD . {faux_path} RUN cd {faux_path} && {install_cmd} {env_additional_config} ENV LANGSERVE_GRAPHS='{json.dumps(config["graphs"])}' +{f"ENV LANGGRAPH_UI='{json.dumps(config['ui'])}'" if config.get("ui") else ""} WORKDIR {faux_path} diff --git a/libs/cli/tests/unit_tests/test_config.py b/libs/cli/tests/unit_tests/test_config.py index 95e20033e..397fca031 100644 --- a/libs/cli/tests/unit_tests/test_config.py +++ b/libs/cli/tests/unit_tests/test_config.py @@ -33,6 +33,7 @@ def test_validate_config(): "store": None, "auth": None, "http": None, + "ui": None, **expected_config, } actual_config = validate_config(expected_config) @@ -52,6 +53,7 @@ def test_validate_config(): "store": None, "auth": None, "http": None, + "ui": None, } actual_config = validate_config(expected_config) assert actual_config == expected_config @@ -467,6 +469,7 @@ def test_config_to_docker_nodejs(): "node_version": "20", "graphs": graphs, "dockerfile_lines": ["ARG meow", "ARG foo"], + "ui": {"agent": "./graphs/agent.ui.jsx"}, } ), "langchain/langgraphjs-api", @@ -477,6 +480,7 @@ ARG foo ADD . /deps/unit_tests RUN cd /deps/unit_tests && npm i ENV LANGSERVE_GRAPHS='{"agent": "./graphs/agent.js:graph"}' +ENV LANGGRAPH_UI='{"agent": "./graphs/agent.ui.jsx"}' WORKDIR /deps/unit_tests RUN (test ! -f /api/langgraph_api/js/build.mts && echo "Prebuild script not found, skipping") || tsx /api/langgraph_api/js/build.mts"""