@langchain/langgraph-sdk 0.0.86 → 0.0.87
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.cjs +30 -1
- package/dist/client.d.ts +8 -0
- package/dist/client.js +28 -0
- package/dist/react/stream.cjs +5 -1
- package/dist/react/stream.js +6 -2
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Client = exports.StoreClient = exports.RunsClient = exports.ThreadsClient = exports.AssistantsClient = exports.CronsClient = exports.getApiKey = void 0;
|
|
3
|
+
exports.getClientConfigHash = exports.Client = exports.StoreClient = exports.RunsClient = exports.ThreadsClient = exports.AssistantsClient = exports.CronsClient = exports.getApiKey = void 0;
|
|
4
4
|
const async_caller_js_1 = require("./utils/async_caller.cjs");
|
|
5
5
|
const env_js_1 = require("./utils/env.cjs");
|
|
6
6
|
const signals_js_1 = require("./utils/signals.cjs");
|
|
@@ -1156,6 +1156,28 @@ class Client {
|
|
|
1156
1156
|
writable: true,
|
|
1157
1157
|
value: void 0
|
|
1158
1158
|
});
|
|
1159
|
+
/**
|
|
1160
|
+
* @internal Used to obtain a stable key representing the client.
|
|
1161
|
+
*/
|
|
1162
|
+
Object.defineProperty(this, "~configHash", {
|
|
1163
|
+
enumerable: true,
|
|
1164
|
+
configurable: true,
|
|
1165
|
+
writable: true,
|
|
1166
|
+
value: void 0
|
|
1167
|
+
});
|
|
1168
|
+
this["~configHash"] = (() => JSON.stringify({
|
|
1169
|
+
apiUrl: config?.apiUrl,
|
|
1170
|
+
apiKey: config?.apiKey,
|
|
1171
|
+
timeoutMs: config?.timeoutMs,
|
|
1172
|
+
defaultHeaders: config?.defaultHeaders,
|
|
1173
|
+
maxConcurrency: config?.callerOptions?.maxConcurrency,
|
|
1174
|
+
maxRetries: config?.callerOptions?.maxRetries,
|
|
1175
|
+
callbacks: {
|
|
1176
|
+
onFailedResponseHook: config?.callerOptions?.onFailedResponseHook != null,
|
|
1177
|
+
onRequest: config?.onRequest != null,
|
|
1178
|
+
fetch: config?.callerOptions?.fetch != null,
|
|
1179
|
+
},
|
|
1180
|
+
}))();
|
|
1159
1181
|
this.assistants = new AssistantsClient(config);
|
|
1160
1182
|
this.threads = new ThreadsClient(config);
|
|
1161
1183
|
this.runs = new RunsClient(config);
|
|
@@ -1165,3 +1187,10 @@ class Client {
|
|
|
1165
1187
|
}
|
|
1166
1188
|
}
|
|
1167
1189
|
exports.Client = Client;
|
|
1190
|
+
/**
|
|
1191
|
+
* @internal Used to obtain a stable key representing the client.
|
|
1192
|
+
*/
|
|
1193
|
+
function getClientConfigHash(client) {
|
|
1194
|
+
return client["~configHash"];
|
|
1195
|
+
}
|
|
1196
|
+
exports.getClientConfigHash = getClientConfigHash;
|
package/dist/client.d.ts
CHANGED
|
@@ -596,6 +596,14 @@ export declare class Client<TStateType = DefaultValues, TUpdateType = TStateType
|
|
|
596
596
|
* @internal Used by LoadExternalComponent and the API might change in the future.
|
|
597
597
|
*/
|
|
598
598
|
"~ui": UiClient;
|
|
599
|
+
/**
|
|
600
|
+
* @internal Used to obtain a stable key representing the client.
|
|
601
|
+
*/
|
|
602
|
+
private "~configHash";
|
|
599
603
|
constructor(config?: ClientConfig);
|
|
600
604
|
}
|
|
605
|
+
/**
|
|
606
|
+
* @internal Used to obtain a stable key representing the client.
|
|
607
|
+
*/
|
|
608
|
+
export declare function getClientConfigHash(client: Client): string | undefined;
|
|
601
609
|
export {};
|
package/dist/client.js
CHANGED
|
@@ -1147,6 +1147,28 @@ export class Client {
|
|
|
1147
1147
|
writable: true,
|
|
1148
1148
|
value: void 0
|
|
1149
1149
|
});
|
|
1150
|
+
/**
|
|
1151
|
+
* @internal Used to obtain a stable key representing the client.
|
|
1152
|
+
*/
|
|
1153
|
+
Object.defineProperty(this, "~configHash", {
|
|
1154
|
+
enumerable: true,
|
|
1155
|
+
configurable: true,
|
|
1156
|
+
writable: true,
|
|
1157
|
+
value: void 0
|
|
1158
|
+
});
|
|
1159
|
+
this["~configHash"] = (() => JSON.stringify({
|
|
1160
|
+
apiUrl: config?.apiUrl,
|
|
1161
|
+
apiKey: config?.apiKey,
|
|
1162
|
+
timeoutMs: config?.timeoutMs,
|
|
1163
|
+
defaultHeaders: config?.defaultHeaders,
|
|
1164
|
+
maxConcurrency: config?.callerOptions?.maxConcurrency,
|
|
1165
|
+
maxRetries: config?.callerOptions?.maxRetries,
|
|
1166
|
+
callbacks: {
|
|
1167
|
+
onFailedResponseHook: config?.callerOptions?.onFailedResponseHook != null,
|
|
1168
|
+
onRequest: config?.onRequest != null,
|
|
1169
|
+
fetch: config?.callerOptions?.fetch != null,
|
|
1170
|
+
},
|
|
1171
|
+
}))();
|
|
1150
1172
|
this.assistants = new AssistantsClient(config);
|
|
1151
1173
|
this.threads = new ThreadsClient(config);
|
|
1152
1174
|
this.runs = new RunsClient(config);
|
|
@@ -1155,3 +1177,9 @@ export class Client {
|
|
|
1155
1177
|
this["~ui"] = new UiClient(config);
|
|
1156
1178
|
}
|
|
1157
1179
|
}
|
|
1180
|
+
/**
|
|
1181
|
+
* @internal Used to obtain a stable key representing the client.
|
|
1182
|
+
*/
|
|
1183
|
+
export function getClientConfigHash(client) {
|
|
1184
|
+
return client["~configHash"];
|
|
1185
|
+
}
|
package/dist/react/stream.cjs
CHANGED
|
@@ -174,8 +174,12 @@ function fetchHistory(client, threadId) {
|
|
|
174
174
|
}
|
|
175
175
|
function useThreadHistory(threadId, client, clearCallbackRef, submittingRef) {
|
|
176
176
|
const [history, setHistory] = (0, react_1.useState)([]);
|
|
177
|
+
const clientHash = (0, client_js_1.getClientConfigHash)(client);
|
|
178
|
+
const clientRef = (0, react_1.useRef)(client);
|
|
179
|
+
clientRef.current = client;
|
|
177
180
|
const fetcher = (0, react_1.useCallback)((threadId) => {
|
|
178
181
|
if (threadId != null) {
|
|
182
|
+
const client = clientRef.current;
|
|
179
183
|
return fetchHistory(client, threadId).then((history) => {
|
|
180
184
|
setHistory(history);
|
|
181
185
|
return history;
|
|
@@ -189,7 +193,7 @@ function useThreadHistory(threadId, client, clearCallbackRef, submittingRef) {
|
|
|
189
193
|
if (submittingRef.current)
|
|
190
194
|
return;
|
|
191
195
|
fetcher(threadId);
|
|
192
|
-
}, [fetcher, submittingRef, threadId]);
|
|
196
|
+
}, [fetcher, clientHash, submittingRef, threadId]);
|
|
193
197
|
return {
|
|
194
198
|
data: history,
|
|
195
199
|
mutate: (mutateId) => fetcher(mutateId ?? threadId),
|
package/dist/react/stream.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */
|
|
2
2
|
"use client";
|
|
3
|
-
import { Client } from "../client.js";
|
|
3
|
+
import { Client, getClientConfigHash } from "../client.js";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
5
5
|
import { coerceMessageLikeToMessage, convertToChunk, isBaseMessageChunk, } from "@langchain/core/messages";
|
|
6
6
|
class StreamError extends Error {
|
|
@@ -171,8 +171,12 @@ function fetchHistory(client, threadId) {
|
|
|
171
171
|
}
|
|
172
172
|
function useThreadHistory(threadId, client, clearCallbackRef, submittingRef) {
|
|
173
173
|
const [history, setHistory] = useState([]);
|
|
174
|
+
const clientHash = getClientConfigHash(client);
|
|
175
|
+
const clientRef = useRef(client);
|
|
176
|
+
clientRef.current = client;
|
|
174
177
|
const fetcher = useCallback((threadId) => {
|
|
175
178
|
if (threadId != null) {
|
|
179
|
+
const client = clientRef.current;
|
|
176
180
|
return fetchHistory(client, threadId).then((history) => {
|
|
177
181
|
setHistory(history);
|
|
178
182
|
return history;
|
|
@@ -186,7 +190,7 @@ function useThreadHistory(threadId, client, clearCallbackRef, submittingRef) {
|
|
|
186
190
|
if (submittingRef.current)
|
|
187
191
|
return;
|
|
188
192
|
fetcher(threadId);
|
|
189
|
-
}, [fetcher, submittingRef, threadId]);
|
|
193
|
+
}, [fetcher, clientHash, submittingRef, threadId]);
|
|
190
194
|
return {
|
|
191
195
|
data: history,
|
|
192
196
|
mutate: (mutateId) => fetcher(mutateId ?? threadId),
|