@langchain/core 0.2.23 → 0.2.24
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/runnables/base.d.ts
CHANGED
|
@@ -187,6 +187,7 @@ export declare abstract class Runnable<RunInput = any, RunOutput = any, CallOpti
|
|
|
187
187
|
*
|
|
188
188
|
* **ATTENTION** This reference table is for the V2 version of the schema.
|
|
189
189
|
*
|
|
190
|
+
* ```md
|
|
190
191
|
* +----------------------+------------------+---------------------------------+-----------------------------------------------+-------------------------------------------------+
|
|
191
192
|
* | event | name | chunk | input | output |
|
|
192
193
|
* +======================+==================+=================================+===============================================+=================================================+
|
|
@@ -220,6 +221,7 @@ export declare abstract class Runnable<RunInput = any, RunOutput = any, CallOpti
|
|
|
220
221
|
* +----------------------+------------------+---------------------------------+-----------------------------------------------+-------------------------------------------------+
|
|
221
222
|
* | on_prompt_end | [template_name] | | {"question": "hello"} | ChatPromptValue(messages: [SystemMessage, ...]) |
|
|
222
223
|
* +----------------------+------------------+---------------------------------+-----------------------------------------------+-------------------------------------------------+
|
|
224
|
+
* ```
|
|
223
225
|
*
|
|
224
226
|
* The "on_chain_*" events are the default for Runnables that don't fit one of the above categories.
|
|
225
227
|
*
|
|
@@ -229,6 +231,7 @@ export declare abstract class Runnable<RunInput = any, RunOutput = any, CallOpti
|
|
|
229
231
|
*
|
|
230
232
|
* A custom event has following format:
|
|
231
233
|
*
|
|
234
|
+
* ```md
|
|
232
235
|
* +-----------+------+-----------------------------------------------------------------------------------------------------------+
|
|
233
236
|
* | Attribute | Type | Description |
|
|
234
237
|
* +===========+======+===========================================================================================================+
|
|
@@ -236,9 +239,10 @@ export declare abstract class Runnable<RunInput = any, RunOutput = any, CallOpti
|
|
|
236
239
|
* +-----------+------+-----------------------------------------------------------------------------------------------------------+
|
|
237
240
|
* | data | Any | The data associated with the event. This can be anything, though we suggest making it JSON serializable. |
|
|
238
241
|
* +-----------+------+-----------------------------------------------------------------------------------------------------------+
|
|
242
|
+
* ```
|
|
239
243
|
*
|
|
240
244
|
* Here's an example:
|
|
241
|
-
*
|
|
245
|
+
*
|
|
242
246
|
* ```ts
|
|
243
247
|
* import { RunnableLambda } from "@langchain/core/runnables";
|
|
244
248
|
* import { dispatchCustomEvent } from "@langchain/core/callbacks/dispatch";
|
|
@@ -257,12 +257,17 @@ class RemoteRunnable extends base_js_1.Runnable {
|
|
|
257
257
|
writable: true,
|
|
258
258
|
value: void 0
|
|
259
259
|
});
|
|
260
|
+
// Wrap the default fetch call due to issues with illegal invocations
|
|
261
|
+
// from the browser:
|
|
262
|
+
// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err
|
|
260
263
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
264
|
Object.defineProperty(this, "fetchImplementation", {
|
|
262
265
|
enumerable: true,
|
|
263
266
|
configurable: true,
|
|
264
267
|
writable: true,
|
|
265
|
-
value:
|
|
268
|
+
value: (...args) =>
|
|
269
|
+
// @ts-expect-error Broad typing to support a range of fetch implementations
|
|
270
|
+
fetch(...args)
|
|
266
271
|
});
|
|
267
272
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
268
273
|
Object.defineProperty(this, "fetchRequestOptions", {
|
package/dist/runnables/remote.js
CHANGED
|
@@ -254,12 +254,17 @@ export class RemoteRunnable extends Runnable {
|
|
|
254
254
|
writable: true,
|
|
255
255
|
value: void 0
|
|
256
256
|
});
|
|
257
|
+
// Wrap the default fetch call due to issues with illegal invocations
|
|
258
|
+
// from the browser:
|
|
259
|
+
// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err
|
|
257
260
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
261
|
Object.defineProperty(this, "fetchImplementation", {
|
|
259
262
|
enumerable: true,
|
|
260
263
|
configurable: true,
|
|
261
264
|
writable: true,
|
|
262
|
-
value:
|
|
265
|
+
value: (...args) =>
|
|
266
|
+
// @ts-expect-error Broad typing to support a range of fetch implementations
|
|
267
|
+
fetch(...args)
|
|
263
268
|
});
|
|
264
269
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
270
|
Object.defineProperty(this, "fetchRequestOptions", {
|
package/dist/utils/signal.cjs
CHANGED
|
@@ -5,6 +5,7 @@ async function raceWithSignal(promise, signal) {
|
|
|
5
5
|
if (signal === undefined) {
|
|
6
6
|
return promise;
|
|
7
7
|
}
|
|
8
|
+
let listener;
|
|
8
9
|
return Promise.race([
|
|
9
10
|
promise.catch((err) => {
|
|
10
11
|
if (!signal?.aborted) {
|
|
@@ -15,14 +16,15 @@ async function raceWithSignal(promise, signal) {
|
|
|
15
16
|
}
|
|
16
17
|
}),
|
|
17
18
|
new Promise((_, reject) => {
|
|
18
|
-
|
|
19
|
+
listener = () => {
|
|
19
20
|
reject(new Error("Aborted"));
|
|
20
|
-
}
|
|
21
|
+
};
|
|
22
|
+
signal.addEventListener("abort", listener);
|
|
21
23
|
// Must be here inside the promise to avoid a race condition
|
|
22
24
|
if (signal.aborted) {
|
|
23
25
|
reject(new Error("Aborted"));
|
|
24
26
|
}
|
|
25
27
|
}),
|
|
26
|
-
]);
|
|
28
|
+
]).finally(() => signal.removeEventListener("abort", listener));
|
|
27
29
|
}
|
|
28
30
|
exports.raceWithSignal = raceWithSignal;
|
package/dist/utils/signal.js
CHANGED
|
@@ -2,6 +2,7 @@ export async function raceWithSignal(promise, signal) {
|
|
|
2
2
|
if (signal === undefined) {
|
|
3
3
|
return promise;
|
|
4
4
|
}
|
|
5
|
+
let listener;
|
|
5
6
|
return Promise.race([
|
|
6
7
|
promise.catch((err) => {
|
|
7
8
|
if (!signal?.aborted) {
|
|
@@ -12,13 +13,14 @@ export async function raceWithSignal(promise, signal) {
|
|
|
12
13
|
}
|
|
13
14
|
}),
|
|
14
15
|
new Promise((_, reject) => {
|
|
15
|
-
|
|
16
|
+
listener = () => {
|
|
16
17
|
reject(new Error("Aborted"));
|
|
17
|
-
}
|
|
18
|
+
};
|
|
19
|
+
signal.addEventListener("abort", listener);
|
|
18
20
|
// Must be here inside the promise to avoid a race condition
|
|
19
21
|
if (signal.aborted) {
|
|
20
22
|
reject(new Error("Aborted"));
|
|
21
23
|
}
|
|
22
24
|
}),
|
|
23
|
-
]);
|
|
25
|
+
]).finally(() => signal.removeEventListener("abort", listener));
|
|
24
26
|
}
|