@langchain/langgraph-sdk 0.0.1-rc.0 → 0.0.1-rc.1
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/dist/client.d.mts +145 -32
- package/dist/client.mjs +134 -33
- package/dist/schema.d.ts +6 -3
- package/dist/types.d.mts +44 -0
- package/dist/types.mjs +1 -0
- package/dist/utils/stream.d.mts +2 -1
- package/package.json +1 -1
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Assistant, AssistantGraph, Config, GraphSchema, Metadata, Run, RunEvent, Thread, ThreadState } from "./schema.js";
|
|
2
2
|
import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { RunsCreatePayload, RunsStreamPayload, RunsWaitPayload } from "./types.mjs";
|
|
4
4
|
interface ClientConfig {
|
|
5
5
|
apiUrl?: string;
|
|
6
6
|
callerOptions?: AsyncCallerParams;
|
|
@@ -25,80 +25,193 @@ declare class AssistantsClient extends BaseClient {
|
|
|
25
25
|
getGraph(assistantId: string): Promise<AssistantGraph>;
|
|
26
26
|
getSchemas(assistantId: string): Promise<GraphSchema>;
|
|
27
27
|
create(payload: {
|
|
28
|
-
graphId
|
|
28
|
+
graphId: string;
|
|
29
29
|
config?: Config;
|
|
30
30
|
metadata?: Metadata;
|
|
31
31
|
}): Promise<Assistant>;
|
|
32
32
|
upsert(assistantId: string, payload: {
|
|
33
|
-
graphId
|
|
33
|
+
graphId: string;
|
|
34
34
|
config?: Config;
|
|
35
35
|
metadata?: Metadata;
|
|
36
36
|
}): Promise<Assistant>;
|
|
37
|
-
search(query
|
|
37
|
+
search(query?: {
|
|
38
38
|
metadata?: Metadata;
|
|
39
39
|
limit?: number;
|
|
40
40
|
offset?: number;
|
|
41
41
|
}): Promise<Assistant[]>;
|
|
42
42
|
}
|
|
43
43
|
declare class ThreadsClient extends BaseClient {
|
|
44
|
+
/**
|
|
45
|
+
* Get a thread by ID.
|
|
46
|
+
*
|
|
47
|
+
* @param threadId ID of the thread.
|
|
48
|
+
* @returns The thread.
|
|
49
|
+
*/
|
|
44
50
|
get(threadId: string): Promise<Thread>;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new thread.
|
|
53
|
+
*
|
|
54
|
+
* @param payload Payload for creating a thread.
|
|
55
|
+
* @returns The created thread.
|
|
56
|
+
*/
|
|
45
57
|
create(payload: {
|
|
58
|
+
/**
|
|
59
|
+
* Metadata for the thread.
|
|
60
|
+
*/
|
|
46
61
|
metadata?: Metadata;
|
|
47
62
|
}): Promise<Thread>;
|
|
48
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Update a thread.
|
|
65
|
+
*
|
|
66
|
+
* @param threadId ID of the thread.
|
|
67
|
+
* @param payload Payload for updating the thread.
|
|
68
|
+
* @returns The updated thread.
|
|
69
|
+
*/
|
|
70
|
+
upsert(threadId: string, payload?: {
|
|
71
|
+
/**
|
|
72
|
+
* Metadata for the thread.
|
|
73
|
+
*/
|
|
49
74
|
metadata?: Metadata;
|
|
50
75
|
}): Promise<Thread>;
|
|
76
|
+
/**
|
|
77
|
+
* Delete a thread.
|
|
78
|
+
*
|
|
79
|
+
* @param threadId ID of the thread.
|
|
80
|
+
*/
|
|
51
81
|
delete(threadId: string): Promise<void>;
|
|
52
|
-
|
|
82
|
+
/**
|
|
83
|
+
* List threads
|
|
84
|
+
*
|
|
85
|
+
* @param query Query options
|
|
86
|
+
* @returns List of threads
|
|
87
|
+
*/
|
|
88
|
+
search(query?: {
|
|
89
|
+
/**
|
|
90
|
+
* Metadata to filter threads by.
|
|
91
|
+
*/
|
|
53
92
|
metadata?: Metadata;
|
|
93
|
+
/**
|
|
94
|
+
* Maximum number of threads to return.
|
|
95
|
+
* Defaults to 10
|
|
96
|
+
*/
|
|
54
97
|
limit?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Offset to start from.
|
|
100
|
+
*/
|
|
55
101
|
offset?: number;
|
|
56
102
|
}): Promise<Thread[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Get state for a thread.
|
|
105
|
+
*
|
|
106
|
+
* @param threadId ID of the thread.
|
|
107
|
+
* @returns Thread state.
|
|
108
|
+
*/
|
|
57
109
|
getState(threadId: string): Promise<ThreadState>;
|
|
110
|
+
/**
|
|
111
|
+
* Add state to a thread.
|
|
112
|
+
*
|
|
113
|
+
* @param threadIdOrConfig Thread ID or config that identifies the state to start from.
|
|
114
|
+
* @param values The state update
|
|
115
|
+
* @param options Additional options.
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
58
118
|
updateState(threadIdOrConfig: string | Config, values: Record<string, unknown>, options?: {
|
|
59
119
|
asNode?: string;
|
|
60
120
|
}): Promise<void>;
|
|
61
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Patch the state of a thread.
|
|
123
|
+
*
|
|
124
|
+
* @param threadIdOrConfig Thread ID or config to patch the state of.
|
|
125
|
+
* @param metadata Metadata to patch the state with.
|
|
126
|
+
*/
|
|
127
|
+
patchState(threadIdOrConfig: string | Config, metadata: Metadata): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Get all past states for a thread.
|
|
130
|
+
*
|
|
131
|
+
* @param threadId ID of the thread.
|
|
132
|
+
* @param options Additional options.
|
|
133
|
+
* @returns List of thread states.
|
|
134
|
+
*/
|
|
62
135
|
getHistory(threadId: string, options?: {
|
|
63
136
|
limit?: number;
|
|
64
137
|
before?: Config;
|
|
65
138
|
}): Promise<ThreadState[]>;
|
|
66
139
|
}
|
|
67
140
|
declare class RunsClient extends BaseClient {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Create a run and stream the results.
|
|
143
|
+
*
|
|
144
|
+
* @param threadId The ID of the thread.
|
|
145
|
+
* @param assistantId Assistant ID to use for this run.
|
|
146
|
+
* @param payload Payload for creating a run.
|
|
147
|
+
*/
|
|
148
|
+
stream(threadId: string, assistantId: string, payload?: RunsStreamPayload): AsyncGenerator<{
|
|
76
149
|
event: string;
|
|
77
150
|
data: unknown;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* Create a run.
|
|
154
|
+
*
|
|
155
|
+
* @param threadId The ID of the thread.
|
|
156
|
+
* @param assistantId Assistant ID to use for this run.
|
|
157
|
+
* @param payload Payload for creating a run.
|
|
158
|
+
* @returns The created run.
|
|
159
|
+
*/
|
|
160
|
+
create(threadId: string, assistantId: string, payload?: RunsCreatePayload): Promise<Run>;
|
|
161
|
+
/**
|
|
162
|
+
* Create a run and wait for it to complete.
|
|
163
|
+
*
|
|
164
|
+
* @param threadId The ID of the thread.
|
|
165
|
+
* @param assistantId Assistant ID to use for this run.
|
|
166
|
+
* @param payload Payload for creating a run.
|
|
167
|
+
* @returns The last values chunk of the thread.
|
|
168
|
+
*/
|
|
169
|
+
wait(threadId: string, assistantId: string, payload?: RunsWaitPayload): Promise<ThreadState["values"]>;
|
|
170
|
+
/**
|
|
171
|
+
* List all runs for a thread.
|
|
172
|
+
*
|
|
173
|
+
* @param threadId The ID of the thread.
|
|
174
|
+
* @param options Filtering and pagination options.
|
|
175
|
+
* @returns List of runs.
|
|
176
|
+
*/
|
|
95
177
|
list(threadId: string, options?: {
|
|
178
|
+
/**
|
|
179
|
+
* Maximum number of runs to return.
|
|
180
|
+
* Defaults to 10
|
|
181
|
+
*/
|
|
96
182
|
limit?: number;
|
|
183
|
+
/**
|
|
184
|
+
* Offset to start from.
|
|
185
|
+
* Defaults to 0.
|
|
186
|
+
*/
|
|
97
187
|
offset?: number;
|
|
98
188
|
}): Promise<Run[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Get a run by ID.
|
|
191
|
+
*
|
|
192
|
+
* @param threadId The ID of the thread.
|
|
193
|
+
* @param runId The ID of the run.
|
|
194
|
+
* @returns The run.
|
|
195
|
+
*/
|
|
99
196
|
get(threadId: string, runId: string): Promise<Run>;
|
|
197
|
+
/**
|
|
198
|
+
* List all events for a run.
|
|
199
|
+
*
|
|
200
|
+
* @param threadId The ID of the thread.
|
|
201
|
+
* @param runId The ID of the run.
|
|
202
|
+
* @param options Filtering and pagination options.
|
|
203
|
+
* @returns List of events.
|
|
204
|
+
*/
|
|
100
205
|
listEvents(threadId: string, runId: string, options?: {
|
|
206
|
+
/**
|
|
207
|
+
* Maximum number of events to return.
|
|
208
|
+
* Defaults to 10
|
|
209
|
+
*/
|
|
101
210
|
limit?: number;
|
|
211
|
+
/**
|
|
212
|
+
* Offset to start from.
|
|
213
|
+
* Defaults to 0.
|
|
214
|
+
*/
|
|
102
215
|
offset?: number;
|
|
103
216
|
}): Promise<RunEvent[]>;
|
|
104
217
|
}
|
package/dist/client.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncCaller } from "./utils/async_caller.mjs";
|
|
2
2
|
import { createParser } from "eventsource-parser";
|
|
3
|
-
import { IterableReadableStream
|
|
3
|
+
import { IterableReadableStream } from "./utils/stream.mjs";
|
|
4
4
|
class BaseClient {
|
|
5
5
|
constructor(config) {
|
|
6
6
|
Object.defineProperty(this, "asyncCaller", {
|
|
@@ -71,12 +71,11 @@ class AssistantsClient extends BaseClient {
|
|
|
71
71
|
async create(payload) {
|
|
72
72
|
return this.fetch("/assistants", {
|
|
73
73
|
method: "POST",
|
|
74
|
-
|
|
74
|
+
json: {
|
|
75
75
|
graph_id: payload.graphId,
|
|
76
76
|
config: payload.config,
|
|
77
77
|
metadata: payload.metadata,
|
|
78
|
-
}
|
|
79
|
-
headers: { "Content-Type": "application/json" },
|
|
78
|
+
},
|
|
80
79
|
});
|
|
81
80
|
}
|
|
82
81
|
async upsert(assistantId, payload) {
|
|
@@ -93,53 +92,97 @@ class AssistantsClient extends BaseClient {
|
|
|
93
92
|
return this.fetch("/assistants/search", {
|
|
94
93
|
method: "POST",
|
|
95
94
|
json: {
|
|
96
|
-
metadata: query
|
|
97
|
-
limit: query
|
|
98
|
-
offset: query
|
|
95
|
+
metadata: query?.metadata ?? undefined,
|
|
96
|
+
limit: query?.limit ?? 10,
|
|
97
|
+
offset: query?.offset ?? 0,
|
|
99
98
|
},
|
|
100
99
|
});
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
class ThreadsClient extends BaseClient {
|
|
103
|
+
/**
|
|
104
|
+
* Get a thread by ID.
|
|
105
|
+
*
|
|
106
|
+
* @param threadId ID of the thread.
|
|
107
|
+
* @returns The thread.
|
|
108
|
+
*/
|
|
104
109
|
async get(threadId) {
|
|
105
110
|
return this.fetch(`/threads/${threadId}`);
|
|
106
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Create a new thread.
|
|
114
|
+
*
|
|
115
|
+
* @param payload Payload for creating a thread.
|
|
116
|
+
* @returns The created thread.
|
|
117
|
+
*/
|
|
107
118
|
async create(payload) {
|
|
108
119
|
return this.fetch(`/threads`, {
|
|
109
120
|
method: "POST",
|
|
110
121
|
json: { metadata: payload },
|
|
111
122
|
});
|
|
112
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Update a thread.
|
|
126
|
+
*
|
|
127
|
+
* @param threadId ID of the thread.
|
|
128
|
+
* @param payload Payload for updating the thread.
|
|
129
|
+
* @returns The updated thread.
|
|
130
|
+
*/
|
|
113
131
|
async upsert(threadId, payload) {
|
|
114
132
|
return this.fetch(`/threads/${threadId}`, {
|
|
115
133
|
method: "PUT",
|
|
116
134
|
json: { metadata: payload },
|
|
117
135
|
});
|
|
118
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Delete a thread.
|
|
139
|
+
*
|
|
140
|
+
* @param threadId ID of the thread.
|
|
141
|
+
*/
|
|
119
142
|
async delete(threadId) {
|
|
120
143
|
return this.fetch(`/threads/${threadId}`, {
|
|
121
144
|
method: "DELETE",
|
|
122
145
|
});
|
|
123
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* List threads
|
|
149
|
+
*
|
|
150
|
+
* @param query Query options
|
|
151
|
+
* @returns List of threads
|
|
152
|
+
*/
|
|
124
153
|
async search(query) {
|
|
125
154
|
return this.fetch("/threads/search", {
|
|
126
155
|
method: "POST",
|
|
127
156
|
json: {
|
|
128
|
-
metadata: query
|
|
129
|
-
limit: query
|
|
130
|
-
offset: query
|
|
157
|
+
metadata: query?.metadata ?? undefined,
|
|
158
|
+
limit: query?.limit ?? 10,
|
|
159
|
+
offset: query?.offset ?? 0,
|
|
131
160
|
},
|
|
132
161
|
});
|
|
133
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Get state for a thread.
|
|
165
|
+
*
|
|
166
|
+
* @param threadId ID of the thread.
|
|
167
|
+
* @returns Thread state.
|
|
168
|
+
*/
|
|
134
169
|
async getState(threadId) {
|
|
135
170
|
return this.fetch(`/threads/${threadId}/state`);
|
|
136
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Add state to a thread.
|
|
174
|
+
*
|
|
175
|
+
* @param threadIdOrConfig Thread ID or config that identifies the state to start from.
|
|
176
|
+
* @param values The state update
|
|
177
|
+
* @param options Additional options.
|
|
178
|
+
* @returns
|
|
179
|
+
*/
|
|
137
180
|
async updateState(threadIdOrConfig, values, options) {
|
|
138
181
|
let config = undefined;
|
|
139
182
|
let threadId;
|
|
140
183
|
if (typeof threadIdOrConfig !== "string") {
|
|
141
184
|
config = threadIdOrConfig;
|
|
142
|
-
if (typeof config.configurable
|
|
185
|
+
if (typeof config.configurable?.thread_id !== "string") {
|
|
143
186
|
throw new Error("Thread ID is required when updating state with a config.");
|
|
144
187
|
}
|
|
145
188
|
threadId = config.configurable.thread_id;
|
|
@@ -153,6 +196,12 @@ class ThreadsClient extends BaseClient {
|
|
|
153
196
|
json: { values, config, as_node: options?.asNode },
|
|
154
197
|
});
|
|
155
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Patch the state of a thread.
|
|
201
|
+
*
|
|
202
|
+
* @param threadIdOrConfig Thread ID or config to patch the state of.
|
|
203
|
+
* @param metadata Metadata to patch the state with.
|
|
204
|
+
*/
|
|
156
205
|
async patchState(threadIdOrConfig, metadata) {
|
|
157
206
|
let threadId;
|
|
158
207
|
if (typeof threadIdOrConfig !== "string") {
|
|
@@ -169,6 +218,13 @@ class ThreadsClient extends BaseClient {
|
|
|
169
218
|
json: { metadata: metadata },
|
|
170
219
|
});
|
|
171
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Get all past states for a thread.
|
|
223
|
+
*
|
|
224
|
+
* @param threadId ID of the thread.
|
|
225
|
+
* @param options Additional options.
|
|
226
|
+
* @returns List of thread states.
|
|
227
|
+
*/
|
|
172
228
|
async getHistory(threadId, options) {
|
|
173
229
|
return this.fetch(`/threads/${threadId}/history`, {
|
|
174
230
|
params: {
|
|
@@ -179,17 +235,24 @@ class ThreadsClient extends BaseClient {
|
|
|
179
235
|
}
|
|
180
236
|
}
|
|
181
237
|
class RunsClient extends BaseClient {
|
|
182
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Create a run and stream the results.
|
|
240
|
+
*
|
|
241
|
+
* @param threadId The ID of the thread.
|
|
242
|
+
* @param assistantId Assistant ID to use for this run.
|
|
243
|
+
* @param payload Payload for creating a run.
|
|
244
|
+
*/
|
|
245
|
+
async *stream(threadId, assistantId, payload) {
|
|
183
246
|
const response = await this.asyncCaller.fetch(...this.prepareFetchOptions(`/threads/${threadId}/runs/stream`, {
|
|
184
247
|
method: "POST",
|
|
185
248
|
json: {
|
|
186
|
-
input:
|
|
187
|
-
config:
|
|
188
|
-
metadata:
|
|
189
|
-
stream_mode:
|
|
249
|
+
input: payload?.input,
|
|
250
|
+
config: payload?.config,
|
|
251
|
+
metadata: payload?.metadata,
|
|
252
|
+
stream_mode: payload?.streamMode,
|
|
190
253
|
assistant_id: assistantId,
|
|
191
|
-
interrupt_before:
|
|
192
|
-
interrupt_after:
|
|
254
|
+
interrupt_before: payload?.interruptBefore,
|
|
255
|
+
interrupt_after: payload?.interruptAfter,
|
|
193
256
|
},
|
|
194
257
|
}));
|
|
195
258
|
let parser;
|
|
@@ -203,7 +266,7 @@ class RunsClient extends BaseClient {
|
|
|
203
266
|
}
|
|
204
267
|
if ("data" in event) {
|
|
205
268
|
ctrl.enqueue({
|
|
206
|
-
event: event.event ?? "
|
|
269
|
+
event: event.event ?? "message",
|
|
207
270
|
data: JSON.parse(event.data),
|
|
208
271
|
});
|
|
209
272
|
}
|
|
@@ -213,35 +276,58 @@ class RunsClient extends BaseClient {
|
|
|
213
276
|
parser.feed(textDecoder.decode(chunk));
|
|
214
277
|
},
|
|
215
278
|
}));
|
|
216
|
-
|
|
279
|
+
yield* IterableReadableStream.fromReadableStream(stream);
|
|
217
280
|
}
|
|
218
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Create a run.
|
|
283
|
+
*
|
|
284
|
+
* @param threadId The ID of the thread.
|
|
285
|
+
* @param assistantId Assistant ID to use for this run.
|
|
286
|
+
* @param payload Payload for creating a run.
|
|
287
|
+
* @returns The created run.
|
|
288
|
+
*/
|
|
289
|
+
async create(threadId, assistantId, payload) {
|
|
219
290
|
return this.fetch(`/threads/${threadId}/runs`, {
|
|
220
291
|
method: "POST",
|
|
221
292
|
json: {
|
|
222
|
-
input:
|
|
223
|
-
config:
|
|
224
|
-
metadata:
|
|
293
|
+
input: payload?.input,
|
|
294
|
+
config: payload?.config,
|
|
295
|
+
metadata: payload?.metadata,
|
|
225
296
|
assistant_id: assistantId,
|
|
226
|
-
interrupt_before:
|
|
227
|
-
interrupt_after:
|
|
228
|
-
webhook:
|
|
297
|
+
interrupt_before: payload?.interruptBefore,
|
|
298
|
+
interrupt_after: payload?.interruptAfter,
|
|
299
|
+
webhook: payload?.webhook,
|
|
229
300
|
},
|
|
230
301
|
});
|
|
231
302
|
}
|
|
232
|
-
|
|
303
|
+
/**
|
|
304
|
+
* Create a run and wait for it to complete.
|
|
305
|
+
*
|
|
306
|
+
* @param threadId The ID of the thread.
|
|
307
|
+
* @param assistantId Assistant ID to use for this run.
|
|
308
|
+
* @param payload Payload for creating a run.
|
|
309
|
+
* @returns The last values chunk of the thread.
|
|
310
|
+
*/
|
|
311
|
+
async wait(threadId, assistantId, payload) {
|
|
233
312
|
return this.fetch(`/threads/${threadId}/runs/wait`, {
|
|
234
313
|
method: "POST",
|
|
235
314
|
json: {
|
|
236
|
-
input:
|
|
237
|
-
config:
|
|
238
|
-
metadata:
|
|
315
|
+
input: payload?.input,
|
|
316
|
+
config: payload?.config,
|
|
317
|
+
metadata: payload?.metadata,
|
|
239
318
|
assistant_id: assistantId,
|
|
240
|
-
interrupt_before:
|
|
241
|
-
interrupt_after:
|
|
319
|
+
interrupt_before: payload?.interruptBefore,
|
|
320
|
+
interrupt_after: payload?.interruptAfter,
|
|
242
321
|
},
|
|
243
322
|
});
|
|
244
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* List all runs for a thread.
|
|
326
|
+
*
|
|
327
|
+
* @param threadId The ID of the thread.
|
|
328
|
+
* @param options Filtering and pagination options.
|
|
329
|
+
* @returns List of runs.
|
|
330
|
+
*/
|
|
245
331
|
async list(threadId, options) {
|
|
246
332
|
return this.fetch(`/threads/${threadId}/runs`, {
|
|
247
333
|
params: {
|
|
@@ -250,9 +336,24 @@ class RunsClient extends BaseClient {
|
|
|
250
336
|
},
|
|
251
337
|
});
|
|
252
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Get a run by ID.
|
|
341
|
+
*
|
|
342
|
+
* @param threadId The ID of the thread.
|
|
343
|
+
* @param runId The ID of the run.
|
|
344
|
+
* @returns The run.
|
|
345
|
+
*/
|
|
253
346
|
async get(threadId, runId) {
|
|
254
347
|
return this.fetch(`/threads/${threadId}/runs/${runId}`);
|
|
255
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* List all events for a run.
|
|
351
|
+
*
|
|
352
|
+
* @param threadId The ID of the thread.
|
|
353
|
+
* @param runId The ID of the run.
|
|
354
|
+
* @param options Filtering and pagination options.
|
|
355
|
+
* @returns List of events.
|
|
356
|
+
*/
|
|
256
357
|
async listEvents(threadId, runId, options) {
|
|
257
358
|
return this.fetch(`/threads/${threadId}/runs/${runId}/events`, {
|
|
258
359
|
params: {
|
package/dist/schema.d.ts
CHANGED
|
@@ -4,16 +4,19 @@ export interface Config {
|
|
|
4
4
|
* Tags for this call and any sub-calls (eg. a Chain calling an LLM).
|
|
5
5
|
* You can use these to filter calls.
|
|
6
6
|
*/
|
|
7
|
-
tags
|
|
7
|
+
tags?: string[];
|
|
8
8
|
/**
|
|
9
9
|
* Maximum number of times a call can recurse.
|
|
10
10
|
* If not provided, defaults to 25.
|
|
11
11
|
*/
|
|
12
|
-
recursion_limit
|
|
12
|
+
recursion_limit?: number;
|
|
13
13
|
/**
|
|
14
14
|
* Runtime values for attributes previously made configurable on this Runnable.
|
|
15
15
|
*/
|
|
16
|
-
configurable:
|
|
16
|
+
configurable: {
|
|
17
|
+
thread_id?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
};
|
|
17
20
|
}
|
|
18
21
|
export interface GraphSchema {
|
|
19
22
|
graph_id: string;
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Config, Metadata } from "./schema.js";
|
|
2
|
+
export type StreamMode = "values" | "messages" | "updates" | "events" | "debug";
|
|
3
|
+
interface RunsInvokePayload {
|
|
4
|
+
/**
|
|
5
|
+
* Input to the run. Pass `null` to resume from the current state of the thread.
|
|
6
|
+
*/
|
|
7
|
+
input?: Record<string, unknown> | null;
|
|
8
|
+
/**
|
|
9
|
+
* Metadata for the run.
|
|
10
|
+
*/
|
|
11
|
+
metadata?: Metadata;
|
|
12
|
+
/**
|
|
13
|
+
* Additional configuration for the run.
|
|
14
|
+
*/
|
|
15
|
+
config?: Config;
|
|
16
|
+
/**
|
|
17
|
+
* Interrupt execution before entering these nodes.
|
|
18
|
+
*/
|
|
19
|
+
interruptBefore?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Interrupt execution after leaving these nodes.
|
|
22
|
+
*/
|
|
23
|
+
interruptAfter?: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface RunsStreamPayload extends RunsInvokePayload {
|
|
26
|
+
/**
|
|
27
|
+
* One of `"values"`, `"messages"`, `"updates"` or `"events"`.
|
|
28
|
+
* - `"values"`: Stream the thread state any time it changes.
|
|
29
|
+
* - `"messages"`: Stream chat messages from thread state and calls to chat models,
|
|
30
|
+
* token-by-token where possible.
|
|
31
|
+
* - `"updates"`: Stream the state updates returned by each node.
|
|
32
|
+
* - `"events"`: Stream all events produced by the run. You can also access these
|
|
33
|
+
* afterwards using the `client.runs.listEvents()` method.
|
|
34
|
+
*/
|
|
35
|
+
streamMode?: StreamMode | Array<StreamMode>;
|
|
36
|
+
}
|
|
37
|
+
export interface RunsCreatePayload extends RunsInvokePayload {
|
|
38
|
+
/**
|
|
39
|
+
* Webhook to call when the run is complete.
|
|
40
|
+
*/
|
|
41
|
+
webhook?: string;
|
|
42
|
+
}
|
|
43
|
+
export type RunsWaitPayload = RunsStreamPayload;
|
|
44
|
+
export {};
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/stream.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type IterableReadableStreamInterface<T> = ReadableStream<T> & AsyncIterable<T>;
|
|
2
2
|
export declare class IterableReadableStream<T> extends ReadableStream<T> implements IterableReadableStreamInterface<T> {
|
|
3
3
|
reader: ReadableStreamDefaultReader<T>;
|
|
4
4
|
ensureReader(): void;
|
|
@@ -9,3 +9,4 @@ export declare class IterableReadableStream<T> extends ReadableStream<T> impleme
|
|
|
9
9
|
static fromReadableStream<T>(stream: ReadableStream<T>): IterableReadableStream<T>;
|
|
10
10
|
static fromAsyncGenerator<T>(generator: AsyncGenerator<T>): IterableReadableStream<T>;
|
|
11
11
|
}
|
|
12
|
+
export {};
|