diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..fcf1bd801 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# and +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/_lint.yml b/.github/workflows/_lint.yml index fc50fef5c..585c232df 100644 --- a/.github/workflows/_lint.yml +++ b/.github/workflows/_lint.yml @@ -49,7 +49,7 @@ jobs: - name: Get .mypy_cache to speed up mypy if: steps.changed-files.outputs.all - uses: actions/cache@v3 + uses: actions/cache@v4 env: SEGMENT_DOWNLOAD_TIMEOUT_MIN: "2" with: @@ -75,7 +75,7 @@ jobs: - name: Get .mypy_cache_test to speed up mypy if: steps.changed-files.outputs.all - uses: actions/cache@v3 + uses: actions/cache@v4 env: SEGMENT_DOWNLOAD_TIMEOUT_MIN: "2" with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6be1a569b..726c31f69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,9 +166,9 @@ jobs: run: working-directory: ${{ matrix.working-directory }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Node.js (LTS) - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" @@ -192,9 +192,9 @@ jobs: run: working-directory: ${{ matrix.working-directory }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Node.js (LTS) - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index dcf4db042..acd828488 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -145,7 +145,7 @@ jobs: - name: Configure GitHub Pages if: github.ref == 'refs/heads/main' - uses: actions/configure-pages@v4 + uses: actions/configure-pages@v5 - name: Upload Pages Artifact # if: github.ref == 'refs/heads/main' diff --git a/.github/workflows/release_js.yml b/.github/workflows/release_js.yml index 670d2c024..70617d6f1 100644 --- a/.github/workflows/release_js.yml +++ b/.github/workflows/release_js.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 # JS Build - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1231673d5..a4e9a3eca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -109,7 +109,7 @@ Here are some high-level tips on writing a good how-to guide: LangGraph's conceptual guides fall under the **Explanation** quadrant of Diataxis. They should cover LangChain terms and concepts in a more abstract way than how-to guides or tutorials, and should be geared towards curious users interested in gaining a deeper understanding of the framework. Try to avoid excessively large code examples. The goal here is to -impart perspective to the user rather than to finish a practical project. These guides should cover **why** things work they way they do. +impart perspective to the user rather than to finish a practical project. These guides should cover **why** things work the way they do. To quote the Diataxis website: diff --git a/docs/_scripts/notebook_hooks.py b/docs/_scripts/notebook_hooks.py index 0cebf7b75..30545408e 100644 --- a/docs/_scripts/notebook_hooks.py +++ b/docs/_scripts/notebook_hooks.py @@ -1,9 +1,16 @@ +"""mkdocs hooks for adding custom logic to documentation pipeline. + +Lifecycle events: https://www.mkdocs.org/dev-guide/plugins/#events +""" + import logging import os import posixpath import re from typing import Any, Dict +from bs4 import BeautifulSoup +from mkdocs.config.defaults import MkDocsConfig from mkdocs.structure.files import Files, File from mkdocs.structure.pages import Page @@ -101,8 +108,7 @@ REDIRECT_MAP = { "how-tos/deploy-self-hosted.md": "cloud/deployment/self_hosted_data_plane.md", "concepts/self_hosted.md": "concepts/langgraph_self_hosted_data_plane.md", # assistant redirects - "cloud/how-tos/assistant_versioning.md": "cloud/how-tos/configuration_cloud.md" - + "cloud/how-tos/assistant_versioning.md": "cloud/how-tos/configuration_cloud.md", } @@ -292,7 +298,7 @@ Redirecting... """ -def write_html(site_dir, old_path, new_path): +def _write_html(site_dir, old_path, new_path): """Write an HTML file in the site_dir with a meta redirect to the new page""" # Determine all relevant paths old_path_abs = os.path.join(site_dir, old_path) @@ -308,6 +314,52 @@ def write_html(site_dir, old_path, new_path): f.write(content) +def _inject_gtm(html: str) -> str: + """Inject Google Tag Manager code into the HTML. + + Code to inject Google Tag Manager noscript tag immediately after . + + This is done via hooks rather than via a template because the MkDocs material + theme does not seem to allow placing the code immediately after the tag + without modifying the template files directly. + + Args: + html: The HTML content to modify. + + Returns: + The modified HTML content with GTM code injected. + """ + # Code was copied from Google Tag Manager setup instructions. + gtm_code = """ + + + +""" + soup = BeautifulSoup(html, "html.parser") + body = soup.body + if body: + # Insert the GTM code as raw HTML at the top of + body.insert(0, BeautifulSoup(gtm_code, "html.parser")) + return str(soup) + else: + return html # fallback if no found + + +def on_post_page(output: str, page: Page, config: MkDocsConfig) -> str: + """Inject Google Tag Manager noscript tag immediately after . + + Args: + output: The HTML output of the page. + page: The page instance. + config: The MkDocs configuration object. + + Returns: + modified HTML output with GTM code injected. + """ + return _inject_gtm(output) + + # Create HTML files for redirects after site dir has been built def on_post_build(config): use_directory_urls = config.get("use_directory_urls") @@ -324,4 +376,4 @@ def on_post_build(config): + hash + suffix ) - write_html(config["site_dir"], old_html_path, new_html_path) + _write_html(config["site_dir"], old_html_path, new_html_path) diff --git a/docs/docs/agents/mcp.md b/docs/docs/agents/mcp.md index dbe3d092e..919f5a967 100644 --- a/docs/docs/agents/mcp.md +++ b/docs/docs/agents/mcp.md @@ -38,7 +38,7 @@ client = MultiServerMCPClient( "transport": "stdio", }, "weather": { - # Ensure your start your weather server on port 8000 + # Ensure you start your weather server on port 8000 "url": "http://localhost:8000/mcp", "transport": "streamable_http", } diff --git a/docs/docs/agents/memory.md b/docs/docs/agents/memory.md index 518341703..716429f51 100644 --- a/docs/docs/agents/memory.md +++ b/docs/docs/agents/memory.md @@ -88,7 +88,7 @@ ny_response = agent.invoke( When the agent is invoked the second time with the same `thread_id`, the original message history from the first conversation is automatically included, allowing the agent to infer that the user is asking specifically about the **weather** in New York. -!!! Note "LangGraph Platform providers a production-ready checkpointer" +!!! Note "LangGraph Platform provides a production-ready checkpointer" If you're using [LangGraph Platform](./deployment.md), during deployment your checkpointer will be automatically configured to use a production-ready database. diff --git a/docs/docs/agents/multi-agent.md b/docs/docs/agents/multi-agent.md index 51a35bbac..54ba13c9c 100644 --- a/docs/docs/agents/multi-agent.md +++ b/docs/docs/agents/multi-agent.md @@ -9,7 +9,7 @@ hide: # Multi-agent -A single agent might struggle if it needs to specialize in multiple domains or manage many tools. To tackle this, you can break your agent into smaller, independent agents and composing them into a [multi-agent system](../concepts/multi_agent.md). +A single agent might struggle if it needs to specialize in multiple domains or manage many tools. To tackle this, you can break your agent into smaller, independent agents and compose them into a [multi-agent system](../concepts/multi_agent.md). In multi-agent systems, agents need to communicate between each other. They do so via [handoffs](#handoffs) — a primitive that describes which agent to hand control to and the payload to send to that agent. diff --git a/docs/docs/cloud/deployment/custom_docker.md b/docs/docs/cloud/deployment/custom_docker.md index 8bc520f12..d1db7eeff 100644 --- a/docs/docs/cloud/deployment/custom_docker.md +++ b/docs/docs/cloud/deployment/custom_docker.md @@ -16,4 +16,4 @@ Users can add an array of additional lines to add to the Dockerfile following th } ``` -This would install the system packages required to use Pillow if we were working with `jpeq` or `png` image formats. \ No newline at end of file +This would install the system packages required to use Pillow if we were working with `jpeg` or `png` image formats. \ No newline at end of file diff --git a/docs/docs/cloud/deployment/graph_rebuild.md b/docs/docs/cloud/deployment/graph_rebuild.md index eb5b8a322..75dc26377 100644 --- a/docs/docs/cloud/deployment/graph_rebuild.md +++ b/docs/docs/cloud/deployment/graph_rebuild.md @@ -20,7 +20,7 @@ my-app/ |-- openai_agent.py # code for your graph ``` -where the graph is defined in `openai_agent.py`. +where the graph is defined in `openai_agent.py`. ### No rebuild @@ -28,11 +28,11 @@ In the standard LangGraph API configuration, the server uses the compiled graph ```python from langchain_openai import ChatOpenAI -from langgraph.graph import END, START, MessageGraph +from langgraph.graph import END, START, StateGraph, MessagesState model = ChatOpenAI(temperature=0) -graph_workflow = MessageGraph() +graph_workflow = StateGraph(MessagesState) graph_workflow.add_node("agent", model) graph_workflow.add_edge("agent", END) @@ -61,7 +61,7 @@ To make your graph rebuild on each new run with custom configuration, you need t from typing import Annotated from typing_extensions import TypedDict from langchain_openai import ChatOpenAI -from langgraph.graph import END, START, MessageGraph +from langgraph.graph import END, START from langgraph.graph.state import StateGraph from langgraph.graph.message import add_messages from langgraph.prebuilt import ToolNode @@ -144,4 +144,4 @@ Finally, you need to specify the path to your graph-making function (`make_graph } ``` -See more info on LangGraph API configuration file [here](../reference/cli.md#configuration-file) \ No newline at end of file +See more info on LangGraph API configuration file [here](../reference/cli.md#configuration-file) diff --git a/docs/docs/cloud/deployment/self_hosted_control_plane.md b/docs/docs/cloud/deployment/self_hosted_control_plane.md index 2af5925bd..98165e1ee 100644 --- a/docs/docs/cloud/deployment/self_hosted_control_plane.md +++ b/docs/docs/cloud/deployment/self_hosted_control_plane.md @@ -41,7 +41,8 @@ Before deploying, review the [conceptual guide for the Self-Hosted Control Plane pullPolicy: IfNotPresent tag: "aa9dff4" -1. In your `values.yaml` file, enable the `langgraphPlatform` option. Note that you must also have a valid ingress setup: +1. In your `langsmith_config.yaml` file, enable the `langgraphPlatform` option. Note that you must also have a valid ingress setup: + config: langgraphPlatform: enabled: true diff --git a/docs/docs/cloud/deployment/setup.md b/docs/docs/cloud/deployment/setup.md index 51786af53..4fc52c7e5 100644 --- a/docs/docs/cloud/deployment/setup.md +++ b/docs/docs/cloud/deployment/setup.md @@ -95,7 +95,7 @@ my-app/ ## Define Graphs -Implement your graphs! Graphs can be defined in a single file or multiple files. Make note of the variable names of each [CompiledGraph][langgraph.graph.graph.CompiledGraph] to be included in the LangGraph application. The variable names will be used later when creating the [LangGraph configuration file](../reference/cli.md#configuration-file). +Implement your graphs! Graphs can be defined in a single file or multiple files. Make note of the variable names of each [CompiledStateGraph][langgraph.graph.state.CompiledStateGraph] to be included in the LangGraph application. The variable names will be used later when creating the [LangGraph configuration file](../reference/cli.md#configuration-file). Example `agent.py` file, which shows how to import from other modules you define (code for the modules is not shown here, please see [this repository](https://github.com/langchain-ai/langgraph-example) to see their implementation): diff --git a/docs/docs/cloud/deployment/setup_pyproject.md b/docs/docs/cloud/deployment/setup_pyproject.md index 23a592f6a..033ab7763 100644 --- a/docs/docs/cloud/deployment/setup_pyproject.md +++ b/docs/docs/cloud/deployment/setup_pyproject.md @@ -108,7 +108,7 @@ my-app/ ## Define Graphs -Implement your graphs! Graphs can be defined in a single file or multiple files. Make note of the variable names of each [CompiledGraph][langgraph.graph.graph.CompiledGraph] to be included in the LangGraph application. The variable names will be used later when creating the [LangGraph configuration file](../reference/cli.md#configuration-file). +Implement your graphs! Graphs can be defined in a single file or multiple files. Make note of the variable names of each [CompiledStateGraph][langgraph.graph.state.CompiledStateGraph] to be included in the LangGraph application. The variable names will be used later when creating the [LangGraph configuration file](../reference/cli.md#configuration-file). Example `agent.py` file, which shows how to import from other modules you define (code for the modules is not shown here, please see [this repository](https://github.com/langchain-ai/langgraph-example-pyproject) to see their implementation): diff --git a/docs/docs/cloud/how-tos/use_stream_react.md b/docs/docs/cloud/how-tos/use_stream_react.md index 9329d5c79..3b9a77abf 100644 --- a/docs/docs/cloud/how-tos/use_stream_react.md +++ b/docs/docs/cloud/how-tos/use_stream_react.md @@ -1,8 +1,8 @@ -# How to integrate LangGraph into your React application +How to integrate LangGraph into your React application# How to integrate LangGraph into your React application -!!! info "Prerequisites" +!!! info "Prerequisites" - - [LangGraph Platform](../../concepts/langgraph_platform.md) + - [LangGraph Platform](../../concepts/langgraph_platform.md) - [LangGraph Server](../../concepts/langgraph_server.md) The `useStream()` React hook provides a seamless way to integrate LangGraph into your React applications. It handles all the complexities of streaming, state management, and branching logic, letting you focus on building great chat experiences. @@ -113,6 +113,115 @@ export default function App() { } ``` +### Resume a stream after page refresh + +The `useStream()` hook can automatically resume an ongoing run upon mounting by setting `reconnectOnMount: true`. This is useful for continuing a stream after a page refresh, ensuring no messages and events generated during the downtime are lost. + +```tsx +const thread = useStream<{ messages: Message[] }>({ + apiUrl: "http://localhost:2024", + assistantId: "agent", + reconnectOnMount: true, +}); +``` + +By default the ID of the created run is stored in `window.sessionStorage`, which can be swapped by passing a custom storage in `reconnectOnMount` instead. The storage is used to persist the in-flight run ID for a thread (under `lg:stream:${threadId}` key). + +```tsx +const thread = useStream<{ messages: Message[] }>({ + apiUrl: "http://localhost:2024", + assistantId: "agent", + reconnectOnMount: () => window.localStorage, +}); +``` + +You can also manually manage the resuming process by using the run callbacks to persist the run metadata and the `joinStream` function to resume the stream. Make sure to pass `streamResumable: true` when creating the run; otherwise some events might be lost. + +````tsx +import type { Message } from "@langchain/langgraph-sdk"; +import { useStream } from "@langchain/langgraph-sdk/react"; +import { useCallback, useState, useEffect, useRef } from "react"; + +export default function App() { + const [threadId, onThreadId] = useSearchParam("threadId"); + + const thread = useStream<{ messages: Message[] }>({ + apiUrl: "http://localhost:2024", + assistantId: "agent", + + threadId, + onThreadId, + + onCreated: (run) => { + window.sessionStorage.setItem(`resume:${run.thread_id}`, run.run_id); + }, + onFinish: (_, run) => { + window.sessionStorage.removeItem(`resume:${run?.thread_id}`); + }, + }); + + // Ensure that we only join the stream once per thread. + const joinedThreadId = useRef(null); + useEffect(() => { + if (!threadId) return; + + const resume = window.sessionStorage.getItem(`resume:${threadId}`); + if (resume && joinedThreadId.current !== threadId) { + thread.joinStream(resume); + joinedThreadId.current = threadId; + } + }, [threadId]); + + return ( +
{ + e.preventDefault(); + const form = e.target as HTMLFormElement; + const message = new FormData(form).get("message") as string; + thread.submit( + { messages: [{ type: "human", content: message }] }, + { streamResumable: true } + ); + }} + > +
+ {thread.messages.map((message) => ( +
{message.content as string}
+ ))} +
+ + +
+ ); +} + +// Utility method to retrieve and persist data in URL as search param +function useSearchParam(key: string) { + const [value, setValue] = useState(() => { + const params = new URLSearchParams(window.location.search); + return params.get(key) ?? null; + }); + + const update = useCallback( + (value: string | null) => { + setValue(value); + + const url = new URL(window.location.href); + if (value == null) { + url.searchParams.delete(key); + } else { + url.searchParams.set(key, value); + } + + window.history.pushState({}, "", url.toString()); + }, + [key] + ); + + return [value, update] as const; +} +``` + ### Thread Management Keep track of conversations with built-in thread management. You can access the current thread ID and get notified when new threads are created: @@ -127,7 +236,7 @@ const thread = useStream<{ messages: Message[] }>({ threadId: threadId, onThreadId: setThreadId, }); -``` +```` We recommend storing the `threadId` in your URL's query parameters to let users resume conversations after page refreshes. diff --git a/docs/docs/concepts/application_structure.md b/docs/docs/concepts/application_structure.md index 47b03c6d7..a23b463ac 100644 --- a/docs/docs/concepts/application_structure.md +++ b/docs/docs/concepts/application_structure.md @@ -32,7 +32,7 @@ Below are examples of directory structures for Python and JavaScript application │ ├── utils # utilities for your graph │ │ ├── __init__.py │ │ ├── tools.py # tools for your graph - │ │ ├── nodes.py # node functions for you graph + │ │ ├── nodes.py # node functions for your graph │ │ └── state.py # state definition of your graph │ ├── __init__.py │ └── agent.py # code for constructing your graph diff --git a/docs/docs/concepts/assistants.md b/docs/docs/concepts/assistants.md index 7b7bb44cd..1e28b4465 100644 --- a/docs/docs/concepts/assistants.md +++ b/docs/docs/concepts/assistants.md @@ -26,4 +26,4 @@ Once you've created an assistant, subsequent edits to that assistant will create ## Learn more -* The LangGraph Cloud API provides several endpoints for creating and managing assistants their versions. See the [API reference](../cloud/reference/api/api_ref.html#tag/assistants) for more details. \ No newline at end of file +* The LangGraph Cloud API provides several endpoints for creating and managing assistants and their versions. See the [API reference](../cloud/reference/api/api_ref.html#tag/assistants) for more details. \ No newline at end of file diff --git a/docs/docs/concepts/deployment_options.md b/docs/docs/concepts/deployment_options.md index 81bbdbe03..5b776e3b1 100644 --- a/docs/docs/concepts/deployment_options.md +++ b/docs/docs/concepts/deployment_options.md @@ -59,7 +59,7 @@ For more information, please see: !!! info "Important" The Self-Hosted Control Plane deployment option is currently in beta stage and requires an [Enterprise](../concepts/plans.md) plan. -The [Self-Hosted Control Plane](./langgraph_self_hosted_control_plane.md) deployment option is a fully self-hosted model for deployment where you manage the [control plane](./langgraph_control_plane.md) and [data plane](./langgraph_data_plane.md) in your cloud. This option give you full control and responsibility of the control plane and data plane infrastructure. +The [Self-Hosted Control Plane](./langgraph_self_hosted_control_plane.md) deployment option is a fully self-hosted model for deployment where you manage the [control plane](./langgraph_control_plane.md) and [data plane](./langgraph_data_plane.md) in your cloud. This option gives you full control and responsibility of the control plane and data plane infrastructure. Build a Docker image using the [LangGraph CLI](./langgraph_cli.md) and deploy your LangGraph Server from the [control plane UI](./langgraph_control_plane.md#control-plane-ui). diff --git a/docs/docs/concepts/faq.md b/docs/docs/concepts/faq.md index c274952b3..db244fd45 100644 --- a/docs/docs/concepts/faq.md +++ b/docs/docs/concepts/faq.md @@ -59,8 +59,8 @@ Yes! You can use LangGraph with any LLMs. The main reason we use LLMs that suppo Yes! LangGraph is totally ambivalent to what LLMs are used under the hood. The main reason we use closed LLMs in most of the tutorials is that they seamlessly support tool calling, while OSS LLMs often don't. But tool calling is not necessary (see [this section](#does-langgraph-work-with-llms-that-dont-support-tool-calling)) so you can totally use LangGraph with OSS LLMs. -## Can I use LangGraph Studio without logging to LangSmith +## Can I use LangGraph Studio without logging in to LangSmith Yes! You can use the [development version of LangGraph Server](../tutorials/langgraph-platform/local-server.md) to run the backend locally. This will connect to the studio frontend hosted as part of LangSmith. -If you set an environment variable of `LANGSMITH_TRACING=false` then no traces will be sent to LangSmith. \ No newline at end of file +If you set an environment variable of `LANGSMITH_TRACING=false`, then no traces will be sent to LangSmith. \ No newline at end of file diff --git a/docs/docs/concepts/langgraph_data_plane.md b/docs/docs/concepts/langgraph_data_plane.md index 47195a8ce..79188118d 100644 --- a/docs/docs/concepts/langgraph_data_plane.md +++ b/docs/docs/concepts/langgraph_data_plane.md @@ -9,7 +9,7 @@ The term "data plane" is used broadly to refer to [LangGraph Servers](./langgrap ## Server Infrastructure -In addition to the [LangGraph Server](./langgraph_server.md) itself, the following infrastructure for each server are also included in the broad definition of "data plane": +In addition to the [LangGraph Server](./langgraph_server.md) itself, the following infrastructure components for each server are also included in the broad definition of "data plane": - Postgres - Redis @@ -44,7 +44,7 @@ All runs in a LangGraph Server are executed by a pool of background workers that ### Ephemeral metadata -Runs in a LangGraph Server may be retried for specific failures (currently only for transient Postgres errors encountered during the run). In order to limit the number of retries (currently limited to 3 attempts per run) we record the attempt number in a Redis string when is picked up. This contains no run-specific info other than its ID, and expires after a short delay. +Runs in a LangGraph Server may be retried for specific failures (currently only for transient Postgres errors encountered during the run). In order to limit the number of retries (currently limited to 3 attempts per run) we record the attempt number in a Redis string when it is picked up. This contains no run-specific info other than its ID, and expires after a short delay. ## Data Plane Features @@ -62,7 +62,7 @@ For CPU utilization, the autoscaler targets 75% utilization. This means the auto For number of pending runs, the autoscaler targets 10 pending runs. For example, if the current number of containers is 1, but the number of pending runs in 20, the autoscaler will scale up the deployment to 2 containers (20 pending runs / 2 containers = 10 pending runs per container). -Each metric is computed independently and the autoscaler will determine the scaling action based on the metric that results in the most number of containers. +Each metric is computed independently and the autoscaler will determine the scaling action based on the metric that results in the largest number of containers. Scale down actions are delayed for 30 minutes before any action is taken. In other words, if the autoscaler decides to scale down a deployment, it will first wait for 30 minutes before scaling down. After 30 minutes, the metrics are recomputed and the deployment will scale down if the recomputed metrics result in a lower number of containers than the current number. Otherwise, the deployment remains scaled up. This "cool down" period ensures that deployments do not scale up and down too frequently. diff --git a/docs/docs/concepts/langgraph_platform.md b/docs/docs/concepts/langgraph_platform.md index 7f81a3e29..780d7f6a2 100644 --- a/docs/docs/concepts/langgraph_platform.md +++ b/docs/docs/concepts/langgraph_platform.md @@ -9,7 +9,7 @@ Develop, deploy, scale, and manage agents with **LangGraph Platform** — the pu !!! tip "Get started with LangGraph Platform" - Check out the [LangGraph Platform quickstart](../tutorials/langgraph-platform/local-server.md) for instructions on how to use LangGraph Platform run a LangGraph application locally. + Check out the [LangGraph Platform quickstart](../tutorials/langgraph-platform/local-server.md) for instructions on how to use LangGraph Platform to run a LangGraph application locally. ## Why use LangGraph Platform? @@ -33,4 +33,4 @@ LangGraph Platform makes it easy to get your agent running in production — wh - **[LangGraph Studio](./langgraph_studio.md)**: Enables visualization, interaction, and debugging of agentic systems that implement the LangGraph Server API protocol. Studio also integrates with LangSmith to enable tracing, evaluation, and prompt engineering. -- **[Deployment](./deployment_options.md)**: There are four ways to deploy on LangGraph Platform: [Cloud Saas](../concepts/langgraph_cloud.md), [Self-Hosted Data Plane](../concepts/langgraph_self_hosted_data_plane.md), [Self-Hosted Control Plane](../concepts/langgraph_self_hosted_control_plane.md), and [Standalone Container](../concepts/langgraph_standalone_container.md). \ No newline at end of file +- **[Deployment](./deployment_options.md)**: There are four ways to deploy on LangGraph Platform: [Cloud SaaS](../concepts/langgraph_cloud.md), [Self-Hosted Data Plane](../concepts/langgraph_self_hosted_data_plane.md), [Self-Hosted Control Plane](../concepts/langgraph_self_hosted_control_plane.md), and [Standalone Container](../concepts/langgraph_standalone_container.md). \ No newline at end of file diff --git a/docs/docs/concepts/langgraph_self_hosted_control_plane.md b/docs/docs/concepts/langgraph_self_hosted_control_plane.md index 000c1257c..c7bf31016 100644 --- a/docs/docs/concepts/langgraph_self_hosted_control_plane.md +++ b/docs/docs/concepts/langgraph_self_hosted_control_plane.md @@ -9,10 +9,12 @@ There are two versions of the self-hosted deployment: [Self-Hosted Data Plane](. - You use `langgraph-cli` and/or [LangGraph Studio](./langgraph_studio.md) app to test graph locally. - You use `langgraph build` command to build image. +- You have a Self-Hosted LangSmith instance deployed. +- You are using Ingress for your LangSmith instance. All agents will be deployed as Kubernetes services behind this ingress. ## Self-Hosted Control Plane -The [Self-Hosted Control Plane](./langgraph_self_hosted_control_plane.md) deployment option is a fully self-hosted model for deployment where you manage the [control plane](./langgraph_control_plane.md) and [data plane](./langgraph_data_plane.md) in your cloud. This option give you full control and responsibility of the control plane and data plane infrastructure. +The [Self-Hosted Control Plane](./langgraph_self_hosted_control_plane.md) deployment option is a fully self-hosted model for deployment where you manage the [control plane](./langgraph_control_plane.md) and [data plane](./langgraph_data_plane.md) in your cloud. This option gives you full control and responsibility of the control plane and data plane infrastructure. | | [Control plane](../concepts/langgraph_control_plane.md) | [Data plane](../concepts/langgraph_data_plane.md) | |-------------------|-------------------|------------| @@ -29,4 +31,4 @@ The [Self-Hosted Control Plane](./langgraph_self_hosted_control_plane.md) deploy - **Kubernetes**: The Self-Hosted Control Plane deployment option supports deploying control plane and data plane infrastructure to any Kubernetes cluster. !!! tip - If you would like to deploy to Kubernetes, you can use this [Helm chart](https://github.com/langchain-ai/helm/blob/main/charts/langgraph-cloud/README.md). \ No newline at end of file + If you would like to enable this on your LangSmith instance, please follow the [Self-Hosted Control Plane deployment guide](../deployment/self_hosted_control_plane.md). \ No newline at end of file diff --git a/docs/docs/concepts/langgraph_server.md b/docs/docs/concepts/langgraph_server.md index 57fb8d93c..47f7dacd5 100644 --- a/docs/docs/concepts/langgraph_server.md +++ b/docs/docs/concepts/langgraph_server.md @@ -26,7 +26,7 @@ Feature Differences: |-------|------------|------------| | [Cron Jobs](../cloud/concepts/cron_jobs.md) |❌|✅| | [Custom Authentication](../concepts/auth.md) |❌|✅| -| [Deployment options](../concepts/deployment_options.md) | Standalone container | Cloud Saas, Self-Hosted Data Plane, Self-Hosted Control Plane, Standalone container +| [Deployment options](../concepts/deployment_options.md) | Standalone container | Cloud SaaS, Self-Hosted Data Plane, Self-Hosted Control Plane, Standalone container ## Application structure diff --git a/docs/docs/concepts/langgraph_studio.md b/docs/docs/concepts/langgraph_studio.md index 988219fb9..cdd8ef00c 100644 --- a/docs/docs/concepts/langgraph_studio.md +++ b/docs/docs/concepts/langgraph_studio.md @@ -21,7 +21,7 @@ Key features of LangGraph Studio: - Visualize your graph architecture - [Run and interact with your agent](../cloud/how-tos/invoke_studio.md) -- [Manage assistants](../cloud/how-tos/studio/manage_assistants.md.md) +- [Manage assistants](../cloud/how-tos/studio/manage_assistants.md) - [Manage threads](../cloud/how-tos/threads_studio.md) - [Iterate on prompts](../cloud/how-tos/iterate_graph_studio.md) - Manage [long term memory](memory.md) @@ -33,7 +33,7 @@ Studio supports two modes: ### Graph mode -Graph mode exposes the full feature-set of Studio and is useful when you would like as many details about the execution of your agent, including the nodes traversed, intermediate states, and LangSmith integrations (such as adding to datasets an playground). +Graph mode exposes the full feature-set of Studio and is useful when you would like as many details about the execution of your agent, including the nodes traversed, intermediate states, and LangSmith integrations (such as adding to datasets and playground). ### Chat mode diff --git a/docs/docs/concepts/low_level.md b/docs/docs/concepts/low_level.md index bd75f026e..755a9e4ba 100644 --- a/docs/docs/concepts/low_level.md +++ b/docs/docs/concepts/low_level.md @@ -105,7 +105,7 @@ graph.invoke({"user_input":"My"}) There are two subtle and important points to note here: -1. We pass `state: InputState` as the input schema to `node_1`. But, we write out to `foo`, a channel in `OverallState`. How can we write out to a state channel that is not included in the input schema? This is because a node _can write to any state channel in the graph state._ The graph state is the union of of the state channels defined at initialization, which includes `OverallState` and the filters `InputState` and `OutputState`. +1. We pass `state: InputState` as the input schema to `node_1`. But, we write out to `foo`, a channel in `OverallState`. How can we write out to a state channel that is not included in the input schema? This is because a node _can write to any state channel in the graph state._ The graph state is the union of the state channels defined at initialization, which includes `OverallState` and the filters `InputState` and `OutputState`. 2. We initialize the graph with `StateGraph(OverallState,input=InputState,output=OutputState)`. So, how can we write to `PrivateState` in `node_2`? How does the graph gain access to this schema if it was not passed in the `StateGraph` initialization? We can do this because _nodes can also declare additional state channels_ as long as the state schema definition exists. In this case, the `PrivateState` schema is defined, so we can add `bar` as a new state channel in the graph and write to it. @@ -167,7 +167,7 @@ In addition to keeping track of message IDs, the `add_messages` function will al {"messages": [{"type": "human", "content": "message"}]} ``` -Since the state updates are always deserialized into LangChain `Messages` when using `add_messages`, you should use dot notation to access message attributes, like `state["messages"][-1].content`. Below is an example of a graph that uses `add_messages` as it's reducer function. +Since the state updates are always deserialized into LangChain `Messages` when using `add_messages`, you should use dot notation to access message attributes, like `state["messages"][-1].content`. Below is an example of a graph that uses `add_messages` as its reducer function. ```python from langchain_core.messages import AnyMessage diff --git a/docs/docs/how-tos/human_in_the_loop/time-travel.ipynb b/docs/docs/how-tos/human_in_the_loop/time-travel.ipynb index a01689613..ba36f4479 100644 --- a/docs/docs/how-tos/human_in_the_loop/time-travel.ipynb +++ b/docs/docs/how-tos/human_in_the_loop/time-travel.ipynb @@ -12,9 +12,9 @@ "\n", "\n", "1. **Run the graph** with initial inputs using `invoke` or `stream` APIs.\n", - "2. **Identify a checkpoint in an existing thread**: Use the [`get_state_history()`][langgraph.graph.graph.CompiledGraph.get_state_history] method to retrieve the execution history for a specific `thread_id` and locate the desired `checkpoint_id`. \n", + "2. **Identify a checkpoint in an existing thread**: Use the [`get_state_history()`][langgraph.graph.state.CompiledStateGraph.get_state_history] method to retrieve the execution history for a specific `thread_id` and locate the desired `checkpoint_id`. \n", " Alternatively, set a [breakpoint](../../../concepts/breakpoints/) before the node(s) where you want execution to pause. You can then find the most recent checkpoint recorded up to that breakpoint.\n", - "3. **(Optional) modify the graph state**: Use the [`update_state`][langgraph.graph.graph.CompiledGraph.update_state] method to modify the graph’s state at the checkpoint and resume execution from alternative state.\n", + "3. **(Optional) modify the graph state**: Use the [`update_state`][langgraph.graph.state.CompiledStateGraph.update_state] method to modify the graph’s state at the checkpoint and resume execution from alternative state.\n", "4. **Resume execution from the checkpoint**: Use the `invoke` or `stream` APIs with an input of `None` and a configuration containing the appropriate `thread_id` and `checkpoint_id`.\n", "\n", "## Example\n", diff --git a/docs/docs/reference/graphs.md b/docs/docs/reference/graphs.md index 53ecc68db..e7473cbf8 100644 --- a/docs/docs/reference/graphs.md +++ b/docs/docs/reference/graphs.md @@ -36,41 +36,6 @@ - aget_subgraphs - with_config -::: langgraph.graph.graph.Graph - options: - show_if_no_docstring: true - show_root_heading: true - show_root_full_path: false - members: - - add_node - - add_edge - - add_conditional_edges - - compile - -::: langgraph.graph.graph.CompiledGraph - options: - show_if_no_docstring: true - show_root_heading: true - show_root_full_path: false - members: - - stream - - astream - - invoke - - ainvoke - - get_state - - aget_state - - get_state_history - - aget_state_history - - update_state - - aupdate_state - - bulk_update_state - - abulk_update_state - - get_graph - - aget_graph - - get_subgraphs - - aget_subgraphs - - with_config - ::: langgraph.graph.message options: members: diff --git a/docs/docs/tutorials/extraction/retries.ipynb b/docs/docs/tutorials/extraction/retries.ipynb index de081052c..ccd552e3a 100644 --- a/docs/docs/tutorials/extraction/retries.ipynb +++ b/docs/docs/tutorials/extraction/retries.ipynb @@ -89,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "baf669a0-04ee-492d-80d8-8fcb658ed128", "metadata": {}, "outputs": [], @@ -313,8 +313,8 @@ "\n", " builder.add_edge(\"finalizer\", END)\n", "\n", - " # These functions let the step be used in a MessageGraph\n", - " # or a StateGraph with 'messages' as the key.\n", + " # These functions let the step be used in a\n", + " # StateGraph with 'messages' as the key.\n", " def encode(x: Union[Sequence[AnyMessage], PromptValue]) -> dict:\n", " \"\"\"Ensure the input is the correct format.\"\"\"\n", " if isinstance(x, PromptValue):\n", diff --git a/docs/docs/tutorials/get-started/2-add-tools.md b/docs/docs/tutorials/get-started/2-add-tools.md index cd9ee7cd7..33accd9a8 100644 --- a/docs/docs/tutorials/get-started/2-add-tools.md +++ b/docs/docs/tutorials/get-started/2-add-tools.md @@ -1,6 +1,6 @@ # Add tools -To handle queries you chatbot can't answer "from memory", integrate a web search tool. The chatbot can use this tool to find relevant information and provide better responses. +To handle queries that your chatbot can't answer "from memory", integrate a web search tool. The chatbot can use this tool to find relevant information and provide better responses. !!! note diff --git a/docs/docs/tutorials/rag/langgraph_adaptive_rag.ipynb b/docs/docs/tutorials/rag/langgraph_adaptive_rag.ipynb index f7e7d453a..e8c8a95d3 100644 --- a/docs/docs/tutorials/rag/langgraph_adaptive_rag.ipynb +++ b/docs/docs/tutorials/rag/langgraph_adaptive_rag.ipynb @@ -516,11 +516,13 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "b76b5ec3-0720-443d-85b1-c0e79659ca0a", "metadata": {}, "outputs": [], "source": [ + "from pprint import pprint\n", + "\n", "from langchain.schema import Document\n", "\n", "\n", @@ -796,7 +798,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "id": "29acc541-d726-4b75-84d1-a215845fe88a", "metadata": {}, "outputs": [ @@ -823,8 +825,6 @@ } ], "source": [ - "from pprint import pprint\n", - "\n", "# Run\n", "inputs = {\n", " \"question\": \"What player at the Bears expected to draft first in the 2024 NFL draft?\"\n", diff --git a/docs/overrides/main.html b/docs/overrides/main.html index 4b59238dc..12a20dfbb 100644 --- a/docs/overrides/main.html +++ b/docs/overrides/main.html @@ -1,5 +1,16 @@ {% extends "base.html" %} +{% block analytics %} + + + +{% endblock %} + + {% block extrahead %} {% endblock %} - {% block content %}