[docs]: adding js/curl tabs (#1558)

* jsifying

* x

* z

* x

* fix background run output

* reformatting

* z

* z

* z

* z

* z

* add tabs to stream debug

* default urls
This commit is contained in:
Isaac Francisco
2024-09-04 22:13:19 +00:00
committed by GitHub
parent 82c989feea
commit 1774dbb860
34 changed files with 2489 additions and 1416 deletions
+23 -17
View File
@@ -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,9 +23,11 @@ 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)
console.log(thread);
```
=== "CURL"
@@ -36,12 +40,15 @@ First let's set up our client and thread:
Output:
{'thread_id': 'bfc68029-1f7b-400f-beab-6f9032a52da4',
'created_at': '2024-06-24T21:30:07.980789+00:00',
'updated_at': '2024-06-24T21:30:07.980789+00:00',
'metadata': {},
'status': 'idle',
'config': {}}
{
'thread_id': 'bfc68029-1f7b-400f-beab-6f9032a52da4',
'created_at': '2024-06-24T21:30:07.980789+00:00',
'updated_at': '2024-06-24T21:30:07.980789+00:00',
'metadata': {},
'status': 'idle',
'config': {},
'values': None
}
When configuring multiple streaming modes for a run, responses for each respective mode will be produced. In the following example, note that a `list` of modes (`messages`, `events`, `debug`) is passed to the `stream_mode` parameter and the response contains `events`, `debug`, `messages/complete`, `messages/metadata`, and `messages/partial` event types.
@@ -61,7 +68,7 @@ When configuring multiple streaming modes for a run, responses for each respecti
# stream events with multiple streaming modes
async for chunk in client.runs.stream(
thread_id=thread["thread_id"],
assistant_id="agent",
assistant_id=assistant_id,
input=input,
stream_mode=["messages", "events", "debug"],
):
@@ -75,27 +82,27 @@ When configuring multiple streaming modes for a run, responses for each respecti
```js
// create input
const input = {
"messages": [
messages: [
{
"role": "human",
"content": "What's the weather in SF?",
role: "human",
content: "What's the weather in SF?",
}
]
}
};
// stream events with multiple streaming modes
const streamResponse = client.runs.stream(
thread["thread_id"],
"agent",
assistantID,
{
input,
streamMode: ["messages", "events", "debug"]
}
);
for await (const chunk of streamResponse) {
console.log(f"Receiving new event of type: {chunk.event}...")
console.log(chunk.data)
console.log("\n\n")
console.log(`Receiving new event of type: ${chunk.event}...`);
console.log(chunk.data);
console.log("\n\n");
}
```
@@ -482,5 +489,4 @@ Output:
None