diff --git a/docs/docs/cloud/reference/cli.md b/docs/docs/cloud/reference/cli.md index 37f4e38d9..01286a5e3 100644 --- a/docs/docs/cloud/reference/cli.md +++ b/docs/docs/cloud/reference/cli.md @@ -4,20 +4,26 @@ 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 + + # Install globally, will be available as `langgraphjs` + npm install -g @langchain/langgraph-cli + ``` + +3. Run the command `langgraph --help` or `npx @langchain/langgraph-cli --help` to confirm that the CLI is working correctly. [](){#langgraph.json} @@ -25,17 +31,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,253 +38,418 @@ 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 -The base command for the LangGraph CLI is `langgraph`. - **Usage** -``` -langgraph [OPTIONS] COMMAND [ARGS] -``` +=== "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`. + + ``` + npx @langchain/langgraph-cli [OPTIONS] COMMAND [ARGS] + ``` + + We recommend using `npx` to always use the latest version of the CLI. ### `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** + + ``` + npx @langchain/langgraph-cli 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** + + ``` + npx @langchain/langgraph-cli 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** + + ``` + npx @langchain/langgraph-cli 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/* -???+ 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 + 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. + + **Usage** + + ``` + npx @langchain/langgraph-cli 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 + npx @langchain/langgraph-cli 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 `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. diff --git a/docs/docs/how-tos/persistence_postgres.ipynb b/docs/docs/how-tos/persistence_postgres.ipynb index 572759289..332c98cae 100644 --- a/docs/docs/how-tos/persistence_postgres.ipynb +++ b/docs/docs/how-tos/persistence_postgres.ipynb @@ -44,7 +44,8 @@ "...\n", "```\n", "\n", - "!!! info \"Setup\n", + "!!! info \"Setup\"", + "\n", " You need to run `.setup()` once on your checkpointer to initialize the database before you can use it." ] }, diff --git a/docs/docs/tutorials/langgraph-platform/local-server.md b/docs/docs/tutorials/langgraph-platform/local-server.md index 8393cb13b..402ee77f7 100644 --- a/docs/docs/tutorials/langgraph-platform/local-server.md +++ b/docs/docs/tutorials/langgraph-platform/local-server.md @@ -250,4 +250,4 @@ Access detailed documentation for development and API usage: - **[LangGraph Server API Reference](../../cloud/reference/api/api_ref.html)**: Explore the LangGraph Server API documentation. - **[Python SDK Reference](../../cloud/reference/sdk/python_sdk_ref.md)**: Explore the Python SDK API Reference. -- **[JS/TS SDK Reference](../../cloud/reference/sdk/js_ts_sdk_ref.md)**: Explore the Python SDK API Reference. +- **[JS/TS SDK Reference](../../cloud/reference/sdk/js_ts_sdk_ref.md)**: Explore the JS/TS SDK API Reference. diff --git a/libs/cli/langgraph_cli/cli.py b/libs/cli/langgraph_cli/cli.py index 98d585f40..17088b713 100644 --- a/libs/cli/langgraph_cli/cli.py +++ b/libs/cli/langgraph_cli/cli.py @@ -605,6 +605,11 @@ def dev( ) from None config_json = langgraph_cli.config.validate_config_file(pathlib.Path(config)) + if config_json.get("node_version"): + raise click.UsageError( + "In-mem server for JS graphs is not supported in this version of the LangGraph CLI. Please use `npx @langchain/langgraph-cli` instead." + ) from None + cwd = os.getcwd() sys.path.append(cwd) dependencies = config_json.get("dependencies", []) diff --git a/libs/cli/langgraph_cli/config.py b/libs/cli/langgraph_cli/config.py index 6fb6b309a..be8cfd085 100644 --- a/libs/cli/langgraph_cli/config.py +++ b/libs/cli/langgraph_cli/config.py @@ -469,10 +469,11 @@ def node_config_to_docker(config_path: pathlib.Path, config: Config, base_image: except OSError: return False - npm, yarn, pnpm = [ + npm, yarn, pnpm, bun = [ test_file("package-lock.json"), test_file("yarn.lock"), test_file("pnpm-lock.yaml"), + test_file("bun.lockb"), ] if yarn: @@ -481,6 +482,8 @@ def node_config_to_docker(config_path: pathlib.Path, config: Config, base_image: install_cmd = "pnpm i --frozen-lockfile" elif npm: install_cmd = "npm ci" + elif bun: + install_cmd = "bun i" else: install_cmd = "npm i" store_config = config.get("store") diff --git a/libs/cli/pyproject.toml b/libs/cli/pyproject.toml index 6595cc7b9..bcb314066 100644 --- a/libs/cli/pyproject.toml +++ b/libs/cli/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langgraph-cli" -version = "0.1.67" +version = "0.1.68" description = "CLI for interacting with LangGraph API" authors = [] license = "MIT" diff --git a/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py b/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py index a14007713..ceeba34b3 100644 --- a/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/langgraph/langgraph/prebuilt/chat_agent_executor.py @@ -635,7 +635,7 @@ def create_react_agent( if ( ( "remaining_steps" not in state - and state["is_last_step"] + and state.get("is_last_step", False) and has_tool_calls ) or ( @@ -672,7 +672,7 @@ def create_react_agent( if ( ( "remaining_steps" not in state - and state["is_last_step"] + and state.get("is_last_step", False) and has_tool_calls ) or ( diff --git a/libs/langgraph/langgraph/utils/config.py b/libs/langgraph/langgraph/utils/config.py index 309c6d6be..55c89b3ba 100644 --- a/libs/langgraph/langgraph/utils/config.py +++ b/libs/langgraph/langgraph/utils/config.py @@ -23,9 +23,11 @@ from langgraph.constants import ( CONFIG_KEY_CHECKPOINT_ID, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_CHECKPOINT_NS, + CONFIG_KEY_STORE, NS_END, NS_SEP, ) +from langgraph.store.base import BaseStore def recast_checkpoint_ns(ns: str) -> str: @@ -332,4 +334,9 @@ def get_config() -> RunnableConfig: if var_config := var_child_runnable_config.get(): return var_config else: - raise RuntimeError("Called get_configurable outside of a runnable context") + raise RuntimeError("Called get_config outside of a runnable context") + + +def get_store() -> BaseStore: + config = get_config() + return config[CONF][CONFIG_KEY_STORE] diff --git a/libs/langgraph/pyproject.toml b/libs/langgraph/pyproject.toml index a0b366809..742c9bd0e 100644 --- a/libs/langgraph/pyproject.toml +++ b/libs/langgraph/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langgraph" -version = "0.2.64" +version = "0.2.65" description = "Building stateful, multi-actor applications with LLMs" authors = [] license = "MIT"