@langchain/langgraph-sdk 0.0.1-rc.11 → 0.0.1-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License
1
+ MIT License
2
2
 
3
- Copyright (c) 2024 LangChain
3
+ Copyright (c) 2024 LangChain, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # LangGraph JS/TS SDK
2
+
3
+ This repository contains the JS/TS SDK for interacting with the LangGraph REST API.
4
+
5
+ ## Quick Start
6
+
7
+ To get started with the JS/TS SDK, [install the package](https://www.npmjs.com/package/@langchain/langgraph-sdk)
8
+
9
+ ```bash
10
+ yarn add @langchain/langgraph-sdk
11
+ ```
12
+
13
+ You will need a running LangGraph API server. If you're running a server locally using `langgraph-cli`, SDK will automatically point at `http://localhost:8123`, otherwise
14
+ you would need to specify the server URL when creating a client.
15
+
16
+ ```js
17
+ import { Client } from "@langchain/langgraph-sdk";
18
+
19
+ const client = new Client();
20
+
21
+ // List all assistants
22
+ const assistants = await client.assistants.search({
23
+ metadata: null,
24
+ offset: 0,
25
+ limit: 10,
26
+ });
27
+
28
+ // We auto-create an assistant for each graph you register in config.
29
+ const agent = assistants[0];
30
+
31
+ // Start a new thread
32
+ const thread = await client.threads.create();
33
+
34
+ // Start a streaming run
35
+ const messages = [{ role: "human", content: "what's the weather in la" }];
36
+
37
+ const streamResponse = client.runs.stream(
38
+ thread["thread_id"],
39
+ agent["assistant_id"],
40
+ {
41
+ input: { messages },
42
+ }
43
+ );
44
+
45
+ for await (const chunk of streamResponse) {
46
+ console.log(chunk);
47
+ }
48
+ ```
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, RunEvent, Thread, ThreadState } from "./schema.js";
1
+ import { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState } from "./schema.js";
2
2
  import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.mjs";
3
3
  import { RunsCreatePayload, RunsStreamPayload, RunsWaitPayload, StreamEvent } from "./types.mjs";
4
4
  interface ClientConfig {
@@ -242,26 +242,6 @@ declare class RunsClient extends BaseClient {
242
242
  * @returns
243
243
  */
244
244
  join(threadId: string, runId: string): Promise<void>;
245
- /**
246
- * List all events for a run.
247
- *
248
- * @param threadId The ID of the thread.
249
- * @param runId The ID of the run.
250
- * @param options Filtering and pagination options.
251
- * @returns List of events.
252
- */
253
- listEvents(threadId: string, runId: string, options?: {
254
- /**
255
- * Maximum number of events to return.
256
- * Defaults to 10
257
- */
258
- limit?: number;
259
- /**
260
- * Offset to start from.
261
- * Defaults to 0.
262
- */
263
- offset?: number;
264
- }): Promise<RunEvent[]>;
265
245
  /**
266
246
  * Delete a run.
267
247
  *
package/dist/client.mjs CHANGED
@@ -65,7 +65,7 @@ class BaseClient {
65
65
  }
66
66
  async fetch(path, options) {
67
67
  const response = await this.asyncCaller.fetch(...this.prepareFetchOptions(path, options));
68
- if (response.status == 202) {
68
+ if (response.status === 202 || response.status === 204) {
69
69
  return undefined;
70
70
  }
71
71
  return response.json();
@@ -439,22 +439,6 @@ class RunsClient extends BaseClient {
439
439
  async join(threadId, runId) {
440
440
  return this.fetch(`/threads/${threadId}/runs/${runId}/join`);
441
441
  }
442
- /**
443
- * List all events for a run.
444
- *
445
- * @param threadId The ID of the thread.
446
- * @param runId The ID of the run.
447
- * @param options Filtering and pagination options.
448
- * @returns List of events.
449
- */
450
- async listEvents(threadId, runId, options) {
451
- return this.fetch(`/threads/${threadId}/runs/${runId}/events`, {
452
- params: {
453
- limit: options?.limit ?? 10,
454
- offset: options?.offset ?? 0,
455
- },
456
- });
457
- }
458
442
  /**
459
443
  * Delete a run.
460
444
  *
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Client } from "./client.mjs";
2
- export type { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, RunEvent, Thread, ThreadState, } from "./schema.js";
2
+ export type { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, } from "./schema.js";
package/dist/schema.d.ts CHANGED
@@ -74,15 +74,4 @@ export interface Run {
74
74
  status: "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
75
75
  metadata: Metadata;
76
76
  }
77
- export interface RunEvent {
78
- event_id: string;
79
- run_id: string;
80
- received_at: string;
81
- span_id: string;
82
- event: string;
83
- name: string;
84
- data: Record<string, unknown>;
85
- metadata: Record<string, unknown>;
86
- tags: string[];
87
- }
88
77
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.1-rc.11",
3
+ "version": "0.0.1-rc.13",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",