mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-30 11:49:38 +02:00
small fixes (#1629)
This commit is contained in:
@@ -36,7 +36,8 @@ First let's set up our client and thread:
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
@@ -34,7 +34,8 @@ First, we need to setup our client so that we can communicate with our hosted gr
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
## Find idle threads
|
||||
|
||||
@@ -78,7 +78,8 @@ Then, let's import our required packages and instantiate our client, assistant,
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Now let's start two runs, with the second interrupting the first one with a multitask strategy of "enqueue":
|
||||
|
||||
@@ -43,7 +43,8 @@ In this how-to we use a simple ReAct style hosted graph (you can see the full co
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
## Adding a breakpoint
|
||||
|
||||
@@ -39,7 +39,8 @@ First, we need to setup our client so that we can communicate with our hosted gr
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
## Editing state
|
||||
|
||||
@@ -50,7 +50,8 @@ First, we need to setup our client so that we can communicate with our hosted gr
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
## Example with no review
|
||||
@@ -177,7 +178,7 @@ Let's now look at what it looks like to approve a tool call. Note that we don't
|
||||
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=input,
|
||||
):
|
||||
if chunk.data and chunk.event != "metadata":
|
||||
@@ -278,7 +279,7 @@ To approve the tool call, we can just continue the thread with no edits. To do t
|
||||
```python
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=None,
|
||||
stream_mode="values",
|
||||
):
|
||||
@@ -352,7 +353,7 @@ Let's now say we want to edit the tool call. E.g. change some of the parameters
|
||||
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=input,
|
||||
stream_mode="values",
|
||||
):
|
||||
@@ -465,7 +466,7 @@ To do this, we first need to update the state. We can do this by passing a messa
|
||||
# Let's now continue executing from here
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=None,
|
||||
):
|
||||
if chunk.data and chunk.event != "metadata":
|
||||
@@ -608,7 +609,7 @@ For this example we will just add a single tool call representing the feedback.
|
||||
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=input,
|
||||
):
|
||||
if chunk.data and chunk.event != "metadata":
|
||||
@@ -708,7 +709,7 @@ To do this, we first need to update the state. We can do this by passing a messa
|
||||
# Let's now continue executing from here
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=None,
|
||||
stream_mode="values",
|
||||
):
|
||||
@@ -827,7 +828,7 @@ We can see that we now get to another breakpoint - because it went back to the m
|
||||
```python
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=None,
|
||||
):
|
||||
if chunk.data and chunk.event != "metadata":
|
||||
|
||||
@@ -36,7 +36,8 @@ First, we need to setup our client so that we can communicate with our hosted gr
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
## Replay a state
|
||||
|
||||
@@ -46,7 +46,8 @@ First, we need to setup our client so that we can communicate with our hosted gr
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
## Waiting for user input
|
||||
|
||||
@@ -75,7 +75,8 @@ Now, let's import our required packages and instantiate our client, assistant, a
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Now we can start our two runs and join the second on euntil it has completed:
|
||||
|
||||
@@ -74,7 +74,8 @@ Now, let's import our required packages and instantiate our client, assistant, a
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Now we can run a thread and try to run a second one with the "reject" option, which should fail since we have already started a run:
|
||||
|
||||
@@ -76,7 +76,8 @@ Now, let's import our required packages and instantiate our client, assistant, a
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Now let's run a thread with the multitask parameter set to "rollback":
|
||||
|
||||
@@ -39,7 +39,8 @@ First let's set up our client and thread:
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ This guide covers how to stream events from your graph (`stream_mode="events"`).
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
@@ -71,7 +71,8 @@ First let's set up our client and thread:
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
@@ -35,7 +35,8 @@ First let's set up our client and thread:
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
@@ -10,6 +10,8 @@ First let's set up our client and thread:
|
||||
from langgraph_sdk import get_client
|
||||
|
||||
client = get_client(url=<DEPLOYMENT_URL>)
|
||||
# Using the graph deployed with the name "agent"
|
||||
assistant_id = "agent"
|
||||
# create thread
|
||||
thread = await client.threads.create()
|
||||
print(thread)
|
||||
@@ -21,6 +23,8 @@ First let's set up our client and thread:
|
||||
import { Client } from "@langchain/langgraph-sdk";
|
||||
|
||||
const client = new Client({ apiUrl: <DEPLOYMENT_URL> });
|
||||
// Using the graph deployed with the name "agent"
|
||||
const assistantID = "agent";
|
||||
// create thread
|
||||
const thread = await client.threads.create();
|
||||
console.log(thread);
|
||||
@@ -31,7 +35,8 @@ First let's set up our client and thread:
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Output:
|
||||
@@ -62,7 +67,7 @@ Now we can stream by updates, which outputs updates made to the state by each no
|
||||
}
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=input,
|
||||
stream_mode="updates",
|
||||
):
|
||||
@@ -85,7 +90,7 @@ Now we can stream by updates, which outputs updates made to the state by each no
|
||||
|
||||
const streamResponse = client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistantID,
|
||||
{
|
||||
input,
|
||||
streamMode: "updates"
|
||||
|
||||
@@ -10,6 +10,8 @@ First let's set up our client and thread:
|
||||
from langgraph_sdk import get_client
|
||||
|
||||
client = get_client(url=<DEPLOYMENT_URL>)
|
||||
# Using the graph deployed with the name "agent"
|
||||
assistant_id = "agent"
|
||||
# create thread
|
||||
thread = await client.threads.create()
|
||||
print(thread)
|
||||
@@ -21,6 +23,8 @@ First let's set up our client and thread:
|
||||
import { Client } from "@langchain/langgraph-sdk";
|
||||
|
||||
const client = new Client({ apiUrl: <DEPLOYMENT_URL> });
|
||||
// Using the graph deployed with the name "agent"
|
||||
const assistantID = "agent";
|
||||
// create thread
|
||||
const thread = await client.threads.create();
|
||||
console.log(thread);
|
||||
@@ -31,7 +35,8 @@ First let's set up our client and thread:
|
||||
```bash
|
||||
curl --request POST \
|
||||
--url <DEPLOYMENT_URL>/threads \
|
||||
--header 'Content-Type: application/json'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{}'
|
||||
```
|
||||
|
||||
Output:
|
||||
@@ -56,7 +61,7 @@ Now we can stream by values, which streams the full state of the graph after eac
|
||||
# stream values
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=input,
|
||||
stream_mode="values"
|
||||
):
|
||||
@@ -72,7 +77,7 @@ Now we can stream by values, which streams the full state of the graph after eac
|
||||
|
||||
const streamResponse = client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistantID,
|
||||
{
|
||||
input,
|
||||
streamMode: "values"
|
||||
@@ -164,7 +169,7 @@ If we want to just get the final result, we can use this endpoint and just keep
|
||||
final_answer = None
|
||||
async for chunk in client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistant_id,
|
||||
input=input,
|
||||
stream_mode="values"
|
||||
):
|
||||
@@ -178,7 +183,7 @@ If we want to just get the final result, we can use this endpoint and just keep
|
||||
let finalAnswer;
|
||||
const streamResponse = client.runs.stream(
|
||||
thread["thread_id"],
|
||||
"agent",
|
||||
assistantID,
|
||||
{
|
||||
input,
|
||||
streamMode: "values"
|
||||
|
||||
Reference in New Issue
Block a user