@langchain/langgraph-sdk 0.0.1-rc.12 → 0.0.1-rc.14

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,64 @@
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
+ ```
49
+
50
+ ## Documentation
51
+
52
+ To generate documentation, run the following commands:
53
+
54
+ 1. Generate docs.
55
+
56
+ yarn typedoc
57
+
58
+ 1. Consolidate doc files into one markdown file.
59
+
60
+ npx concat-md --decrease-title-levels --ignore=js_ts_sdk_ref.md --start-title-level-at 2 docs > docs/js_ts_sdk_ref.md
61
+
62
+ 1. Copy `js_ts_sdk_ref.md` to MkDocs directory.
63
+
64
+ cp docs/js_ts_sdk_ref.md ../../docs/docs/cloud/reference/sdk/js_ts_sdk_ref.md
@@ -11,6 +11,12 @@ export interface AsyncCallerParams {
11
11
  */
12
12
  maxRetries?: number;
13
13
  onFailedResponseHook?: ResponseCallback;
14
+ /**
15
+ * Specify a custom fetch implementation.
16
+ *
17
+ * By default we expect the `fetch` is available in the global scope.
18
+ */
19
+ fetch?: typeof fetch;
14
20
  }
15
21
  export interface AsyncCallerCallOptions {
16
22
  signal?: AbortSignal;
@@ -33,6 +39,7 @@ export declare class AsyncCaller {
33
39
  protected maxRetries: AsyncCallerParams["maxRetries"];
34
40
  private queue;
35
41
  private onFailedResponseHook?;
42
+ private customFetch?;
36
43
  constructor(params: AsyncCallerParams);
37
44
  call<A extends any[], T extends (...args: A) => Promise<any>>(callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
38
45
  callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(options: AsyncCallerCallOptions, callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
@@ -99,6 +99,12 @@ export class AsyncCaller {
99
99
  writable: true,
100
100
  value: void 0
101
101
  });
102
+ Object.defineProperty(this, "customFetch", {
103
+ enumerable: true,
104
+ configurable: true,
105
+ writable: true,
106
+ value: void 0
107
+ });
102
108
  this.maxConcurrency = params.maxConcurrency ?? Infinity;
103
109
  this.maxRetries = params.maxRetries ?? 4;
104
110
  if ("default" in PQueueMod) {
@@ -112,6 +118,7 @@ export class AsyncCaller {
112
118
  this.queue = new PQueueMod({ concurrency: this.maxConcurrency });
113
119
  }
114
120
  this.onFailedResponseHook = params?.onFailedResponseHook;
121
+ this.customFetch = params.fetch;
115
122
  }
116
123
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
124
  call(callable, ...args) {
@@ -175,6 +182,7 @@ export class AsyncCaller {
175
182
  return this.call(callable, ...args);
176
183
  }
177
184
  fetch(...args) {
178
- return this.call(() => fetch(...args).then((res) => (res.ok ? res : Promise.reject(res))));
185
+ const fetchFn = this.customFetch ?? fetch;
186
+ return this.call(() => fetchFn(...args).then((res) => (res.ok ? res : Promise.reject(res))));
179
187
  }
180
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.1-rc.12",
3
+ "version": "0.0.1-rc.14",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",
@@ -26,7 +26,10 @@
26
26
  "@tsconfig/recommended": "^1.0.2",
27
27
  "@types/node": "^20.12.12",
28
28
  "@types/uuid": "^9.0.1",
29
+ "concat-md": "^0.5.1",
29
30
  "prettier": "^3.2.5",
31
+ "typedoc": "^0.26.1",
32
+ "typedoc-plugin-markdown": "^4.1.0",
30
33
  "typescript": "^5.4.5"
31
34
  },
32
35
  "exports": {