Compare commits

..
Author SHA1 Message Date
Arjun Natarajan f393d7ac8b consolidate installing deps 2025-05-14 10:15:11 -04:00
lc-arjunandGitHub c1a4d77bd4 fix: update langgraph cli to include js and update template app description (#4687) 2025-05-14 07:04:04 -07:00
6e3eb6370e Update docs/docs/tutorials/langgraph-platform/local-server.md
Co-authored-by: William FH <13333726+hinthornw@users.noreply.github.com>
2025-05-14 06:56:36 -07:00
Arjun Natarajan ab0fa9dc77 use npx to install cli instead 2025-05-14 09:49:42 -04:00
Arjun Natarajan 5f821cf584 fix: update langgraph cli to include js and update template app description 2025-05-14 09:41:37 -04:00
lc-arjunandGitHub c7691081d1 fix(docs): template app names (#4682) 2025-05-13 15:25:39 -07:00
Arjun Natarajan 2ff2972b67 oops js is js not python 2025-05-13 18:21:20 -04:00
Arjun Natarajan 873873e640 fix(docs): template app names 2025-05-13 18:17:42 -04:00
lc-arjunandGitHub fba0d6f96c chore(docs): reformat troubleshooting section and remove faqs page (#4681) 2025-05-13 15:04:19 -07:00
Arjun Natarajan 8bc509578b fix formatting 2025-05-13 17:59:51 -04:00
Arjun Natarajan 72d085d9f8 reformat troubleshooting section and remove faqs page 2025-05-13 17:54:51 -04:00
ccurmeandGitHub 940c2b0e74 docs: add chat model tabs to models guide (#4679) 2025-05-13 17:50:26 -04:00
lc-arjunandGitHub e705ea1961 feat(docs): studio nits (#4680) 2025-05-13 13:53:02 -07:00
Arjun Natarajan 18e8d334ed nits to threads 2025-05-13 16:48:07 -04:00
Arjun Natarajan 392606f5f7 feat(docs): studio nits 2025-05-13 16:29:10 -04:00
lc-arjunandGitHub cff2be48c9 feat(docs): further improvements for studio guides docs (#4677) 2025-05-13 12:59:47 -07:00
Arjun Natarajan c63cc173b2 added page for running application 2025-05-13 15:54:46 -04:00
Lauren Hirata SinghandGitHub 2b8c295898 docs: Simplify LGP quickstarts (#4678)
- Change quickstarts to use `new-langgraph-project`, which doesn't
require API keys for Anthropic, Tavily, etc.
2025-05-13 11:47:48 -07:00
Arjun Natarajan 03c5547e34 update dataset page 2025-05-13 14:46:26 -04:00
Lauren Hirata Singh a7faae6b54 nit 2025-05-13 11:40:30 -07:00
Lauren Hirata Singh 1d3f19763d add js sample code back 2025-05-13 11:36:45 -07:00
Lauren Hirata Singh 16d5ce364c nit 2025-05-13 11:24:19 -07:00
Lauren Hirata Singh ce235d0eb1 edits based on feedback 2025-05-13 11:20:19 -07:00
Arjun Natarajan 2e17857ca7 verb tense 2025-05-13 13:57:18 -04:00
Arjun Natarajan 304a59a1c9 feat(docs): further improvements for studio guides docs 2025-05-13 13:52:14 -04:00
Lauren Hirata Singh 063a0e027b docs: Simplify LGP quickstarts 2025-05-13 10:51:48 -07:00
ccurmeandGitHub 4534d174f4 docs: move async guide into graph-api (#4676) 2025-05-13 13:30:23 -04:00
Lauren Hirata SinghandGitHub 8d9a99bb99 docs: address feedback (#4674) 2025-05-13 10:08:42 -07:00
Lauren Hirata Singh ee528f7d49 nit 2025-05-13 10:04:33 -07:00
Lauren Hirata Singh 9d3ea6fd7e docs: address feedback 2025-05-13 09:51:50 -07:00
Vadym BardaandGitHub d256469f37 docs: fix warnings in links (#4672) 2025-05-13 11:38:54 -04:00
William Fu-Hinthorn 138f0eb003 fix: (docs) Rm unused api keys 2025-05-13 08:07:13 -07:00
Lauren Hirata SinghandGitHub 1acad37bee docs: LGP nits (#4670) 2025-05-12 20:59:59 -07:00
Lauren Hirata Singh 0a7a7fb71f docs: LGP nits 2025-05-12 20:57:29 -07:00
lc-arjunandGitHub b6f3e25ef7 fix: use absolute links for sdk reference (#4669) 2025-05-12 19:44:36 -07:00
Arjun Natarajan 70a10b0b57 fix: use absolute links for sdk reference 2025-05-12 22:39:05 -04:00
46 changed files with 528 additions and 1047 deletions
+1
View File
@@ -39,6 +39,7 @@ REDIRECT_MAP = {
"how-tos/configuration.ipynb": "how-tos/graph-api/#add-runtime-configuration",
"how-tos/node-retries.ipynb": "how-tos/graph-api/#add-retry-policies",
"how-tos/return-when-recursion-limit-hits.ipynb": "how-tos/graph-api/#impose-a-recursion-limit",
"how-tos/async.ipynb": "how-tos/graph-api/#async",
# memory how-tos
"how-tos/memory/manage-conversation-history.ipynb": "how-tos/memory.ipynb",
"how-tos/memory/delete-messages.ipynb": "how-tos/memory.ipynb#delete-messages",
+1 -1
View File
@@ -106,7 +106,7 @@ for chunk in agent.stream(
print("\n")
```
1. The [`interrupt` function][langgraph.types.interrupt] is used in conjunction with the [`Command`](../reference/types.md#langgraph.types.Command) object to resume the graph with a value provided by the human.
1. The [`interrupt` function][langgraph.types.interrupt] is used in conjunction with the [`Command`][langgraph.types.Command] object to resume the graph with a value provided by the human.
## Using with Agent Inbox
+2 -2
View File
@@ -294,7 +294,7 @@ agent.invoke(
)
```
For more details, see [how to update state from tools](../how-tos/update-state-from-tools.ipynb).
For more details, see [how to update state from tools](../how-tos/tool-calling.ipynb#update).
## Long-term memory
@@ -302,7 +302,7 @@ Use long-term memory to store user-specific or application-specific data across
To use long-term memory, you need to:
1. [Configure a store](../how-tos/cross-thread-persistence.ipynb) to persist data across invocations.
1. [Configure a store](../how-tos/persistence.ipynb#add-long-term-memory) to persist data across invocations.
2. Use the [`get_store`][langgraph.config.get_store] function to access the store from within tools or prompts.
### Read { #read-long-term }
+169 -16
View File
@@ -23,29 +23,182 @@ Compatible models can be found in the [LangChain integrations directory](https:/
You can configure an agent with a model name string:
```python
from langgraph.prebuilt import create_react_agent
=== "OpenAI"
```python
import os
from langgraph.prebuilt import create_react_agent
os.environ["OPENAI_API_KEY"] = "sk-..."
agent = create_react_agent(
# highlight-next-line
model="openai:gpt-4.1",
# other parameters
)
```
=== "Anthropic"
```python
import os
from langgraph.prebuilt import create_react_agent
os.environ["ANTHROPIC_API_KEY"] = "sk-..."
agent = create_react_agent(
# highlight-next-line
model="anthropic:claude-3-7-sonnet-latest",
# other parameters
)
```
=== "Azure"
```python
import os
from langgraph.prebuilt import create_react_agent
os.environ["AZURE_OPENAI_API_KEY"] = "..."
os.environ["AZURE_OPENAI_ENDPOINT"] = "..."
os.environ["OPENAI_API_VERSION"] = "2025-03-01-preview"
agent = create_react_agent(
# highlight-next-line
model="azure_openai:gpt-4.1",
# other parameters
)
```
=== "Google Gemini"
```python
import os
from langgraph.prebuilt import create_react_agent
os.environ["GOOGLE_API_KEY"] = "..."
agent = create_react_agent(
# highlight-next-line
model="google_genai:gemini-2.0-flash",
# other parameters
)
```
=== "AWS Bedrock"
```python
from langgraph.prebuilt import create_react_agent
# Follow the steps here to configure your credentials:
# https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html
agent = create_react_agent(
# highlight-next-line
model="bedrock_converse:anthropic.claude-3-5-sonnet-20240620-v1:0",
# other parameters
)
```
agent = create_react_agent(
# highlight-next-line
model="anthropic:claude-3-7-sonnet-latest",
# other parameters
)
```
## Using `init_chat_model`
The [`init_chat_model`](https://python.langchain.com/docs/how_to/chat_models_universal_init/) utility simplifies model initialization with configurable parameters:
```python
from langchain.chat_models import init_chat_model
=== "OpenAI"
```
pip install -U "langchain[openai]"
```
```python
import os
from langchain.chat_models import init_chat_model
os.environ["OPENAI_API_KEY"] = "sk-..."
model = init_chat_model(
"openai:gpt-4.1",
temperature=0,
# other parameters
)
```
=== "Anthropic"
```
pip install -U "langchain[anthropic]"
```
```python
import os
from langchain.chat_models import init_chat_model
os.environ["ANTHROPIC_API_KEY"] = "sk-..."
model = init_chat_model(
"anthropic:claude-3-5-sonnet-latest",
temperature=0,
# other parameters
)
```
=== "Azure"
```
pip install -U "langchain[openai]"
```
```python
import os
from langchain.chat_models import init_chat_model
os.environ["AZURE_OPENAI_API_KEY"] = "..."
os.environ["AZURE_OPENAI_ENDPOINT"] = "..."
os.environ["OPENAI_API_VERSION"] = "2025-03-01-preview"
model = init_chat_model(
"azure_openai:gpt-4.1",
azure_deployment=os.environ["AZURE_OPENAI_DEPLOYMENT_NAME"],
temperature=0,
# other parameters
)
```
=== "Google Gemini"
```
pip install -U "langchain[google-genai]"
```
```python
import os
from langchain.chat_models import init_chat_model
os.environ["GOOGLE_API_KEY"] = "..."
model = init_chat_model(
"google_genai:gemini-2.0-flash",
temperature=0,
# other parameters
)
```
=== "AWS Bedrock"
```
pip install -U "langchain[aws]"
```
```python
from langchain.chat_models import init_chat_model
# Follow the steps here to configure your credentials:
# https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html
model = init_chat_model(
"anthropic.claude-3-5-sonnet-20240620-v1:0",
model_provider="bedrock_converse",
temperature=0,
# other parameters
)
```
model = init_chat_model(
"anthropic:claude-3-7-sonnet-latest",
temperature=0,
max_tokens=2048
)
```
Refer to the [API reference](https://python.langchain.com/api_reference/langchain/chat_models/langchain.chat_models.base.init_chat_model.html) for advanced options.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

@@ -8,7 +8,7 @@ Please see [the overview of LangGraph human-in-the-loop](../../concepts/human_in
The [`interrupt` function][langgraph.types.interrupt] in LangGraph enables human-in-the-loop workflows by pausing the graph at a specific node, presenting information to a human, and resuming the graph with their input. It's useful for tasks like approvals, edits, or gathering additional context.
The graph is resumed using a [`Command`](../reference/types.md#langgraph.types.Command) object that provides the human's response.
The graph is resumed using a [`Command`][langgraph.types.Command] object that provides the human's response.
**Graph node with `interrupt`:**
+25 -20
View File
@@ -1,31 +1,36 @@
# Testing local agents with remote traces
# Debug LangSmith traces
## Overview
This guide explains how to open LangSmith traces in LangGraph Studio for interactive investigation and debugging.
A common workflow when debugging production-deployed agents is to test the same thread against a local version of the same agent, which may have modifications.
## Open deployed threads
To support this, LangGraph Studio, in combination with LangSmith, allows you to clone remote threads traced in LangSmith into your locally running agent. This cloned thread can then be used to re-run specific nodes within Studio.
1. Open the LangSmith trace, selecting the root run.
2. Click "Run in Studio".
## Requirements
This will open LangGraph Studio connected to the associated LangGraph Platform deployment with the trace's parent thread selected.
!!! info "Prerequisites"
## Testing local agents with remote traces
This section explains how to test a local agent against remote traces from LangSmith. This enables you to use production traces as input for local testing, allowing you to debug and verify agent modifications in your development environment.
### Requirements
- A LangSmith traced thread
- A locally running agent. See [here](../how-tos/studio/quick_start.md#local-development-server) for setup
instructions.
!!! info "Local agent requirements"
- langgraph>=0.3.18
- langgraph-api>=0.0.32
- Contains the same set of nodes present in the remote trace
- A thread traced in LangSmith.
- A locally running agent. See [here](../../how-tos/local-studio.md) for setup instructions.
- Note that your local agent must be using the above specified `langgraph` and `langgraph-api` versions.
- The nodes present in the remote trace must exist in at least one of the graphs in your local agent.
### Cloning Thread
## Cloning Thread
1. Open the LangSmith trace, selecting the root run.
2. Click the dropdown next to "Run in Studio".
3. Enter your local agent's URL.
4. Select "Clone thread locally".
5. If multiple graphs exist, select the target graph.
First navigate to the LangSmith trace. Here you should see a button to "Run in Studio".
![Run in Studio](img/run_in_studio.png){width=1200}
This will prompt you to enter the url that your locally running agent is accessible at. Once provided, select "Clone thread locally". If you have multiple graphs in your agent, you will also be prompted to select a graph to clone this thread under.
Once selected, a will a new thread in your local agent will be created and the thread history will be reconstruced to reflect the original trace.
Alternatively, if your trace originates from an agent deployed on LangGraph Platform, you can "View original thread" to open Studio with the actual deployed thread.
A new thread will be created in your local agent with the thread history inferred and copied from the remote thread, and you will be navigated to LangGraph Studio for your locally running application.
@@ -50,7 +50,7 @@ For more information on configurations, [see here](../../concepts/low_level.md#c
### LangGraph SDK
To create an assistant, use the [LangGraph SDK](../../concepts/sdk.md) `create` method. See the [Python](../reference/sdk/python_sdk_ref.md#langgraph_sdk.client.AssistantsClient.create) and [JS](../reference/sdk/js_ts_sdk_ref.md#create) SDK reference docs for more information.
To create an assistant, use the [LangGraph SDK](../../concepts/sdk.md) `create` method. See the [Python](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/python_sdk_ref/#langgraph_sdk.client.AssistantsClient.create) and [JS](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/js_ts_sdk_ref/#create) SDK reference docs for more information.
This example uses the same configuration schema as above, and creates an assistant with `model_name` set to `openai`.
@@ -228,10 +228,10 @@ Inside your deployment, select the "Assistants" tab. For the assistant you would
### LangGraph SDK
To edit the assistant, use the `update` method. This will create a new version of the assistant with the provided edits. See the [Python](../reference/sdk/python_sdk_ref.md#langgraph_sdk.client.AssistantsClient.update) and [JS](../reference/sdk/js_ts_sdk_ref.md#update) SDK reference docs for more information.
To edit the assistant, use the `update` method. This will create a new version of the assistant with the provided edits. See the [Python](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/python_sdk_ref/#langgraph_sdk.client.AssistantsClient.update) and [JS](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/js_ts_sdk_ref/#update) SDK reference docs for more information.
!!! note "Note"
You must pass in the ENTIRE config (and metadata if you are using it). The update endpoint creates new versions completely from scratch and does not rely on previously versions.
You must pass in the ENTIRE config (and metadata if you are using it). The update endpoint creates new versions completely from scratch and does not rely on previously versions.
For example, to update your assistant's system prompt:
=== "Python"
+8 -13
View File
@@ -1,17 +1,12 @@
# Adding nodes as dataset examples in Studio
# Add node to dataset
In LangGraph Studio you can create dataset examples from the thread history in the right-hand pane. This can be especially useful when you want to evaluate intermediate steps of the agent.
This guide shows how to add examples to [LangSmith datasets](https://docs.smith.langchain.com/evaluation/how_to_guides#dataset-management) from nodes in the thread log. This is useful to evaluate indivudal steps of the agent.
1. Click on the `Add to Dataset` button to enter the dataset mode.
1. Select nodes which you want to add to dataset.
1. Select the target dataset to create the example in.
You can edit the example payload before sending it to the dataset, which is useful if you need to make changes to conform the example to the dataset schema.
Finally, you can customise the target dataset by clicking on the `Settings` button.
1. Select a thread.
2. Click on the `Add to Dataset` button.
3. Select nodes whose input/output you want to add to a dataset.
4. For each selected node, select the target dataset to create the example in. By default a dataset for the specific assistant and node will be selected. If this dataset does not yet exist, it will be created.
5. Edit the example's input/output as needed before adding it to the dataset.
6. Select "Add to dataset" at the bottom of the page to add all selected nodes to their respective datasets.
See [Evaluating intermediate steps](https://docs.smith.langchain.com/evaluation/how_to_guides/langgraph#evaluating-intermediate-steps) for more details on how to evaluate intermediate steps.
<video controls allowfullscreen="true" poster="../img/studio_datasets.jpg">
<source src="https://langgraph-docs-assets.pages.dev/studio_datasets.mp4" type="video/mp4">
</video>
+38 -9
View File
@@ -1,19 +1,48 @@
# How to manage Assistants
# Run application
!!! info "Prerequisites"
!!!info "Prerequisites"
- [Running agents](../../agents/run_agents.md#running-agents)
- [Assistants Overview](../../concepts/assistants.md)
LangGraph Studio lets you view, edit, and update your assistants, and allows you to run your graph using these assistant configurations.
This guide shows how to submit a [run](../concepts/runs.md) to your application.
## Graph mode
To view your assistants, click the "Manage Assistants" button in the bottom left corner.
### Specify input
First define the input to your graph with in the "Input" section on the left side of the page, below the graph interface.
This opens a modal for you to view all the assistants for the selected graph. Specify the assistant and its version you would like to mark as "Active", and this assistant will be used when submitting runs.
Studio will attempt to render a form for your input based on the graph's defined [state schema](../../concepts/low_level.md/#schema). To disable this, click the "View Raw" button, which will present you with a JSON editor.
Click the up/down arrows at the top of the "Input" section to toggle through and use previously submitted inputs.
### Run settings
#### Assistant
To specify the [assistant](../../concepts/assistants.md) that is used for the run click the settings button in the bottom left corner. If an assistant is currently selected the button will also list the assistant name. If no assistant is selected it will say "Manage Assistants".
Select the assistant to run and click the "Active" toggle at the top of the modal to activate it. [See here](./studio/manage_assistants.md) for more information on managing assistants.
#### Streaming
Click the dropdown next to "Submit" and click the toggle to enable/disable streaming.
#### Breakpoints
To run your graph with breakpoints, click the "Interrupt" button. Select a node and whether to pause before and/or after that node has executed. Click "Continue" in the thread log to resume execution.
For more information on breakpoints see [here](../../concepts/breakpoints.md).
### Submit run
To submit the run with the specified input and run settings, click the "Submit" button. This will add a [run](../concepts/runs.md) to the existing selected [thread](../concepts/threads.md). If no thread is currently selected, a new one will be created.
To cancel the ongoing run, click the "Cancel" button.
By default, the "Default configuration" option will be active. This option reflects the default configuration defined in your graph. Edits made to this configuration will be used to update the run-time configuration, but will not update or create a new assistant unless you click "Create new assistant".
## Chat mode
Specify the input to your chat application in the bottom of the conversation panel. Click the "Send message" button to submit the input as a Human message and have the response streamed back.
Chat mode enables you to switch through the different assistants in your graph via the dropdown selector at the top of the page. To create, edit, or delete assistants, use Graph mode.
To cancel the ongoing run, click the "Cancel" button. Click the "Show tool calls" toggle to hide/show tool calls in the conversation.
## Learn more
To run your application from a specific checkpoint in an existing thread, see [this guide](./threads_studio.md#edit-thread-history).
+30 -36
View File
@@ -1,23 +1,28 @@
# Prompt Engineering in LangGraph Studio
# Iterate on prompts
## Overview
A central aspect of agent development is prompt engineering. LangGraph Studio makes it easy to iterate on the prompts used within your graph directly within the UI.
LangGraph Studio supports two methods for modifying prompts in your graph: direct node editing and the LangSmith Playground interface.
## Setup
## Direct Node Editing
The first step is to define your [configuration](https://langchain-ai.github.io/langgraph/how-tos/configuration/) such that LangGraph Studio is aware of the prompts you want to iterate on and which nodes they are associated with.
Studio allows you to edit prompts used inside individual nodes, directly from the graph interface.
### Reference
!!! info "Prerequisites"
When defining your configuration, you can use special metadata keys to instruct LangGraph Studio how to handle different fields. Here's a reference for the available configuration options:
- [Assistants overview](../../concepts/assistants.md)
#### `langgraph_nodes`
### Graph Configuration
- **Description**: Specifies which graph nodes a configuration field is associated with.
Define your [configuration](https://langchain-ai.github.io/langgraph/how-tos/configuration/) to specify prompt fields and their associated nodes using `langgraph_nodes` and `langgraph_type` keys.
#### Configuration Reference
##### `langgraph_nodes`
- **Description**: Specifies which nodes of the graph a configuration field is associated with.
- **Value Type**: Array of strings, where each string is the name of a node in your graph.
- **Usage Context**: Include in the `json_schema_extra` dictionary for Pydantic models or the `metadata["json_schema_extra"]` dictionary for dataclasses.
- **Required**: No, but necessary if you want a field to be editable for specific nodes in the UI.
- **Example**:
```python
system_prompt: str = Field(
@@ -26,14 +31,13 @@ When defining your configuration, you can use special metadata keys to instruct
)
```
#### `langgraph_type`
##### `langgraph_type`
- **Description**: Specifies the type of configuration field, which determines how it's handled in the UI.
- **Value Type**: String
- **Supported Values**:
- `"prompt"`: Indicates the field contains prompt text that should be treated specially in the UI.
- **Usage Context**: Include in the `json_schema_extra` dictionary for Pydantic models or the `metadata["json_schema_extra"]` dictionary for dataclasses.
- **Required**: No, but helpful for prompt fields to enable special handling.
- **Example**:
```python
system_prompt: str = Field(
@@ -45,9 +49,7 @@ When defining your configuration, you can use special metadata keys to instruct
)
```
### Example
For example, if you have a node called `call_model` whose system prompt you want to iterate on, you can define a configuration like the following.
#### Example Configuration
```python
## Using Pydantic
@@ -111,30 +113,22 @@ class Configuration:
```
## Iterating on prompts
### Editing prompts in UI
### Node Configuration
1. Locate the gear icon on nodes with associated configuration fields
2. Click to open the configuration modal
3. Edit the values
4. Save to update the current assistant version or create a new one
With this set up, running your graph and viewing in LangGraph Studio will result in the graph rendering like such.
## LangSmith Playground
**Note the configuration icon in the top right corner of the `call_model` node**:
The [LangSmith Playground](https://
docs.smith.langchain.com/prompt_engineering/how_to_guides#playground) interface allows testing individual LLM calls without running the full graph:
![Graph in Studio](img/studio_graph_with_configuration.png){width=1200}
1. Select a thread
2. Click "View LLM Runs" on a node. This lists all the LLM calls (if any) made inside the node.
3. Select an LLM run to open in Playground
4. Modify prompts and test different model and tool settings
5. Copy updated prompts back to your graph
Clicking this icon will open a modal where you can edit the configuration for all of the fields associated with the `call_model` node. From here, you can save your changes and apply them to the graph. Note that these values reflect the currently active assistant, and saving will update the assistant with the new values.
![Configuration modal](img/studio_node_configuration.png){width=1200}
### Playground
LangGraph Studio also supports prompt engineering through an integration with the LangSmith Playground. To do so:
1. Open an existing thread or create a new one.
2. Within the thread log, any nodes that have made an LLM call will have a "View LLM Runs" button. Clicking this will open a popover with the LLM runs for that node.
3. Select the LLM run you want to edit. This will open the LangSmith Playground with the selected LLM run.
![Playground in Studio](img/studio_playground.png){width=1200}
From here you can edit the prompt, test different model configurations and re-run just this LLM call without having to re-run the entire graph. When you are happy with your changes, you can copy the updated prompt back into your graph.
For more information on how to use the LangSmith Playground, see the [LangSmith Playground documentation](https://docs.smith.langchain.com/prompt_engineering/how_to_guides#playground).
For advanced Playground features, click the expand button in the top right corner.
-50
View File
@@ -1,50 +0,0 @@
# LangGraph Studio FAQs
## Why is my project failing to start?
A project may fail to start if the configuration file is defined incorrectly, or if required environment variables are missing. See [here](../../reference/cli.md#configuration-file) for how your configuration file should be defined.
## How does interrupt work?
When you select the `Interrupts` dropdown and select a node to interrupt the graph will pause execution before and after (unless the node goes straight to `END`) that node has run. This means that you will be able to both edit the state before the node is ran and the state after the node has ran. This is intended to allow developers more fine-grained control over the behavior of a node and make it easier to observe how the node is behaving. You will not be able to edit the state after the node has ran if the node is the final node in the graph.
For more information on interrupts and human in the loop, see [here](./human_in_the_loop.md).
## Why are extra edges showing up in my graph?
If you don't define your conditional edges carefully, you might notice extra edges appearing in your graph. This is because without proper definition, LangGraph Studio assumes the conditional edge could access all other nodes. In order for this to not be the case, you need to be explicit about how you define the nodes the conditional edge routes to. There are two ways you can do this:
### Solution 1: Include a path map
The first way to solve this is to add path maps to your conditional edges. A path map is just a dictionary or array that maps the possible outputs of your router function with the names of the nodes that each output corresponds to. The path map is passed as the third argument to the `add_conditional_edges` function like so:
=== "Python"
```python
graph.add_conditional_edges("node_a", routing_function, {True: "node_b", False: "node_c"})
```
=== "Javascript"
```ts
graph.addConditionalEdges("node_a", routingFunction, { true: "node_b", false: "node_c" });
```
In this case, the routing function returns either True or False, which map to `node_b` and `node_c` respectively.
### Solution 2: Update the typing of the router (Python only)
Instead of passing a path map, you can also be explicit about the typing of your routing function by specifying the nodes it can map to using the `Literal` python definition. Here is an example of how to define a routing function in that way:
```python
def routing_function(state: GraphState) -> Literal["node_b","node_c"]:
if state['some_condition'] == True:
return "node_b"
else:
return "node_c"
```
## Why is my graph taking so long to startup?
The LangGraph Studio interacts with a local LangGraph API server. To stay aligned with ongoing updates, the LangGraph API requires regular rebuilding. As a result, you may occasionally experience slight delays when starting up your project.
@@ -0,0 +1,19 @@
# Manage assistants
!!! info "Prerequisites"
- [Assistants Overview](../../concepts/assistants.md)
LangGraph Studio lets you view, edit, and update your assistants, and allows you to run your graph using these assistant configurations.
## Graph mode
To view your assistants, click the "Manage Assistants" button in the bottom left corner.
This opens a modal for you to view all the assistants for the selected graph. Specify the assistant and its version you would like to mark as "Active", and this assistant will be used when submitting runs.
By default, the "Default configuration" option will be active. This option reflects the default configuration defined in your graph. Edits made to this configuration will be used to update the run-time configuration, but will not update or create a new assistant unless you click "Create new assistant".
## Chat mode
Chat mode enables you to switch through the different assistants in your graph via the dropdown selector at the top of the page. To create, edit, or delete assistants, use Graph mode.
+28 -25
View File
@@ -7,16 +7,21 @@ LangGraph Studio supports connecting to two types of graphs:
- Graphs deployed on [LangGraph Platform](../../../cloud/quick_start.md)
- Graphs running locally via the [LangGraph Server](../../../tutorials/langgraph-platform/local-server.md).
## Deployed Application
LangGraph Studio is accessed from the LangSmith UI, within the LangGraph Platform Deployments tab.
For applications that are deployed on LangGraph Platform, you can access Studio as part of that deployment. To do so, navigate to the deployment in LangGraph Platform within the LangSmith UI and click the "LangGraph Studio" button.
## Deployed application
For applications that are [deployed](../../quick_start.md) on LangGraph Platform, you can access Studio as part of that deployment. To do so, navigate to the deployment in LangGraph Platform within the LangSmith UI and click the "LangGraph Studio" button.
This will load the Studio UI connected to your live deployment, allowing you to create, read, and update the [threads](../../concepts/threads.md), [assistants](../../../concepts/assistants.md), and [memory](../../../concepts//memory.md) in that deployment.
## Local Development Server
## Local development server
To test your locally running application using LangGraph Studio, ensure your application is set up following [this guide](https://langchain-ai.github.io/langgraph/cloud/deployment/setup/).
!!! info "LangSmith Tracing"
For local development, if you do not wish to have data traced to LangSmith, set `LANGSMITH_TRACING=false` in your application's `.env` file. With tracing disabled, no data will leave your local server.
Next, install the [LangGraph CLI](../../../concepts/langgraph_cli.md):
```
@@ -44,15 +49,14 @@ If successful, you will see the following logs:
>
> - LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
Once running, you will automatically be directed to LangGraph Studio.
Once running, you will automatically be directed to LangGraph Studio.
For an already running server, access Studio by either:
If your server is already running, to access Studio, either:
1. Directly navigate to the following URL: `https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024`.
2. Within LangSmith, navigate to the LangGraph Platform Deployments tab, click the "LangGraph Studio" button, enter `http://127.0.0.1:2024` and click "Connect".
1. Directly navigate to the following URL: `https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024`.
2. Within LangSmith, navigate to the LangGraph Platform Deployments tab, click the "LangGraph Studio" button, enter `http://127.0.0.1:2024` and click "Connect".
If running your server at a different host or port, simply update the `baseUrl` to match.
If running your server at a different host or port, simply update the `baseUrl` to match.
### (Optional) Attach a debugger
@@ -69,8 +73,8 @@ langgraph dev --debug-port 5678
Then attach your preferred debugger:
=== "VS Code"
Add this configuration to `launch.json`:
```json
Add this configuration to `launch.json`:
`json
{
"name": "Attach to LangGraph",
"type": "debugpy",
@@ -80,23 +84,22 @@ Then attach your preferred debugger:
"port": 5678
}
}
```
Specify the port number you chose in the previous step.
`
Specify the port number you chose in the previous step.
=== "PyCharm"
1. Go to Run → Edit Configurations
2. Click + and select "Python Debug Server"
3. Set IDE host name: `localhost`
4. Set port: `5678` (or the port number you chose in the previous step)
5. Click "OK" and start debugging
=== "PyCharm" 1. Go to Run → Edit Configurations 2. Click + and select "Python Debug Server" 3. Set IDE host name: `localhost` 4. Set port: `5678` (or the port number you chose in the previous step) 5. Click "OK" and start debugging
## Troubleshooting
For issues getting started, please see this [troubleshooting guide](../../../troubleshooting/studio.md).
## Next steps
See the following how-tos for more information on how to use Studio:
See the following guides for more information on how to use Studio:
- [How to manage Assistants](../invoke_studio.md)
- [How to manage Threads](../threads_studio.md)
- [How to create datasets](../datasets_studio.md)
- [How to prompt engineer](../iterate_graph_studio.md)
- [How to locally debug remote traces](../clone_traces_studio.md)
- [Run application](../invoke_studio.md)
- [Manage assistants](./manage_assistants.md)
- [Manage threads](../threads_studio.md)
- [Iterate on prompts](../iterate_graph_studio.md)
- [Debug LangSmith traces](../clone_traces_studio.md)
- [Add node to dataset](../datasets_studio.md)
+18 -7
View File
@@ -1,4 +1,4 @@
# How to manage Threads
# Manage threads
!!! info "Prerequisites"
@@ -6,25 +6,36 @@
Studio allows you to view threads from the server and edit their state.
## View Threads
## View threads
### Graph mode
1. In the top of the right-hand pane, select the `New Thread` dropdown menu to view existing threads.
1. In the top of the right-hand pane, select the dropdown menu to view existing threads.
1. Select the desired thread, and the thread history will populate in the right-hand side of the page.
1. To create a new thread, select `+ New Thread`.
1. To create a new thread, click `+ New Thread` and [submit a run](../how-tos/invoke_studio.md#graph-mode).
To view more granular information in the thread, drag the slider at the top of the page to the right. To view less information, drag the slider to the left. Additionally, collapse or expand individual turns, nodes, and keys of the state.
Switch between `Pretty` and `JSON` mode for different rendering formats.
### Chat mode
1. View all threads in the right-hand pane of the page.
2. Click the plus button to create a new thread.
2. Select the desired thread and the thread history will populate in the center panel.
3. To create a new thread, click the plus button and [submit a run](../how-tos/invoke_studio.md#chat-mode).
## Edit Thread State
## Edit thread history
### Graph mode
To edit the state of the thread, select "edit node state" next to the desired node. This enables you to edit the node's output and create a new fork of the thread history. For more information about time travel, [see here](../../concepts/time-travel.md).
To edit the state of the thread, select "edit node state" next to the desired node. Edit the node's output as desired and click "fork" to confirm. This will create a new forked run from the checkpoint of the selected node.
If you instead want to re-run the thread from a given checkpoint without editing the state, click the "Re-run from here". This will again create a new forked run from the selected checkpoint. This is useful for re-running with changes that are not specific to the state, such as the selected assistant.
### Chat mode
To edit a human message in the thread, click the edit button below the human message. Edit the message as desired and submit. This will create a new fork of the conversation history. To re-generate an AI message, click the retry icon below the AI message.
## Learn more
For more information about time travel, [see here](../../concepts/time-travel.md).
+2 -2
View File
@@ -158,7 +158,7 @@ export default function HomePage() {
}
```
Under the hood, the `useStream()` hook will use the `streamMode: "messages-tuple"` to receive a stream of messages (i.e. individual LLM tokens) from any LangChain chat model invocations inside your graph nodes. Learn more about messages streaming in the [How to stream messages from your graph](./stream_messages.md) guide.
Under the hood, the `useStream()` hook will use the `streamMode: "messages-tuple"` to receive a stream of messages (i.e. individual LLM tokens) from any LangChain chat model invocations inside your graph nodes. Learn more about messages streaming in the [streaming](../how-tos/streaming.md#messages) guide.
### Interrupts
@@ -476,7 +476,7 @@ The `useStream()` hook provides several callback options to help you respond to
- `onError`: Called when an error occurs.
- `onFinish`: Called when the stream is finished.
- `onUpdateEvent`: Called when an update event is received.
- `onCustomEvent`: Called when a custom event is received. See [Custom events](../../how-tos/streaming.ipynb#custom) to learn how to stream custom events.
- `onCustomEvent`: Called when a custom event is received. See the [streaming](../../how-tos/streaming.md#stream-custom-data) guide to learn how to stream custom events.
- `onMetadataEvent`: Called when a metadata event is received, which contains the Run ID and Thread ID.
## Learn More
+6 -6
View File
@@ -1,4 +1,4 @@
# How to use threads
# Use threads
!!! info "Prerequisites"
@@ -12,7 +12,7 @@ To run your graph and the state persisted, you must first create a thread.
### Empty thread
To create a new thread, use the [LangGraph SDK](../../concepts/sdk.md) `create` method. See the [Python](../reference/sdk/python_sdk_ref.md#langgraph_sdk.client.ThreadsClient.create) and [JS](../reference/sdk/js_ts_sdk_ref.md#create_3) SDK reference docs for more information.
To create a new thread, use the [LangGraph SDK](../../concepts/sdk.md) `create` method. See the [Python](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/python_sdk_ref/#langgraph_sdk.client.ThreadsClient.create) and [JS](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/js_ts_sdk_ref/#create_3) SDK reference docs for more information.
=== "Python"
@@ -58,7 +58,7 @@ Output:
### Copy thread
Alternatively, if you already have a thread in your application whose state you wish to copy, you can use the `copy` method. This will create an independent thread whose history is identical to the original thread at the time of the operation. See the [Python](../reference/sdk/python_sdk_ref.md#langgraph_sdk.client.ThreadsClient.copy) and [JS](../reference/sdk/js_ts_sdk_ref.md#copy) SDK reference docs for more information.
Alternatively, if you already have a thread in your application whose state you wish to copy, you can use the `copy` method. This will create an independent thread whose history is identical to the original thread at the time of the operation. See the [Python](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/python_sdk_ref/#langgraph_sdk.client.ThreadsClient.copy) and [JS](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/js_ts_sdk_ref/#copy) SDK reference docs for more information.
=== "Python"
@@ -237,11 +237,11 @@ Output:
### LangGraph SDK
To list threads, use the [LangGraph SDK](../../concepts/sdk.md) `search` method. This will list the threads in the application that match the provided filters. See the [Python](../reference/sdk/python_sdk_ref.md#langgraph_sdk.client.ThreadsClient.search) and [JS](../reference/sdk/js_ts_sdk_ref.md#search_2) SDK reference docs for more information.
To list threads, use the [LangGraph SDK](../../concepts/sdk.md) `search` method. This will list the threads in the application that match the provided filters. See the [Python](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/python_sdk_ref/#langgraph_sdk.client.ThreadsClient.search) and [JS](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/js_ts_sdk_ref/#search_2) SDK reference docs for more information.
#### Filter by thread status
Use the `status` field to filter threads based on their status. Supported values are `idle`, `busy`, `interrupted`, and `error`. See [here](../reference/sdk/python_sdk_ref.md/?h=thread+status#langgraph_sdk.auth.types.ThreadStatus) for information on each status. For example, to view `idle` threads:
Use the `status` field to filter threads based on their status. Supported values are `idle`, `busy`, `interrupted`, and `error`. See [here](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/python_sdk_ref/?h=thread+status#langgraph_sdk.auth.types.ThreadStatus) for information on each status. For example, to view `idle` threads:
=== "Python"
@@ -480,7 +480,7 @@ Optionally, to view the state of a thread at a given checkpoint, simply pass in
#### Inspect Full Thread History
To view a thread's history, use the `get_history` method. This returns a list of every state the thread experienced. For more information see the [Python](../reference/sdk/python_sdk_ref.md/#langgraph_sdk.client.ThreadsClient.get_history) and [JS](../reference/sdk/js_ts_sdk_ref.md/#gethistory) reference docs.
To view a thread's history, use the `get_history` method. This returns a list of every state the thread experienced. For more information see the [Python](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/python_sdk_ref/?h=thread+status#langgraph_sdk.client.ThreadsClient.get_history) and [JS](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/js_ts_sdk_ref/#gethistory) reference docs.
### LangGraph Platform UI
+7 -17
View File
@@ -9,16 +9,11 @@ Before you begin, ensure you have the following:
- A [GitHub account](https://github.com/)
- A [LangSmith account](https://smith.langchain.com/) free to sign up
This quickstart uses the [pre-built Python ReAct agent template](https://github.com/langchain-ai/react-agent), which requires the following:
- An API key for [Anthropic](https://console.anthropic.com/)
- An API key for [Tavily](https://app.tavily.com/)
## 1. Create a repository on GitHub
To deploy a LangGraph application to **LangGraph Platform**, your application code must reside in a GitHub repository. Both public and private repositories are supported. For this quickstart, use the [pre-built Python ReAct agent template](https://github.com/langchain-ai/react-agent) for your application:
To deploy an application to **LangGraph Platform**, your application code must reside in a GitHub repository. Both public and private repositories are supported. For this quickstart, use the [`new-langgraph-project` template](https://github.com/langchain-ai/react-agent) for your application:
1. Go to the [ReAct Agent](https://github.com/langchain-ai/react-agent) repository.
1. Go to the [`new-langgraph-project` repository](https://github.com/langchain-ai/new-langgraph-project) or [`new-langgraphjs-project` template](https://github.com/langchain-ai/new-langgraphjs-project).
1. Click the `Fork` button in the top right corner to fork the repository to your GitHub account.
1. Click **Create fork**.
@@ -26,14 +21,9 @@ To deploy a LangGraph application to **LangGraph Platform**, your application co
1. Log in to [LangSmith](https://smith.langchain.com/).
1. In the left sidebar, select **LangGraph Platform**.
1. Click the **+ New Deployment** button. A modal will open where you can fill in the required fields.
1. Click the **+ New Deployment** button. A pane will open where you can fill in the required fields.
1. If you are a first time user or adding a private repository that has not been previously connected, click the **Import from GitHub** button and follow the instructions to connect your GitHub account.
1. Select your ReAct Agent repository.
1. In the **Environment Variables** section, set the following secrets:
- **ANTHROPIC_API_KEY**: Get an API key from [Anthropic](https://console.anthropic.com/).
- **TAVILY_API_KEY**: Get an API key on the [Tavily website](https://app.tavily.com/).
1. Select your New LangGraph Project repository.
1. Click **Submit** to deploy.
This may take about 15 minutes to complete. You can check the status in the **Deployment details** view.
@@ -48,7 +38,7 @@ Once your application is deployed:
LangGraph Studio will open to display your graph.
<figure markdown="1">
[![image](deployment/img/09_langgraph_studio.png){: style="max-height:400px"}](deployment/img/09_langgraph_studio.png)
[![image](deployment/img/langgraph_studio.png){: style="max-height:400px"}](deployment/img/langgraph_studio.png)
<figcaption>
Sample graph run in LangGraph Studio.
</figcaption>
@@ -125,7 +115,7 @@ You can now test the API:
print("\n\n")
```
=== "Javascript SDK"
=== "JavaScript SDK"
1. Install the LangGraph JS SDK
@@ -181,7 +171,7 @@ You can now test the API:
```
## Next Steps
## Next steps
Congratulations! You have deployed an application using LangGraph Platform.
+2 -2
View File
@@ -46,7 +46,7 @@ While a router allows an LLM to make a single decision, more complex agent archi
This architecture allows for more complex and flexible agent behaviors, going beyond simple routing to enable dynamic problem-solving with multiple steps. Unlike the original [paper](https://arxiv.org/abs/2210.03629), today's agents rely on LLMs' [tool calling](#tool-calling) capabilities and operate on a list of [messages](./low_level.md#why-use-messages).
In LangGraph, you can use the prebuilt [agent](../agent/overview.md) to get started with tool-calling agents.
In LangGraph, you can use the prebuilt [agent](../agents/agents.md#2-create-an-agent) to get started with tool-calling agents.
### Tool calling
@@ -75,7 +75,7 @@ Effective [memory management](../how-tos/memory.ipynb) enhances an agent's abili
### Planning
In a tool-calling [agent](../agent/overview.md), an LLM is called repeatedly in a while-loop. At each step the agent decides which tools to call, and what the inputs to those tools should be. Those tools are then executed, and the outputs are fed back into the LLM as observations. The while-loop terminates when the agent decides it has enough information to solve the user request and it is not worth calling any more tools.
In a tool-calling [agent](../agents/overview.md#what-is-an-agent), an LLM is called repeatedly in a while-loop. At each step the agent decides which tools to call, and what the inputs to those tools should be. Those tools are then executed, and the outputs are fed back into the LLM as observations. The while-loop terminates when the agent decides it has enough information to solve the user request and it is not worth calling any more tools.
## Custom agent architectures
+3 -3
View File
@@ -15,15 +15,15 @@ Imagine a general-purpose writing agent built on a common graph architecture. Wh
Assistants build on the LangGraph open source concept of [configuration](low_level.md#configuration).
While configuration is available in the open source LangGraph library, assistants are only present in [LangGraph Platform](langgraph_platform.md).
This is due to the fact that Assistants are tightly coupled to your deployed graph. Upon deployment, LangGraph Server will automatically create a default assistant for each graph using the graph's default configuration settings.
This is due to the fact that assistants are tightly coupled to your deployed graph. Upon deployment, LangGraph Server will automatically create a default assistant for each graph using the graph's default configuration settings.
In practice, an assistant is just an _instance_ of a graph with a specific configuration. Therefore, multiple assistants can reference the same graph but can contain different configurations (e.g. prompts, models, tools). The LangGraph Server API provides several endpoints for creating and managing assistants. See the [API reference](../cloud/reference/api/api_ref.html) and [this how-to](../cloud/how-tos/configuration_cloud.md) for more details on how to create assistants.
## Versioning assistants
Assistants support versioning to track changes over time.
Once you've created an assistant, subsequent edits to that assistant will create new versions. See [this how-to](../cloud/how-tos/assistant_versioning.md) for more details on how to manage assistant versions.
Once you've created an assistant, subsequent edits to that assistant will create new versions. See [this how-to](../cloud/how-tos/configuration_cloud.md#create-a-new-version-for-your-assistant) for more details on how to manage assistant versions.
## 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.
* 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.
+7 -10
View File
@@ -5,18 +5,17 @@ search:
# LangGraph Platform
**LangGraph Platform** is a commercial solution for deploying agentic applications to production, built on the open-source [LangGraph framework](../index.md).
<div align="center"><iframe width="560" height="315" src="https://www.youtube.com/embed/pfAQxBS5z88?si=XGS6Chydn6lhSO1S" title="What is LangGraph Platform?" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
Develop, deploy, scale, and manage agents with **LangGraph Platform** — the purpose-built platform for long-running, agentic workflows.
!!! tip "Get started with LangGraph Platform"
Check out the [LangGraph Platform quickstart](../cloud/quick_start.md) for instructions on how to set up and use LangGraph Platform to do a cloud deployment.
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.
## Why use LangGraph Platform?
LangGraph Platform handles common issues that arise when deploying LLM applications to production, allowing you to focus on agent logic instead of managing server infrastructure.
<div align="center"><iframe width="560" height="315" src="https://www.youtube.com/embed/pfAQxBS5z88?si=XGS6Chydn6lhSO1S" title="What is LangGraph Platform?" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
LangGraph Platform makes it easy to get your agent running in production — whether its built with LangGraph or another framework — so you can focus on your app logic, not infrastructure. Deploy with one click to get a live endpoint, and use our robust APIs and built-in task queues to handle production scale.
- **[Streaming Support](../cloud/concepts/streaming.md)**: As agents grow more sophisticated, they often benefit from streaming both token outputs and intermediate states back to the user. Without this, users are left waiting for potentially long operations with no feedback. LangGraph Server provides multiple streaming modes optimized for various application needs.
@@ -32,8 +31,6 @@ LangGraph Platform handles common issues that arise when deploying LLM applicati
- **[Human-in-the-loop support](../cloud/how-tos/human_in_the_loop_breakpoint.md)**: In many applications, users require a way to intervene in agent processes. LangGraph Server provides specialized endpoints for human-in-the-loop scenarios, simplifying the integration of manual oversight into agent workflows.
By using LangGraph Platform, you gain access to a robust, scalable deployment solution that mitigates these challenges, saving you the effort of implementing and maintaining them manually. This allows you to focus more on building effective agent behavior and less on solving deployment infrastructure issues.
- **[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
There are several ways to deploy on LangGraph Platform. For more information, see [Deployment options](./deployment_options.md).
- **[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).
@@ -17,7 +17,7 @@ There are two versions of the self-hosted deployment: [Self-Hosted Data Plane](.
## Self-Hosted Data Plane
The [Self-Hosted Data Plane](./self_hosted.md.md) deployment option is a "hybrid" model for deployment where we manage the [control plane](./langgraph_control_plane.md) in our cloud and you manage the [data plane](./langgraph_data_plane.md) in your cloud. This option provides a way to securely manage your data plane infrastructure, while offloading control plane management to us. When using the Self-Hosted Data Plane version, you authenticate with a [LangSmith](https://smith.langchain.com/) API key.
The [Self-Hosted Data Plane](../cloud/deployment/self_hosted_data_plane.md) deployment option is a "hybrid" model for deployment where we manage the [control plane](./langgraph_control_plane.md) in our cloud and you manage the [data plane](./langgraph_data_plane.md) in your cloud. This option provides a way to securely manage your data plane infrastructure, while offloading control plane management to us. When using the Self-Hosted Data Plane version, you authenticate with a [LangSmith](https://smith.langchain.com/) API key.
| | [Control plane](../concepts/langgraph_control_plane.md) | [Data plane](../concepts/langgraph_data_plane.md) |
|-------------------|-------------------|------------|
+1 -1
View File
@@ -24,7 +24,7 @@ Feature Differences:
| | Lite | Enterprise |
|-------|------------|------------|
| [Cron Jobs](../clouds/concepts/cron-jobs.md) |❌|✅|
| [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
+15 -10
View File
@@ -17,23 +17,28 @@ LangGraph Studio is a specialized agent IDE that enables visualization, interact
## Features
The key features of LangGraph Studio are:
Key features of LangGraph Studio:
- Visualize your graph architecture
- Run and interact with your agent in a GUI
- Create and manage [assistants](assistants.md)
- View and manage [threads](../cloud/concepts/threads.md)
- View and manage [long term memory](memory.md)
- [Run and interact with your agent](../cloud/how-tos/invoke_studio.md)
- [Manage assistants](../cloud/how-tos/studio/manage_assistants.md.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)
- Debug agent state via [time travel](time-travel.md)
LangGraph Studio works for graphs that are deployed on [LangGraph Platform](../cloud/quick_start.md) or for graphs that are running locally via the [LangGraph Server](../tutorials/langgraph-platform/local-server.md).
LangGraph Studio supports two modes:
Studio supports two modes:
1. Graph
2. Chat
### 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).
Chat mode is a simpler UI for iterating on and testing chat-specific agents. It is useful for business users and those who want to test overall agent behavior.
### Chat mode
Chat mode is a simpler UI for iterating on and testing chat-specific agents. It is useful for business users and those who want to test overall agent behavior. Chat mode is only supported for graph's whose state includes or extends [`MessagesState`](https://langchain-ai.github.io/langgraph/how-tos/graph-api/#messagesstate).
## Learn more
- See this guide on how to [get started](../cloud/how-tos/studio/quick_start.md) with LangGraph Studio.
+8 -8
View File
@@ -45,9 +45,9 @@ The first thing you do when you define a graph is define the `State` of the grap
### Schema
The main documented way to specify the schema of a graph is by using `TypedDict`. However, we also support [using a Pydantic BaseModel](../how-tos/state-model.ipynb) as your graph state to add **default values** and additional data validation.
The main documented way to specify the schema of a graph is by using `TypedDict`. However, we also support [using a Pydantic BaseModel](../how-tos/graph-api.ipynb#use-pydantic-models-for-graph-state) as your graph state to add **default values** and additional data validation.
By default, the graph will have the same input and output schemas. If you want to change this, you can also specify explicit input and output schemas directly. This is useful when you have a lot of keys, and some are explicitly for input and others for output. See the [notebook here](../how-tos/input_output_schema.ipynb) for how to use.
By default, the graph will have the same input and output schemas. If you want to change this, you can also specify explicit input and output schemas directly. This is useful when you have a lot of keys, and some are explicitly for input and others for output. See the [guide here](../how-tos/graph-api.ipynb#define-input-and-output-schemas) for how to use.
#### Multiple schemas
@@ -56,9 +56,9 @@ Typically, all graph nodes communicate with a single schema. This means that the
- Internal nodes can pass information that is not required in the graph's input / output.
- We may also want to use different input / output schemas for the graph. The output might, for example, only contain a single relevant output key.
It is possible to have nodes write to private state channels inside the graph for internal node communication. We can simply define a private schema, `PrivateState`. See [this notebook](../how-tos/pass_private_state.ipynb) for more detail.
It is possible to have nodes write to private state channels inside the graph for internal node communication. We can simply define a private schema, `PrivateState`. See [this guide](../how-tos/graph-api.ipynb#pass-private-state-between-nodes) for more detail.
It is also possible to define explicit input and output schemas for a graph. In these cases, we define an "internal" schema that contains _all_ keys relevant to graph operations. But, we also define `input` and `output` schemas that are sub-sets of the "internal" schema to constrain the input and output of the graph. See [this notebook](../how-tos/input_output_schema.ipynb) for more detail.
It is also possible to define explicit input and output schemas for a graph. In these cases, we define an "internal" schema that contains _all_ keys relevant to graph operations. But, we also define `input` and `output` schemas that are sub-sets of the "internal" schema to constrain the input and output of the graph. See [this guide](../how-tos/graph-api.ipynb#define-input-and-output-schemas) for more detail.
Let's look at an example:
@@ -352,7 +352,7 @@ def my_node(state: State) -> Command[Literal["my_other_node"]]:
When returning `Command` in your node functions, you must add return type annotations with the list of node names the node is routing to, e.g. `Command[Literal["my_other_node"]]`. This is necessary for the graph rendering and tells LangGraph that `my_node` can navigate to `my_other_node`.
Check out this [how-to guide](../how-tos/command.ipynb) for an end-to-end example of how to use `Command`.
Check out this [how-to guide](../how-tos/graph-api.ipynb#combine-control-flow-and-state-updates-with-command) for an end-to-end example of how to use `Command`.
### When should I use Command instead of conditional edges?
@@ -379,7 +379,7 @@ def my_node(state: State) -> Command[Literal["other_subgraph"]]:
!!! important "State updates with `Command.PARENT`"
When you send updates from a subgraph node to a parent graph node for a key that's shared by both parent and subgraph [state schemas](#schema), you **must** define a [reducer](#reducers) for the key you're updating in the parent graph state. See this [example](../how-tos/command.ipynb#navigating-to-a-node-in-a-parent-graph).
When you send updates from a subgraph node to a parent graph node for a key that's shared by both parent and subgraph [state schemas](#schema), you **must** define a [reducer](#reducers) for the key you're updating in the parent graph state. See this [example](../how-tos/graph-api.ipynb#navigate-to-a-node-in-a-parent-graph).
This is particularly useful when implementing [multi-agent handoffs](./multi_agent.md#handoffs).
@@ -435,7 +435,7 @@ def node_a(state, config):
...
```
See [this guide](../how-tos/configuration.ipynb) for a full breakdown on configuration.
See [this guide](../how-tos/graph-api.ipynb#add-runtime-configuration) for a full breakdown on configuration.
### Recursion Limit
@@ -449,4 +449,4 @@ Read [this how-to](https://langchain-ai.github.io/langgraph/how-tos/recursion-li
## Visualization
It's often nice to be able to visualize graphs, especially as they get more complex. LangGraph comes with several built-in ways to visualize graphs. See [this how-to guide](../how-tos/visualization.ipynb) for more info.
It's often nice to be able to visualize graphs, especially as they get more complex. LangGraph comes with several built-in ways to visualize graphs. See [this how-to guide](../how-tos/graph-api.ipynb#visualize-your-graph) for more info.
+1 -1
View File
@@ -165,7 +165,7 @@ network = builder.compile()
### Supervisor
In this architecture, we define agents as nodes and add a supervisor node (LLM) that decides which agent nodes should be called next. We use [`Command`](./low_level.md#command) to route execution to the appropriate agent node based on supervisor's decision. This architecture also lends itself well to running multiple agents in parallel or using [map-reduce](../how-tos/map-reduce.ipynb) pattern.
In this architecture, we define agents as nodes and add a supervisor node (LLM) that decides which agent nodes should be called next. We use [`Command`](./low_level.md#command) to route execution to the appropriate agent node based on supervisor's decision. This architecture also lends itself well to running multiple agents in parallel or using [map-reduce](../how-tos/graph-api.ipynb#map-reduce-and-the-send-api) pattern.
```python
from typing import Literal
+2 -2
View File
@@ -29,7 +29,7 @@ Checkpoint is a snapshot of the graph state saved at each super-step and is repr
- `metadata`: Metadata associated with this checkpoint.
- `values`: Values of the state channels at this point in time.
- `next` A tuple of the node names to execute next in the graph.
- `tasks`: A tuple of `PregelTask` objects that contain information about next tasks to be executed. If the step was previously attempted, it will include error information. If a graph was interrupted [dynamically](../how-tos/human_in_the_loop/dynamic_breakpoints.ipynb) from within a node, tasks will contain additional data associated with interrupts.
- `tasks`: A tuple of `PregelTask` objects that contain information about next tasks to be executed. If the step was previously attempted, it will include error information. If a graph was interrupted [dynamically](../how-tos/human_in_the_loop/breakpoints.ipynb#dynamic-breakpoints) from within a node, tasks will contain additional data associated with interrupts.
Let's see what checkpoints are saved when a simple graph is invoked as follows:
@@ -481,7 +481,7 @@ First, checkpointers facilitate [human-in-the-loop workflows](agentic_concepts.m
### Memory
Second, checkpointers allow for ["memory"](agentic_concepts.md#memory) between interactions. In the case of repeated human interactions (like conversations) any follow up messages can be sent to that thread, which will retain its memory of previous ones. See [this how-to guide](../how-tos/memory/manage-conversation-history.ipynb) for an end-to-end example on how to add and manage conversation memory using checkpointers.
Second, checkpointers allow for ["memory"](agentic_concepts.md#memory) between interactions. In the case of repeated human interactions (like conversations) any follow up messages can be sent to that thread, which will retain its memory of previous ones. See [this how-to guide](../how-tos/memory.ipynb) for an end-to-end example on how to add and manage conversation memory using checkpointers.
### Time Travel
+1 -1
View File
@@ -7,7 +7,7 @@ search:
## Overview
LangGraph Platform is a commercial solution for deploying agentic applications in production.
LangGraph Platform is a solution for deploying agentic applications in production.
There are three different plans for using it.
- **Developer**: All [LangSmith](https://smith.langchain.com/) users have access to this plan. You can sign up for this plan simply by creating a LangSmith account. This gives you access to the [Standalone Container (Lite)](./deployment_options.md) deployment option.
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,4 +1,4 @@
# How to add custom authentication
# Add custom authentication
!!! tip "Prerequisites"
+1 -1
View File
@@ -1,4 +1,4 @@
# How to document API authentication in OpenAPI
# Document API authentication in OpenAPI
This guide shows how to customize the OpenAPI security schema for your LangGraph Platform API documentation. A well-documented security schema helps API consumers understand how to authenticate with your API and even enables automatic client generation. See the [Authentication & Access Control conceptual guide](../../concepts/auth.md) for more details about LangGraph's authentication system.
+49
View File
@@ -2677,6 +2677,55 @@
"</details>"
]
},
{
"cell_type": "markdown",
"id": "5a2d23ae-ea3f-478b-8db6-791cd29cfb6c",
"metadata": {},
"source": [
"## Async\n",
"\n",
"Using the [async](https://docs.python.org/3/library/asyncio.html) programming paradigm can produce significant performance improvements when running [IO-bound](https://en.wikipedia.org/wiki/I/O_bound) code concurrently (e.g., making concurrent API requests to a chat model provider).\n",
"\n",
"To convert a `sync` implementation of the graph to an `async` implementation, you will need to:\n",
"\n",
"1. Update `nodes` use `async def` instead of `def`.\n",
"2. Update the code inside to use `await` appropriately.\n",
"3. Invoke the graph with `.ainvoke` or `.astream` as desired.\n",
"\n",
"Because many LangChain objects implement the [Runnable Protocol](https://python.langchain.com/docs/expression_language/interface/) which has `async` variants of all the `sync` methods it's typically fairly quick to upgrade a `sync` graph to an `async` graph.\n",
"\n",
"See example below. To demonstrate async invocations of underlying LLMs, we will include a chat model:\n",
"\n",
"{!snippets/chat_model_tabs.md!}\n",
"\n",
"```python\n",
"from langchain.chat_models import init_chat_model\n",
"from langgraph.graph import MessagesState, StateGraph\n",
"\n",
"\n",
"# highlight-next-line\n",
"async def node(state: MessagesState): # (1)!\n",
" # highlight-next-line\n",
" new_message = await llm.ainvoke(state[\"messages\"]) # (2)!\n",
" return {\"messages\": [new_message]}\n",
"\n",
"\n",
"builder = StateGraph(MessagesState).add_node(node).set_entry_point(\"node\")\n",
"graph = builder.compile()\n",
"\n",
"input_message = {\"role\": \"user\", \"content\": \"Hello\"}\n",
"# highlight-next-line\n",
"result = await graph.ainvoke({\"messages\": [input_message]}) # (3)!\n",
"```\n",
"\n",
"1. Declare nodes to be async functions.\n",
"2. Use async invocations when available within the node.\n",
"3. Use async invocations on the graph object itself.\n",
"\n",
"!!! tip \"Async streaming\"\n",
" See the [streaming guide](../../how-tos/streaming) for examples of streaming with async."
]
},
{
"cell_type": "markdown",
"id": "d33ecddc-6818-41a3-9d0d-b1b1cbcd286d",
@@ -15,7 +15,7 @@ hide:
The [`interrupt` function][langgraph.types.interrupt] in LangGraph enables human-in-the-loop workflows by pausing the graph at a specific node, presenting information to a human, and resuming the graph with their input. It's useful for tasks like approvals, edits, or gathering additional context.
The graph is resumed using a [`Command`](../reference/types.md#langgraph.types.Command) object that provides the human's response.
The graph is resumed using a [`Command`][langgraph.types.Command] object that provides the human's response.
```python
# highlight-next-line
@@ -530,7 +530,7 @@ def human_node(state: State):
When the `interrupt` function is used within a graph, execution pauses at that point and awaits user input.
To resume execution, use the [`Command`](../reference/types.md#langgraph.types.Command) primitive, which can be supplied via the `invoke`, `ainvoke`, `stream`, or `astream` methods.
To resume execution, use the [`Command`][langgraph.types.Command] primitive, which can be supplied via the `invoke`, `ainvoke`, `stream`, or `astream` methods.
**Providing a response to the `interrupt`:**
To continue execution, pass the user's input using `Command(resume=value)`. The graph resumes execution from the beginning of the node where `interrupt(...)` was initially called. This time, the `interrupt` function will return the value provided in `Command(resume=value)` rather than pausing again.
@@ -642,7 +642,7 @@ Place code with side effects, such as API calls, **after** the `interrupt` to av
### Subgraphs called as functions
When invoking a subgraph [as a function](low_level.md#as-a-function), the **parent graph** will resume execution from the **beginning of the node** where the subgraph was invoked (and where an `interrupt` was triggered). Similarly, the **subgraph**, will resume from the **beginning of the node** where the `interrupt()` function was called.
When invoking a subgraph [as a function](../../how-tos/subgraph.ipynb#different-state-schemas), the **parent graph** will resume execution from the **beginning of the node** where the subgraph was invoked (and where an `interrupt` was triggered). Similarly, the **subgraph**, will resume from the **beginning of the node** where the `interrupt()` function was called.
For example,
-29
View File
@@ -530,35 +530,6 @@
" 6. The `user_id` is passed in the config. This is used to identify the user whose information is being updated."
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"ToolMessage(content='294', name='multiply', tool_call_id='1')"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from langchain_core.tools import tool\n",
"\n",
"\n",
"@tool\n",
"def multiply(a: int, b: int) -> int:\n",
" \"\"\"Multiply two numbers.\"\"\"\n",
" return a * b\n",
"\n",
"\n",
"multiply.invoke({\"type\": \"tool_call\", \"id\": \"1\", \"args\": {\"a\": 42, \"b\": 7}})"
]
},
{
"attachments": {},
"cell_type": "markdown",
+46 -32
View File
@@ -1,10 +1,10 @@
# Troubleshooting LangGraph Studio
# LangGraph Studio Troubleshooting
## :fontawesome-brands-safari:{ .safari } Safari connection error with local dev server
## :fontawesome-brands-safari:{ .safari } Safari Connection Issues
Safari blocks plainHTTP traffic on localhost. If you start Studio with a vanilla `langgraph dev`, the page may report a "Failed to load assistants" error and the browser DevTools will show network errors.
Safari blocks plain-HTTP traffic on localhost. When running Studio with `langgraph dev`, you may see "Failed to load assistants" errors.
#### Quick fix — run Studio through a secure Cloudflare tunnel
### Solution 1: Use Cloudflare Tunnel
=== "Python"
@@ -20,42 +20,29 @@ Safari blocks plainHTTP traffic on localhost. If you start Studio with a van
npx @langchain/langgraph-cli dev
```
The command prints a URL like:
The command outputs a URL in this format:
```shell
https://smith.langchain.com/studio/?baseUrl=https://hamilton-praise-heart-costumes.trycloudflare.com
```
where
Use this URL in Safari to load Studio. Here, the `baseUrl` parameter specifies your agent server endpoint.
```shell
?baseUrl=https://hamilton-praise-heart-costumes.trycloudflare.com
```
### Solution 2: Use Chromium Browser
indicates the endpoint where your agent server is exposed. Open that URL in Safari and Studio should load immediately.
Chrome and other Chromium browsers allow HTTP on localhost. Use `langgraph dev` without additional configuration.
#### Alternative — use a Chromiumbased browser
## :fontawesome-brands-brave:{ .brave } Brave Connection Issues
Chrome and other Chromiumbased browsers allow HTTP on localhost, so a plain `langgraph dev` should work without extra steps.
Brave blocks plain-HTTP traffic on localhost when Brave Shields are enabled. When running Studio with `langgraph dev`, you may see "Failed to load assistants" errors.
#### If its still not loading
### Solution 1: Disable Brave Shields
1. Make sure the `baseUrl` query parameter in the studio URL points to the **tunnel URL** NOT to localhost.
2. Confirm your CLI version with `langgraph --version`.
No other configuration, certificates, or CORS tweaks are required.
## :fontawesome-brands-brave:{ .brave } Brave connection error with local dev server
By default, Brave blocks plainHTTP traffic on localhost if Brave Shields are enabled. If you start Studio with a vanilla `langgraph dev`, the page may report a "Failed to load assistants" error and the browser DevTools will show network errors.
#### Quick fix — disable Brave Shields for LangSmith
Click the Brave icon next to the URL bar and turn off the Brave Shields in the popover.
Disable Brave Shields for LangSmith using the Brave icon in the URL bar.
![Brave Shields](./img/brave-shields.png)
#### Alternative — run Studio through a secure Cloudflare tunnel
### Solution 2: Use Cloudflare Tunnel
=== "Python"
@@ -71,16 +58,43 @@ Click the Brave icon next to the URL bar and turn off the Brave Shields in the p
npx @langchain/langgraph-cli dev
```
The command prints a URL like:
The command outputs a URL in this format:
```shell
https://smith.langchain.com/studio/?baseUrl=https://hamilton-praise-heart-costumes.trycloudflare.com
```
where
Use this URL in Brave to load Studio. Here, the `baseUrl` parameter specifies your agent server endpoint.
```shell
?baseUrl=https://hamilton-praise-heart-costumes.trycloudflare.com
## Graph Edge Issues
Undefined conditional edges may show unexpected connections in your graph. This is
because without proper definition, LangGraph Studio assumes the conditional edge could access all other nodes. To address this, explicitly define the routing paths using one of these methods:
### Solution 1: Path Map
Define a mapping between router outputs and target nodes:
=== "Python"
```python
graph.add_conditional_edges("node_a", routing_function, {True: "node_b", False: "node_c"})
```
=== "Javascript"
```ts
graph.addConditionalEdges("node_a", routingFunction, { true: "node_b", false: "node_c" });
```
### Solution 2: Router Type Definition (Python)
Specify possible routing destinations using Python's `Literal` type:
```python
def routing_function(state: GraphState) -> Literal["node_b","node_c"]:
if state['some_condition'] == True:
return "node_b"
else:
return "node_c"
```
indicates the endpoint where your agent server is exposed. Open that URL in Brave and Studio should load immediately.
-78
View File
@@ -1,78 +0,0 @@
---
title: Tutorials
search:
boost: 0.5
---
# Tutorials
New to LangGraph or LLM app development? Read this material to get up and running building your first applications.
## Get Started 🚀 {#quick-start}
- [LangGraph basics](get-started/1-build-basic-chatbot.md): Build a chatbot that can use tools and keep track of conversation history. Add human-in-the-loop capabilities and explore how time-travel works.
- [Common Workflows](workflows/index.md): Overview of the most common workflows using LLMs implemented with LangGraph.
- [LangGraph Server Quickstart](langgraph-platform/local-server.md): Launch a LangGraph server locally and interact with it using REST API and LangGraph Studio Web UI.
- [LangGraph Template Quickstart](../concepts/template_applications.md): Start building with LangGraph Platform using a template application.
- [Deploy with LangGraph Platform Quickstart](../cloud/quick_start.md): Deploy a LangGraph app using LangGraph Platform.
## Use cases 🛠️ {#use-cases}
Explore practical implementations tailored for specific scenarios:
### Chatbots
- [Customer Support](customer-support/customer-support.ipynb): Build a multi-functional support bot for flights, hotels, and car rentals.
- [Prompt Generation from User Requirements](chatbots/information-gather-prompting.ipynb): Build an information gathering chatbot.
- [Code Assistant](code_assistant/langgraph_code_assistant.ipynb): Build a code analysis and generation assistant.
### RAG
- [Agentic RAG](rag/langgraph_agentic_rag.ipynb): Use an agent to figure out how to retrieve the most relevant information before using the retrieved information to answer the user's question.
- [SQL Agent](sql-agent.ipynb): Build a SQL agent that can answer questions about a SQL database.
### Agent Architectures
#### Multi-Agent Systems
- [Network](multi_agent/multi-agent-collaboration.ipynb): Enable two or more agents to collaborate on a task
- [Supervisor](multi_agent/agent_supervisor.ipynb): Use an LLM to orchestrate and delegate to individual agents
#### Planning Agents
- [Plan-and-Execute](plan-and-execute/plan-and-execute.ipynb): Implement a basic planning and execution agent
- [Reasoning without Observation](rewoo/rewoo.ipynb): Reduce re-planning by saving observations as variables
- [LLMCompiler](llm-compiler/LLMCompiler.ipynb): Stream and eagerly execute a DAG of tasks from a planner
#### Reflection & Critique
- [Basic Reflection](reflection/reflection.ipynb): Prompt the agent to reflect on and revise its outputs
- [Reflexion](reflexion/reflexion.ipynb): Critique missing and superfluous details to guide next steps
- [Tree of Thoughts](tot/tot.ipynb): Search over candidate solutions to a problem using a scored tree
- [Language Agent Tree Search](lats/lats.ipynb): Use reflection and rewards to drive a monte-carlo tree search over agents
- [Self-Discover Agent](self-discover/self-discover.ipynb): Analyze an agent that learns about its own capabilities
### Evaluation
- [Agent-based](chatbot-simulation-evaluation/agent-simulation-evaluation.ipynb): Evaluate chatbots via simulated user interactions
- [In LangSmith](chatbot-simulation-evaluation/langsmith-agent-simulation-evaluation.ipynb): Evaluate chatbots in LangSmith over a dialog dataset
### Experimental
- [Web Research (STORM)](storm/storm.ipynb): Generate Wikipedia-like articles via research and multi-perspective QA
- [TNT-LLM](tnt-llm/tnt-llm.ipynb): Build rich, interpretable taxonomies of user intentand using the classification system developed by Microsoft for their Bing Copilot application.
- [Web Navigation](web-navigation/web_voyager.ipynb): Build an agent that can navigate and interact with websites
- [Competitive Programming](usaco/usaco.ipynb): Build an agent with few-shot "episodic memory" and human-in-the-loop collaboration to solve problems from the USA Computing Olympiad; adapted from the ["Can Language Models Solve Olympiad Programming?"](https://arxiv.org/abs/2404.10952v1) paper by Shi, Tang, Narasimhan, and Yao.
- [Complex data extraction](extraction/retries.ipynb): Build an agent that can use function calling to do complex extraction tasks
## LangGraph Platform 🧱 {#platform}
### Authentication & Access Control
Add custom authentication and authorization to an existing LangGraph Platform deployment in the following three-part guide:
1. [Setting Up Custom Authentication](auth/getting_started.md): Implement OAuth2 authentication to authorize users on your deployment
2. [Resource Authorization](auth/resource_auth.md): Let users have private conversations
3. [Connecting an Authentication Provider](auth/add_auth_server.md): Add real user accounts and validate using OAuth2
@@ -8,80 +8,63 @@ Before you begin, ensure you have the following:
- An API key for [LangSmith](https://smith.langchain.com/settings) - free to sign up
This quickstart uses the `react-agent` template and requires the following:
## 1. Create a LangGraph app 🌱
- An API key for [Anthropic](https://console.anthropic.com/)
- An API key for [OpenAI](https://openai.com/)
- An API key [Tavily](https://app.tavily.com/)
Create a new app from the [`new-langgraph-project-python` template](https://github.com/langchain-ai/new-langgraph-project) or [`new-langgraph-project-js` template](https://github.com/langchain-ai/new-langgraphjs-project). This template demonstrates a single-node application you can extend with your own logic.
## 1. Install the LangGraph CLI
```bash
# Python >= 3.11 is required.
pip install --upgrade "langgraph-cli[inmem]"
```
## 2. Create a LangGraph app 🌱
Create a new app from the `react-agent` template. This template is a simple agent that can be flexibly extended to many tools.
=== "Python Server"
=== "Python server"
```shell
langgraph new path/to/your/app --template react-agent-python
langgraph new path/to/your/app --template new-langgraph-project-python
```
=== "Node Server"
=== "Node server"
```shell
langgraph new path/to/your/app --template react-agent-js
langgraph new path/to/your/app --template new-langgraph-project-js
```
!!! tip "Additional templates"
If you use `langgraph new` without specifying a template, you will be presented with an interactive menu that will allow you to choose from a list of available templates.
## 3. Install dependencies
In the root of your new LangGraph app, install the dependencies in `edit` mode so your local changes are used by the server:
## 2. Install dependencies and LangGraph CLI
=== "Python server"
```shell
# Python >= 3.11 is required.
cd path/to/your/app
pip install -e .
pip install -e . "langgraph-cli[inmem]"
```
=== "Node server"
```shell
cd path/to/your/app
npx @langchain/langgraph-cli
yarn install
```
## 4. Create a `.env` file
## 3. Create a `.env` file
You will find a `.env.example` in the root of your new LangGraph app. Create a `.env` file in the root of your new LangGraph app and copy the contents of the `.env.example` file into it, filling in the necessary API keys:
```bash
LANGSMITH_API_KEY=lsv2...
TAVILY_API_KEY=tvly-...
ANTHROPIC_API_KEY=sk-
OPENAI_API_KEY=sk-...
```
## 5. Launch LangGraph Server 🚀
## 4. Launch LangGraph Server 🚀
Start the LangGraph API server locally:
=== "Python Server"
=== "Python server"
```shell
langgraph dev
```
=== "Node Server"
=== "Node server"
```shell
npx @langchain/langgraph-cli dev
@@ -91,17 +74,17 @@ Sample output:
```
> Ready!
>
>
> - API: [http://localhost:2024](http://localhost:2024/)
>
>
> - Docs: http://localhost:2024/docs
>
>
> - LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
```
The `langgraph dev` command starts LangGraph Server in an in-memory mode. This mode is suitable for development and testing purposes. For production use, deploy LangGraph Server with access to a persistent storage backend. For more information, see [Deployment options](../../concepts/deployment_options.md).
## 6. Test your application in LangGraph Studio
## 5. Test your application in LangGraph Studio
[LangGraph Studio](../../concepts/langgraph_studio.md) is a specialized UI that you can connect to LangGraph API server to visualize, interact with, and debug your application locally. Test your graph in LangGraph Studio by visiting the URL provided in the output of the `langgraph dev` command:
@@ -112,14 +95,14 @@ The `langgraph dev` command starts LangGraph Server in an in-memory mode. This m
For a LangGraph Server running on a custom host/port, update the baseURL parameter.
??? info "Safari compatibility"
Use the `--tunnel` flag with your command to create a secure tunnel, as Safari has limitations when connecting to localhost servers:
```shell
langgraph dev --tunnel
```
## 7. Test the API
## 6. Test the API
=== "Python SDK (async)"
@@ -186,6 +169,7 @@ For a LangGraph Server running on a custom host/port, update the baseURL paramet
print("\n\n")
```
=== "Javascript SDK"
1. Install the LangGraph JS SDK:
@@ -239,15 +223,15 @@ For a LangGraph Server running on a custom host/port, update the baseURL paramet
]
},
\"stream_mode\": \"messages-tuple\"
}"
}"
```
## Next Steps
## Next steps
Now that you have a LangGraph app running locally, take your journey further by exploring deployment and advanced features:
- [Deployment quickstart](../../cloud/quick_start.md): Deploy your LangGraph app using LangGraph Platform.
- [LangGraph Platform overview](../../concepts/langgraph_platform.md): Learn about foundational LangGraph Platform concepts.
- [LangGraph Server API Reference](../../cloud/reference/api/api_ref.html): Explore the LangGraph Server API documentation.
- [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 JS/TS SDK API Reference.
+4 -11
View File
@@ -178,15 +178,15 @@ nav:
- Overview: concepts/langgraph_studio.md
- Quickstart: cloud/how-tos/studio/quick_start.md
- cloud/how-tos/invoke_studio.md
- cloud/how-tos/studio/manage_assistants.md
- cloud/how-tos/threads_studio.md
- cloud/how-tos/datasets_studio.md
- cloud/how-tos/iterate_graph_studio.md
- cloud/how-tos/clone_traces_studio.md
- cloud/how-tos/studio/faqs.md
- cloud/how-tos/datasets_studio.md
- LangGraph SDK: concepts/sdk.md
- Data management:
- cloud/deployment/semantic_search.md
- how-tos/ttl/configure_ttl.md
- Add semantic search: cloud/deployment/semantic_search.md
- Add TTLs: how-tos/ttl/configure_ttl.md
- Authentication & access control:
- Overview: concepts/auth.md
- how-tos/auth/custom_auth.md
@@ -277,9 +277,6 @@ nav:
- Agentic RAG: tutorials/rag/langgraph_agentic_rag.ipynb
- Agent Supervisor: tutorials/multi_agent/agent_supervisor.ipynb
- SQL agent: tutorials/sql-agent.ipynb
- Run a graph asynchronously: how-tos/async.ipynb
# We want to push async higher (need to check the content inside it)
# and convert it into a concept rather than a how-to page.
- Graph runs in LangSmith: how-tos/run-id-langsmith.ipynb
- LangGraph Platform:
- Authentication:
@@ -410,10 +407,6 @@ validation:
omitted_files: info
absolute_links: warn
unrecognized_links: warn
# TODO: figure out how to enable 'warn' for this
# it's only an issue for tutorials/storm/storm.ipynb
# because it creates anchors in the generated report
# and those anchors are not available in the actual doc
anchors: warn
# this is needed to handle headers with anchors for nav
not_found: info
-2
View File
@@ -45,7 +45,6 @@
)
```
=== "Google Gemini"
```
@@ -66,7 +65,6 @@
pip install -U "langchain[aws]"
```
```python
import os
from langchain.chat_models import init_chat_model
# Follow the steps here to configure your credentials: