@langchain/langgraph-sdk 0.1.8 → 0.1.10
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/CHANGELOG.md +12 -0
- package/dist/client.cjs +2 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -1
- package/dist/react/stream.lgp.cjs +15 -12
- package/dist/react/stream.lgp.js +15 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @langchain/langgraph-sdk
|
|
2
2
|
|
|
3
|
+
## 0.1.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 47cdce7: Fix stale values being received by optimistic values callback in `stream.submit(...)`
|
|
8
|
+
|
|
9
|
+
## 0.1.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 02beb41: Add support for creating stateless runs
|
|
14
|
+
|
|
3
15
|
## 0.1.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/client.cjs
CHANGED
|
@@ -788,7 +788,8 @@ class RunsClient extends BaseClient {
|
|
|
788
788
|
}
|
|
789
789
|
: undefined,
|
|
790
790
|
};
|
|
791
|
-
const
|
|
791
|
+
const endpoint = threadId === null ? "/runs" : `/threads/${threadId}/runs`;
|
|
792
|
+
const [run, response] = await this.fetch(endpoint, {
|
|
792
793
|
method: "POST",
|
|
793
794
|
json,
|
|
794
795
|
signal: payload?.signal,
|
package/dist/client.d.ts
CHANGED
|
@@ -417,7 +417,7 @@ export declare class RunsClient<TStateType = DefaultValues, TUpdateType = TState
|
|
|
417
417
|
* @param payload Payload for creating a run.
|
|
418
418
|
* @returns The created run.
|
|
419
419
|
*/
|
|
420
|
-
create(threadId: string, assistantId: string, payload?: RunsCreatePayload): Promise<Run>;
|
|
420
|
+
create(threadId: string | null, assistantId: string, payload?: RunsCreatePayload): Promise<Run>;
|
|
421
421
|
/**
|
|
422
422
|
* Create a batch of stateless background runs.
|
|
423
423
|
*
|
package/dist/client.js
CHANGED
|
@@ -780,7 +780,8 @@ export class RunsClient extends BaseClient {
|
|
|
780
780
|
}
|
|
781
781
|
: undefined,
|
|
782
782
|
};
|
|
783
|
-
const
|
|
783
|
+
const endpoint = threadId === null ? "/runs" : `/threads/${threadId}/runs`;
|
|
784
|
+
const [run, response] = await this.fetch(endpoint, {
|
|
784
785
|
method: "POST",
|
|
785
786
|
json,
|
|
786
787
|
signal: payload?.signal,
|
|
@@ -250,20 +250,29 @@ function useStreamLGP(options) {
|
|
|
250
250
|
setBranch(checkpointId != null
|
|
251
251
|
? branchContext.branchByCheckpoint[checkpointId]?.branch ?? ""
|
|
252
252
|
: "");
|
|
253
|
+
// When `fetchStateHistory` is requested, thus we assume that branching
|
|
254
|
+
// is enabled. We then need to include the implicit branch.
|
|
255
|
+
const includeImplicitBranch = historyLimit === true || typeof historyLimit === "number";
|
|
256
|
+
const shouldRefetch =
|
|
257
|
+
// We're expecting the whole thread state in onFinish
|
|
258
|
+
options.onFinish != null ||
|
|
259
|
+
// We're fetching history, thus we need the latest checkpoint
|
|
260
|
+
// to ensure we're not accidentally submitting to a wrong branch
|
|
261
|
+
includeImplicitBranch;
|
|
253
262
|
stream.setStreamValues(() => {
|
|
263
|
+
const prev = shouldRefetch
|
|
264
|
+
? historyValues
|
|
265
|
+
: { ...historyValues, ...stream.values };
|
|
254
266
|
if (submitOptions?.optimisticValues != null) {
|
|
255
267
|
return {
|
|
256
|
-
...
|
|
268
|
+
...prev,
|
|
257
269
|
...(typeof submitOptions.optimisticValues === "function"
|
|
258
|
-
? submitOptions.optimisticValues(
|
|
270
|
+
? submitOptions.optimisticValues(prev)
|
|
259
271
|
: submitOptions.optimisticValues),
|
|
260
272
|
};
|
|
261
273
|
}
|
|
262
|
-
return { ...
|
|
274
|
+
return { ...prev };
|
|
263
275
|
});
|
|
264
|
-
// When `fetchStateHistory` is requested, thus we assume that branching
|
|
265
|
-
// is enabled. We then need to include the implicit branch.
|
|
266
|
-
const includeImplicitBranch = historyLimit === true || typeof historyLimit === "number";
|
|
267
276
|
let callbackMeta;
|
|
268
277
|
let rejoinKey;
|
|
269
278
|
let usableThreadId = threadId;
|
|
@@ -341,12 +350,6 @@ function useStreamLGP(options) {
|
|
|
341
350
|
async onSuccess() {
|
|
342
351
|
if (rejoinKey)
|
|
343
352
|
runMetadataStorage?.removeItem(rejoinKey);
|
|
344
|
-
const shouldRefetch =
|
|
345
|
-
// We're expecting the whole thread state in onFinish
|
|
346
|
-
options.onFinish != null ||
|
|
347
|
-
// We're fetching history, thus we need the latest checkpoint
|
|
348
|
-
// to ensure we're not accidentally submitting to a wrong branch
|
|
349
|
-
includeImplicitBranch;
|
|
350
353
|
if (shouldRefetch) {
|
|
351
354
|
const newHistory = await history.mutate(usableThreadId);
|
|
352
355
|
const lastHead = newHistory?.at(0);
|
package/dist/react/stream.lgp.js
CHANGED
|
@@ -246,20 +246,29 @@ export function useStreamLGP(options) {
|
|
|
246
246
|
setBranch(checkpointId != null
|
|
247
247
|
? branchContext.branchByCheckpoint[checkpointId]?.branch ?? ""
|
|
248
248
|
: "");
|
|
249
|
+
// When `fetchStateHistory` is requested, thus we assume that branching
|
|
250
|
+
// is enabled. We then need to include the implicit branch.
|
|
251
|
+
const includeImplicitBranch = historyLimit === true || typeof historyLimit === "number";
|
|
252
|
+
const shouldRefetch =
|
|
253
|
+
// We're expecting the whole thread state in onFinish
|
|
254
|
+
options.onFinish != null ||
|
|
255
|
+
// We're fetching history, thus we need the latest checkpoint
|
|
256
|
+
// to ensure we're not accidentally submitting to a wrong branch
|
|
257
|
+
includeImplicitBranch;
|
|
249
258
|
stream.setStreamValues(() => {
|
|
259
|
+
const prev = shouldRefetch
|
|
260
|
+
? historyValues
|
|
261
|
+
: { ...historyValues, ...stream.values };
|
|
250
262
|
if (submitOptions?.optimisticValues != null) {
|
|
251
263
|
return {
|
|
252
|
-
...
|
|
264
|
+
...prev,
|
|
253
265
|
...(typeof submitOptions.optimisticValues === "function"
|
|
254
|
-
? submitOptions.optimisticValues(
|
|
266
|
+
? submitOptions.optimisticValues(prev)
|
|
255
267
|
: submitOptions.optimisticValues),
|
|
256
268
|
};
|
|
257
269
|
}
|
|
258
|
-
return { ...
|
|
270
|
+
return { ...prev };
|
|
259
271
|
});
|
|
260
|
-
// When `fetchStateHistory` is requested, thus we assume that branching
|
|
261
|
-
// is enabled. We then need to include the implicit branch.
|
|
262
|
-
const includeImplicitBranch = historyLimit === true || typeof historyLimit === "number";
|
|
263
272
|
let callbackMeta;
|
|
264
273
|
let rejoinKey;
|
|
265
274
|
let usableThreadId = threadId;
|
|
@@ -337,12 +346,6 @@ export function useStreamLGP(options) {
|
|
|
337
346
|
async onSuccess() {
|
|
338
347
|
if (rejoinKey)
|
|
339
348
|
runMetadataStorage?.removeItem(rejoinKey);
|
|
340
|
-
const shouldRefetch =
|
|
341
|
-
// We're expecting the whole thread state in onFinish
|
|
342
|
-
options.onFinish != null ||
|
|
343
|
-
// We're fetching history, thus we need the latest checkpoint
|
|
344
|
-
// to ensure we're not accidentally submitting to a wrong branch
|
|
345
|
-
includeImplicitBranch;
|
|
346
349
|
if (shouldRefetch) {
|
|
347
350
|
const newHistory = await history.mutate(usableThreadId);
|
|
348
351
|
const lastHead = newHistory?.at(0);
|