From 11f2501c9823664500ded692775227637094be9e Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Fri, 17 Jan 2025 03:45:27 +0100 Subject: [PATCH 1/4] docs: add mention of JS CLI --- docs/docs/cloud/reference/cli.md | 570 +++++++++++++++++++------------ 1 file changed, 361 insertions(+), 209 deletions(-) diff --git a/docs/docs/cloud/reference/cli.md b/docs/docs/cloud/reference/cli.md index 37f4e38d9..78495d8e7 100644 --- a/docs/docs/cloud/reference/cli.md +++ b/docs/docs/cloud/reference/cli.md @@ -4,20 +4,23 @@ The LangGraph command line interface includes commands to build and run a LangGr ## Installation -1. Ensure that Docker is installed (e.g. `docker --version`). -2. Install the `langgraph-cli` package: - - === "pip" - ```bash - pip install langgraph-cli - ``` +1. Ensure that Docker is installed (e.g. `docker --version`). +2. Install the CLI package: - === "Homebrew (MacOS only)" + === "Python" ```bash + pip install langgraph-cli + + # Install via Homebrew brew install langgraph-cli ``` - -3. Run the command `langgraph --help` to confirm that the CLI is installed. + + === "JS" + ```bash + npx @langchain/langgraph-cli + ``` + +3. Run the command `langgraph --help` to confirm that the CLI is installed. [](){#langgraph.json} @@ -25,17 +28,6 @@ The LangGraph command line interface includes commands to build and run a LangGr The LangGraph CLI requires a JSON configuration file with the following keys: -| Key | Description | -| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `dependencies` | **Required**. Array of dependencies for LangGraph Cloud API server. Dependencies can be one of the following: (1) `"."`, which will look for local Python packages, (2) `pyproject.toml`, `setup.py` or `requirements.txt` in the app directory `"./local_package"`, or (3) a package name. | -| `graphs` | **Required**. Mapping from graph ID to path where the compiled graph or a function that makes a graph is defined. Example: | -| `auth` | _(Added in v0.0.11)_ Auth configuration containing the path to your authentication handler. Example: `./your_package/auth.py:auth`, where `auth` is an instance of `langgraph_sdk.Auth`. See [authentication guide](../../concepts/auth.md) for details. | -| `env` | Path to `.env` file or a mapping from environment variable to its value. | -| `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields: | -| `python_version` | `3.11` or `3.12`. Defaults to `3.11`. | -| `pip_config_file` | Path to `pip` config file. | -| `dockerfile_lines` | Array of additional lines to add to Dockerfile following the import from parent image. | -

Note

@@ -43,113 +35,151 @@ The LangGraph CLI requires a JSON configuration file with the following keys:

+=== "Python" + + | Key | Description | + | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | + | `dependencies` | **Required**. Array of dependencies for LangGraph Cloud API server. Dependencies can be one of the following: (1) `"."`, which will look for local Python packages, (2) `pyproject.toml`, `setup.py` or `requirements.txt` in the app directory `"./local_package"`, or (3) a package name. | + | `graphs` | **Required**. Mapping from graph ID to path where the compiled graph or a function that makes a graph is defined. Example: | + | `auth` | _(Added in v0.0.11)_ Auth configuration containing the path to your authentication handler. Example: `./your_package/auth.py:auth`, where `auth` is an instance of `langgraph_sdk.Auth`. See [authentication guide](../../concepts/auth.md) for details. | + | `env` | Path to `.env` file or a mapping from environment variable to its value. | + | `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields: | + | `python_version` | `3.11` or `3.12`. Defaults to `3.11`. | + | `node_version` | Specify `node_version: 20` to use LangGraph.js. | + | `pip_config_file` | Path to `pip` config file. | + | `dockerfile_lines` | Array of additional lines to add to Dockerfile following the import from parent image. | + +=== "JS" + + | Key | Description | + | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | + | `graphs` | **Required**. Mapping from graph ID to path where the compiled graph or a function that makes a graph is defined. Example: | + | `env` | Path to `.env` file or a mapping from environment variable to its value. | + | `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields: | + | `node_version` | Specify `node_version: 20` to use LangGraph.js. | + | `dockerfile_lines` | Array of additional lines to add to Dockerfile following the import from parent image. | + ### Examples -#### Basic Configuration +=== "Python" + + #### Basic Configuration -```json -{ - "dependencies": ["."], - "graphs": { - "chat": "./chat/graph.py:graph" - } -} -``` - -#### Adding semantic search to the store - -All deployments come with a DB-backed BaseStore. Adding an "index" configuration to your `langgraph.json` will enable [semantic search](../deployment/semantic_search.md) within the BaseStore of your deployment. - -The `fields` configuration determines which parts of your documents to embed: - -- If omitted or set to `["$"]`, the entire document will be embedded -- To embed specific fields, use JSON path notation: `["metadata.title", "content.text"]` -- Documents missing specified fields will still be stored but won't have embeddings for those fields -- You can still override which fields to embed on a specific item at `put` time using the `index` parameter - -```json -{ - "dependencies": ["."], - "graphs": { - "memory_agent": "./agent/graph.py:graph" - }, - "store": { - "index": { - "embed": "openai:text-embedding-3-small", - "dims": 1536, - "fields": ["$"] + ```json + { + "dependencies": ["."], + "graphs": { + "chat": "./chat/graph.py:graph" + } } - } -} -``` + ``` -!!! note "Common model dimensions" - - openai:text-embedding-3-large: 3072 - - openai:text-embedding-3-small: 1536 - - openai:text-embedding-ada-002: 1536 - - cohere:embed-english-v3.0: 1024 - - cohere:embed-english-light-v3.0: 384 - - cohere:embed-multilingual-v3.0: 1024 - - cohere:embed-multilingual-light-v3.0: 384 + #### Adding semantic search to the store -#### Semantic search with a custom embedding function + All deployments come with a DB-backed BaseStore. Adding an "index" configuration to your `langgraph.json` will enable [semantic search](../deployment/semantic_search.md) within the BaseStore of your deployment. -If you want to use semantic search with a custom embedding function, you can pass a path to a custom embedding function: + The `fields` configuration determines which parts of your documents to embed: -```json -{ - "dependencies": ["."], - "graphs": { - "memory_agent": "./agent/graph.py:graph" - }, - "store": { - "index": { - "embed": "./embeddings.py:embed_texts", - "dims": 768, - "fields": ["text", "summary"] - } - } -} -``` + - If omitted or set to `["$"]`, the entire document will be embedded + - To embed specific fields, use JSON path notation: `["metadata.title", "content.text"]` + - Documents missing specified fields will still be stored but won't have embeddings for those fields + - You can still override which fields to embed on a specific item at `put` time using the `index` parameter -The `embed` field in store configuration can reference a custom function that takes a list of strings and returns a list of embeddings. Example implementation: - -```python -# embeddings.py -def embed_texts(texts: list[str]) -> list[list[float]]: - """Custom embedding function for semantic search.""" - # Implementation using your preferred embedding model - return [[0.1, 0.2, ...] for _ in texts] # dims-dimensional vectors -``` - -#### Adding custom authentication - -```json -{ - "dependencies": ["."], - "graphs": { - "chat": "./chat/graph.py:graph" - }, - "auth": { - "path": "./auth.py:auth", - "openapi": { - "securitySchemes": { - "apiKeyAuth": { - "type": "apiKey", - "in": "header", - "name": "X-API-Key" - } + ```json + { + "dependencies": ["."], + "graphs": { + "memory_agent": "./agent/graph.py:graph" }, - "security": [ - {"apiKeyAuth": []} - ] - }, - "disable_studio_auth": false - } -} -``` + "store": { + "index": { + "embed": "openai:text-embedding-3-small", + "dims": 1536, + "fields": ["$"] + } + } + } + ``` + + !!! note "Common model dimensions" + - `openai:text-embedding-3-large`: 3072 + - `openai:text-embedding-3-small`: 1536 + - `openai:text-embedding-ada-002`: 1536 + - `cohere:embed-english-v3.0`: 1024 + - `cohere:embed-english-light-v3.0`: 384 + - `cohere:embed-multilingual-v3.0`: 1024 + - `cohere:embed-multilingual-light-v3.0`: 384 + + #### Semantic search with a custom embedding function + + If you want to use semantic search with a custom embedding function, you can pass a path to a custom embedding function: + + ```json + { + "dependencies": ["."], + "graphs": { + "memory_agent": "./agent/graph.py:graph" + }, + "store": { + "index": { + "embed": "./embeddings.py:embed_texts", + "dims": 768, + "fields": ["text", "summary"] + } + } + } + ``` + + The `embed` field in store configuration can reference a custom function that takes a list of strings and returns a list of embeddings. Example implementation: + + ```python + # embeddings.py + def embed_texts(texts: list[str]) -> list[list[float]]: + """Custom embedding function for semantic search.""" + # Implementation using your preferred embedding model + return [[0.1, 0.2, ...] for _ in texts] # dims-dimensional vectors + ``` + + #### Adding custom authentication + + ```json + { + "dependencies": ["."], + "graphs": { + "chat": "./chat/graph.py:graph" + }, + "auth": { + "path": "./auth.py:auth", + "openapi": { + "securitySchemes": { + "apiKeyAuth": { + "type": "apiKey", + "in": "header", + "name": "X-API-Key" + } + }, + "security": [{ "apiKeyAuth": [] }] + }, + "disable_studio_auth": false + } + } + ``` + + See the [authentication conceptual guide](../../concepts/auth.md) for details, and the [setting up custom authentication](../../tutorials/auth/getting_started.md) guide for a practical walk through of the process. + + +=== "JS" + + #### Basic Configuration + + ```json + { + "graphs": { + "chat": "./src/graph.ts:graph" + } + } + ``` -See the [authentication conceptual guide](../../concepts/auth.md) for details, and the [setting up custom authentication](../../tutorials/auth/getting_started.md) guide for a practical walk through of the process. ## Commands @@ -157,139 +187,261 @@ The base command for the LangGraph CLI is `langgraph`. **Usage** -``` -langgraph [OPTIONS] COMMAND [ARGS] -``` +=== "Python" + + ``` + langgraph [OPTIONS] COMMAND [ARGS] + ``` +=== "JS" + + ``` + npx @langchain/langgraph-cli [OPTIONS] COMMAND [ARGS] + ``` + + We will be referring to `npx @langchain/langgraph-cli` as `langgraph` in the following commands. ### `dev` -Run LangGraph API server in development mode with hot reloading and debugging capabilities. This lightweight server requires no Docker installation and is suitable for development and testing. State is persisted to a local directory. +=== "Python" -!!! note "Python only" + Run LangGraph API server in development mode with hot reloading and debugging capabilities. This lightweight server requires no Docker installation and is suitable for development and testing. State is persisted to a local directory. - Currently, the CLI only supports Python >= 3.11. - JS support is coming soon. + !!! note -**Installation** + Currently, the CLI only supports Python >= 3.11. -This command requires the "inmem" extra to be installed: + **Installation** -```bash -pip install -U "langgraph-cli[inmem]" -``` + This command requires the "inmem" extra to be installed: -**Usage** + ```bash + pip install -U "langgraph-cli[inmem]" + ``` -``` -langgraph dev [OPTIONS] -``` + **Usage** -**Options** + ``` + langgraph dev [OPTIONS] + ``` -| Option | Default | Description | -| ----------------------------- | ---------------- | ----------------------------------------------------------------------------------- | -| `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables | -| `--host TEXT` | `127.0.0.1` | Host to bind the server to | -| `--port INTEGER` | `2024` | Port to bind the server to | -| `--no-reload` | | Disable auto-reload | -| `--n-jobs-per-worker INTEGER` | | Number of jobs per worker. Default is 10 | -| `--no-browser` | | Disable automatic browser opening | -| `--debug-port INTEGER` | | Port for debugger to listen on | -| `--help` | | Display command documentation | + **Options** + + | Option | Default | Description | + | ----------------------------- | ---------------- | ----------------------------------------------------------------------------------- | + | `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables | + | `--host TEXT` | `127.0.0.1` | Host to bind the server to | + | `--port INTEGER` | `2024` | Port to bind the server to | + | `--no-reload` | | Disable auto-reload | + | `--n-jobs-per-worker INTEGER` | | Number of jobs per worker. Default is 10 | + | `--debug-port INTEGER` | | Port for debugger to listen on | + | `--help` | | Display command documentation | + + +=== "JS" + + Run LangGraph API server in development mode with hot reloading capabilities. This lightweight server requires no Docker installation and is suitable for development and testing. State is persisted to a local directory. + + **Usage** + + ``` + langgraph dev [OPTIONS] + ``` + + **Options** + + | Option | Default | Description | + | ----------------------------- | ---------------- | ----------------------------------------------------------------------------------- | + | `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables | + | `--host TEXT` | `127.0.0.1` | Host to bind the server to | + | `--port INTEGER` | `2024` | Port to bind the server to | + | `--no-reload` | | Disable auto-reload | + | `--n-jobs-per-worker INTEGER` | | Number of jobs per worker. Default is 10 | + | `--debug-port INTEGER` | | Port for debugger to listen on | + | `--help` | | Display command documentation | ### `build` -Build LangGraph Cloud API server Docker image. +=== "Python" -**Usage** + Build LangGraph Cloud API server Docker image. -``` -langgraph build [OPTIONS] -``` + **Usage** -**Options** + ``` + langgraph build [OPTIONS] + ``` + + **Options** + + | Option | Default | Description | + | -------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------- | + | `--platform TEXT` | | Target platform(s) to build the Docker image for. Example: `langgraph build --platform linux/amd64,linux/arm64` | + | `-t, --tag TEXT` | | **Required**. Tag for the Docker image. Example: `langgraph build -t my-image` | + | `--pull / --no-pull` | `--pull` | Build with latest remote Docker image. Use `--no-pull` for running the LangGraph Cloud API server with locally built images. | + | `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. | + | `--help` | | Display command documentation. | + +=== "JS" + + Build LangGraph Cloud API server Docker image. + + **Usage** + + ``` + langgraph build [OPTIONS] + ``` + + **Options** + + | Option | Default | Description | + | -------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------- | + | `--platform TEXT` | | Target platform(s) to build the Docker image for. Example: `langgraph build --platform linux/amd64,linux/arm64` | + | `-t, --tag TEXT` | | **Required**. Tag for the Docker image. Example: `langgraph build -t my-image` | + | `--no-pull` | | Use locally built images. Defaults to `false` to build with latest remote Docker image. | + | `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. | + | `--help` | | Display command documentation. | -| Option | Default | Description | -| -------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `--platform TEXT` | | Target platform(s) to build the Docker image for. Example: `langgraph build --platform linux/amd64,linux/arm64` | -| `-t, --tag TEXT` | | **Required**. Tag for the Docker image. Example: `langgraph build -t my-image` | -| `--pull / --no-pull` | `--pull` | Build with latest remote Docker image. Use `--no-pull` for running the LangGraph Cloud API server with locally built images. | -| `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. | -| `--help` | | Display command documentation. | ### `up` -Start LangGraph API server. For local testing, requires a LangSmith API key with access to LangGraph Cloud closed beta. Requires a license key for production use. +=== "Python" -**Usage** + Start LangGraph API server. For local testing, requires a LangSmith API key with access to LangGraph Cloud closed beta. Requires a license key for production use. -``` -langgraph up [OPTIONS] -``` + **Usage** -**Options** + ``` + langgraph up [OPTIONS] + ``` -| Option | Default | Description | -| ---------------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------- | -| `--wait` | | Wait for services to start before returning. Implies --detach | -| `--postgres-uri TEXT` | Local database | Postgres URI to use for the database. | -| `--watch` | | Restart on file changes | -| `--debugger-base-url TEXT` | `http://127.0.0.1:[PORT]` | URL used by the debugger to access LangGraph API. | -| `--debugger-port INTEGER` | | Pull the debugger image locally and serve the UI on specified port | -| `--verbose` | | Show more output from the server logs. | -| `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. | -| `-d, --docker-compose FILE` | | Path to docker-compose.yml file with additional services to launch. | -| `-p, --port INTEGER` | `8123` | Port to expose. Example: `langgraph up --port 8000` | -| `--pull / --no-pull` | `pull` | Pull latest images. Use `--no-pull` for running the server with locally-built images. Example: `langgraph up --no-pull` | -| `--recreate / --no-recreate` | `no-recreate` | Recreate containers even if their configuration and image haven't changed | -| `--help` | | Display command documentation. | + **Options** + + | Option | Default | Description | + | ---------------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------- | + | `--wait` | | Wait for services to start before returning. Implies --detach | + | `--postgres-uri TEXT` | Local database | Postgres URI to use for the database. | + | `--watch` | | Restart on file changes | + | `--debugger-base-url TEXT` | `http://127.0.0.1:[PORT]` | URL used by the debugger to access LangGraph API. | + | `--debugger-port INTEGER` | | Pull the debugger image locally and serve the UI on specified port | + | `--verbose` | | Show more output from the server logs. | + | `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. | + | `-d, --docker-compose FILE` | | Path to docker-compose.yml file with additional services to launch. | + | `-p, --port INTEGER` | `8123` | Port to expose. Example: `langgraph up --port 8000` | + | `--pull / --no-pull` | `pull` | Pull latest images. Use `--no-pull` for running the server with locally-built images. Example: `langgraph up --no-pull` | + | `--recreate / --no-recreate` | `no-recreate` | Recreate containers even if their configuration and image haven't changed | + | `--help` | | Display command documentation. | + +=== "JS" + + Start LangGraph API server. For local testing, requires a LangSmith API key with access to LangGraph Cloud closed beta. Requires a license key for production use. + + **Usage** + + ``` + langgraph up [OPTIONS] + ``` + + **Options** + + | Option | Default | Description | + | ---------------------------------------------------------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------- | + | `--wait` | | Wait for services to start before returning. Implies --detach | + | `--postgres-uri TEXT` | Local database | Postgres URI to use for the database. | + | `--watch` | | Restart on file changes | + | `-c, --config FILE` | `langgraph.json` | Path to configuration file declaring dependencies, graphs and environment variables. | + | `-d, --docker-compose FILE` | | Path to docker-compose.yml file with additional services to launch. | + | `-p, --port INTEGER` | `8123` | Port to expose. Example: `langgraph up --port 8000` | + | `--no-pull` | | Use locally built images. Defaults to `false` to build with latest remote Docker image. | + | `--recreate` | | Recreate containers even if their configuration and image haven't changed | + | `--help` | | Display command documentation. | ### `dockerfile` -Generate a Dockerfile for building a LangGraph Cloud API server Docker image. +=== "Python" -**Usage** + Generate a Dockerfile for building a LangGraph Cloud API server Docker image. -``` -langgraph dockerfile [OPTIONS] SAVE_PATH -``` + **Usage** -**Options** + ``` + langgraph dockerfile [OPTIONS] SAVE_PATH + ``` -| Option | Default | Description | -| ------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------- | -| `-c, --config FILE` | `langgraph.json` | Path to the [configuration file](#configuration-file) declaring dependencies, graphs and environment variables. | -| `--help` | | Show this message and exit. | + **Options** -Example: + | Option | Default | Description | + | ------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------- | + | `-c, --config FILE` | `langgraph.json` | Path to the [configuration file](#configuration-file) declaring dependencies, graphs and environment variables. | + | `--help` | | Show this message and exit. | -```bash -langgraph dockerfile -c langgraph.json Dockerfile -``` + Example: -This generates a Dockerfile that looks similar to: + ```bash + langgraph dockerfile -c langgraph.json Dockerfile + ``` -```dockerfile -FROM langchain/langgraph-api:3.11 + This generates a Dockerfile that looks similar to: -ADD ./pipconf.txt /pipconfig.txt + ```dockerfile + FROM langchain/langgraph-api:3.11 -RUN PIP_CONFIG_FILE=/pipconfig.txt PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -c /api/constraints.txt langchain_community langchain_anthropic langchain_openai wikipedia scikit-learn + ADD ./pipconf.txt /pipconfig.txt -ADD ./graphs /deps/__outer_graphs/src -RUN set -ex && \ - for line in '[project]' \ - 'name = "graphs"' \ - 'version = "0.1"' \ - '[tool.setuptools.package-data]' \ - '"*" = ["**/*"]'; do \ - echo "$line" >> /deps/__outer_graphs/pyproject.toml; \ - done + RUN PIP_CONFIG_FILE=/pipconfig.txt PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -c /api/constraints.txt langchain_community langchain_anthropic langchain_openai wikipedia scikit-learn -RUN PIP_CONFIG_FILE=/pipconfig.txt PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -c /api/constraints.txt -e /deps/* + ADD ./graphs /deps/__outer_graphs/src + RUN set -ex && \ + for line in '[project]' \ + 'name = "graphs"' \ + 'version = "0.1"' \ + '[tool.setuptools.package-data]' \ + '"*" = ["**/*"]'; do \ + echo "$line" >> /deps/__outer_graphs/pyproject.toml; \ + done -ENV LANGSERVE_GRAPHS='{"agent": "/deps/__outer_graphs/src/agent.py:graph", "storm": "/deps/__outer_graphs/src/storm.py:graph"}' -``` + RUN PIP_CONFIG_FILE=/pipconfig.txt PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -c /api/constraints.txt -e /deps/* + + ENV LANGSERVE_GRAPHS='{"agent": "/deps/__outer_graphs/src/agent.py:graph", "storm": "/deps/__outer_graphs/src/storm.py:graph"}' + ``` + +=== "JS" + + Generate a Dockerfile for building a LangGraph Cloud API server Docker image. + + **Usage** + + ``` + langgraph dockerfile [OPTIONS] SAVE_PATH + ``` + + **Options** + + | Option | Default | Description | + | ------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------- | + | `-c, --config FILE` | `langgraph.json` | Path to the [configuration file](#configuration-file) declaring dependencies, graphs and environment variables. | + | `--help` | | Show this message and exit. | + + Example: + + ```bash + langgraph dockerfile -c langgraph.json Dockerfile + ``` + + This generates a Dockerfile that looks similar to: + + ```dockerfile + FROM langchain/langgraphjs-api:20 + + ADD . /deps/agent + + RUN cd /deps/agent && yarn install + + ENV LANGSERVE_GRAPHS='{"agent":"./src/react_agent/graph.ts:graph"}' + + WORKDIR /deps/agent + + RUN (test ! -f /api/langgraph_api/js/build.mts && echo "Prebuild script not found, skipping") || tsx /api/langgraph_api/js/build.mts + ``` ???+ note "Updating your langgraph.json file" - The `langgraph dockerfile` command translates all the configuration in your `langgraph.json` file into Dockerfile commands. When using this command, you will have to re-run it whenever you update your `langgraph.json` file. Otherwise, your changes will not be reflected when you build or run the dockerfile. \ No newline at end of file + The `langgraph dockerfile` command translates all the configuration in your `langgraph.json` file into Dockerfile commands. When using this command, you will have to re-run it whenever you update your `langgraph.json` file. Otherwise, your changes will not be reflected when you build or run the dockerfile. From efa51fe22cb80d9e33aa9b4d0703ce066b57be18 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Fri, 17 Jan 2025 20:23:37 +0100 Subject: [PATCH 2/4] Update README.md --- docs/docs/cloud/reference/cli.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/docs/cloud/reference/cli.md b/docs/docs/cloud/reference/cli.md index 78495d8e7..00396620e 100644 --- a/docs/docs/cloud/reference/cli.md +++ b/docs/docs/cloud/reference/cli.md @@ -18,9 +18,12 @@ The LangGraph command line interface includes commands to build and run a LangGr === "JS" ```bash npx @langchain/langgraph-cli + + # Install globally + npm install -g @langchain/langgraph-cli ``` -3. Run the command `langgraph --help` to confirm that the CLI is installed. +3. Run the command `langgraph --help` or `npx @langchain/langgraph-cli --help` to confirm that the CLI is working correctly. [](){#langgraph.json} @@ -55,7 +58,7 @@ The LangGraph CLI requires a JSON configuration file with the following keys: | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `graphs` | **Required**. Mapping from graph ID to path where the compiled graph or a function that makes a graph is defined. Example: | | `env` | Path to `.env` file or a mapping from environment variable to its value. | - | `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields: | + | `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields: | | `node_version` | Specify `node_version: 20` to use LangGraph.js. | | `dockerfile_lines` | Array of additional lines to add to Dockerfile following the import from parent image. | @@ -183,23 +186,23 @@ The LangGraph CLI requires a JSON configuration file with the following keys: ## Commands -The base command for the LangGraph CLI is `langgraph`. - **Usage** === "Python" + The base command for the LangGraph CLI is `langgraph`. + ``` langgraph [OPTIONS] COMMAND [ARGS] ``` === "JS" + The base command for the LangGraph.js CLI is `langgraphjs`. We recommend using `npx` to always use the latest version of the CLI. + ``` npx @langchain/langgraph-cli [OPTIONS] COMMAND [ARGS] ``` - We will be referring to `npx @langchain/langgraph-cli` as `langgraph` in the following commands. - ### `dev` === "Python" @@ -244,7 +247,7 @@ The base command for the LangGraph CLI is `langgraph`. **Usage** ``` - langgraph dev [OPTIONS] + npx @langchain/langgraph-cli dev [OPTIONS] ``` **Options** @@ -288,7 +291,7 @@ The base command for the LangGraph CLI is `langgraph`. **Usage** ``` - langgraph build [OPTIONS] + npx @langchain/langgraph-cli build [OPTIONS] ``` **Options** @@ -338,7 +341,7 @@ The base command for the LangGraph CLI is `langgraph`. **Usage** ``` - langgraph up [OPTIONS] + npx @langchain/langgraph-cli up [OPTIONS] ``` **Options** @@ -411,7 +414,7 @@ The base command for the LangGraph CLI is `langgraph`. **Usage** ``` - langgraph dockerfile [OPTIONS] SAVE_PATH + npx @langchain/langgraph-cli dockerfile [OPTIONS] SAVE_PATH ``` **Options** From 0e79407973d2a91279d425ed0e3a1b278c32f470 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Fri, 17 Jan 2025 20:27:42 +0100 Subject: [PATCH 3/4] Last pass --- docs/docs/cloud/reference/cli.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/docs/cloud/reference/cli.md b/docs/docs/cloud/reference/cli.md index 00396620e..875fd7e0f 100644 --- a/docs/docs/cloud/reference/cli.md +++ b/docs/docs/cloud/reference/cli.md @@ -19,7 +19,7 @@ The LangGraph command line interface includes commands to build and run a LangGr ```bash npx @langchain/langgraph-cli - # Install globally + # Install globally, will be available as `langgraphjs` npm install -g @langchain/langgraph-cli ``` @@ -197,12 +197,14 @@ The LangGraph CLI requires a JSON configuration file with the following keys: ``` === "JS" - The base command for the LangGraph.js CLI is `langgraphjs`. We recommend using `npx` to always use the latest version of the CLI. + The base command for the LangGraph.js CLI is `langgraphjs`. ``` npx @langchain/langgraph-cli [OPTIONS] COMMAND [ARGS] ``` + We recommend using `npx` to always use the latest version of the CLI. + ### `dev` === "Python" @@ -407,6 +409,9 @@ The LangGraph CLI requires a JSON configuration file with the following keys: ENV LANGSERVE_GRAPHS='{"agent": "/deps/__outer_graphs/src/agent.py:graph", "storm": "/deps/__outer_graphs/src/storm.py:graph"}' ``` + ???+ note "Updating your langgraph.json file" + The `langgraph dockerfile` command translates all the configuration in your `langgraph.json` file into Dockerfile commands. When using this command, you will have to re-run it whenever you update your `langgraph.json` file. Otherwise, your changes will not be reflected when you build or run the dockerfile. + === "JS" Generate a Dockerfile for building a LangGraph Cloud API server Docker image. @@ -427,7 +432,7 @@ The LangGraph CLI requires a JSON configuration file with the following keys: Example: ```bash - langgraph dockerfile -c langgraph.json Dockerfile + npx @langchain/langgraph-cli dockerfile -c langgraph.json Dockerfile ``` This generates a Dockerfile that looks similar to: @@ -446,5 +451,5 @@ The LangGraph CLI requires a JSON configuration file with the following keys: RUN (test ! -f /api/langgraph_api/js/build.mts && echo "Prebuild script not found, skipping") || tsx /api/langgraph_api/js/build.mts ``` -???+ note "Updating your langgraph.json file" - The `langgraph dockerfile` command translates all the configuration in your `langgraph.json` file into Dockerfile commands. When using this command, you will have to re-run it whenever you update your `langgraph.json` file. Otherwise, your changes will not be reflected when you build or run the dockerfile. + ???+ note "Updating your langgraph.json file" + The `npx @langchain/langgraph-cli dockerfile` command translates all the configuration in your `langgraph.json` file into Dockerfile commands. When using this command, you will have to re-run it whenever you update your `langgraph.json` file. Otherwise, your changes will not be reflected when you build or run the dockerfile. From 0f1b0bfba352e0f42e125d11b617f944ab4b12cb Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Fri, 17 Jan 2025 20:32:16 +0100 Subject: [PATCH 4/4] typo --- docs/docs/cloud/reference/cli.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/cloud/reference/cli.md b/docs/docs/cloud/reference/cli.md index 875fd7e0f..01286a5e3 100644 --- a/docs/docs/cloud/reference/cli.md +++ b/docs/docs/cloud/reference/cli.md @@ -46,7 +46,7 @@ The LangGraph CLI requires a JSON configuration file with the following keys: | `graphs` | **Required**. Mapping from graph ID to path where the compiled graph or a function that makes a graph is defined. Example:
  • `./your_package/your_file.py:variable`, where `variable` is an instance of `langgraph.graph.state.CompiledStateGraph`
  • `./your_package/your_file.py:make_graph`, where `make_graph` is a function that takes a config dictionary (`langchain_core.runnables.RunnableConfig`) and creates an instance of `langgraph.graph.state.StateGraph` / `langgraph.graph.state.CompiledStateGraph`.
| | `auth` | _(Added in v0.0.11)_ Auth configuration containing the path to your authentication handler. Example: `./your_package/auth.py:auth`, where `auth` is an instance of `langgraph_sdk.Auth`. See [authentication guide](../../concepts/auth.md) for details. | | `env` | Path to `.env` file or a mapping from environment variable to its value. | - | `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields:
  • `index`: Configuration for semantic search indexing with fields:
    • `embed`: Embedding provider (e.g., "openai:text-embedding-3-small") or path to custom embedding function
    • `dims`: Dimension size of the embedding model. Used to initialize the vector table.
    • `fields` (optional): List of fields to index. Defaults to `["$"]`, meaningto index entire documents. Can be specific fields like `["text", "summary", "some.value"]`
| + | `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields:
  • `index`: Configuration for semantic search indexing with fields:
    • `embed`: Embedding provider (e.g., "openai:text-embedding-3-small") or path to custom embedding function
    • `dims`: Dimension size of the embedding model. Used to initialize the vector table.
    • `fields` (optional): List of fields to index. Defaults to `["$"]`, which means to index entire documents. Can be specific fields like `["text", "summary", "some.value"]`
| | `python_version` | `3.11` or `3.12`. Defaults to `3.11`. | | `node_version` | Specify `node_version: 20` to use LangGraph.js. | | `pip_config_file` | Path to `pip` config file. | @@ -58,7 +58,7 @@ The LangGraph CLI requires a JSON configuration file with the following keys: | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `graphs` | **Required**. Mapping from graph ID to path where the compiled graph or a function that makes a graph is defined. Example:
  • `./src/graph.ts:variable`, where `variable` is an instance of `CompiledStateGraph`
  • `./src/graph.ts:makeGraph`, where `makeGraph` is a function that takes a config dictionary (`LangGraphRunnableConfig`) and creates an instance of `StateGraph` / `CompiledStateGraph`.
| | `env` | Path to `.env` file or a mapping from environment variable to its value. | - | `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields:
  • `index`: Configuration for semantic search indexing with fields:
    • `embed`: Embedding provider (e.g., "openai:text-embedding-3-small") or path to custom embedding function
    • `dims`: Dimension size of the embedding model. Used to initialize the vector table.
    • `fields` (optional): List of fields to index. Defaults to `["$"]`, meaning to index entire documents. Can be specific fields like `["text", "summary", "some.value"]`
| + | `store` | Configuration for adding semantic search to the BaseStore. Contains the following fields:
  • `index`: Configuration for semantic search indexing with fields:
    • `embed`: Embedding provider (e.g., "openai:text-embedding-3-small") or path to custom embedding function
    • `dims`: Dimension size of the embedding model. Used to initialize the vector table.
    • `fields` (optional): List of fields to index. Defaults to `["$"]`, which means to index entire documents. Can be specific fields like `["text", "summary", "some.value"]`
| | `node_version` | Specify `node_version: 20` to use LangGraph.js. | | `dockerfile_lines` | Array of additional lines to add to Dockerfile following the import from parent image. |