From cb2dce4dee22c7161b9ad0ead1e88b1b451d4f1b Mon Sep 17 00:00:00 2001 From: mcgear Date: Wed, 31 Jul 2024 15:04:02 -0600 Subject: [PATCH 1/6] stream to streamEvents --- langchain-core/src/runnables/base.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain-core/src/runnables/base.ts b/langchain-core/src/runnables/base.ts index 4cb65f379f22..b9b61e472075 100644 --- a/langchain-core/src/runnables/base.ts +++ b/langchain-core/src/runnables/base.ts @@ -895,7 +895,7 @@ export abstract class Runnable< const outerThis = this; async function consumeRunnableStream() { try { - const runnableStream = await outerThis.stream(input, config); + const runnableStream = await outerThis.streamEvents(input, config); const tappedStream = eventStreamer.tapOutputIterable( runId, runnableStream From a32e3c26991b61f36147f87b2218721fe9f1a586 Mon Sep 17 00:00:00 2001 From: mcgear Date: Wed, 14 Aug 2024 07:56:09 -0600 Subject: [PATCH 2/6] Fetch impl fix --- langchain-core/src/runnables/remote.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain-core/src/runnables/remote.ts b/langchain-core/src/runnables/remote.ts index 17df845b7472..1ee79849f8a4 100644 --- a/langchain-core/src/runnables/remote.ts +++ b/langchain-core/src/runnables/remote.ts @@ -282,7 +282,7 @@ export class RemoteRunnable< private options?: RemoteRunnableOptions; // eslint-disable-next-line @typescript-eslint/no-explicit-any - fetchImplementation: (...args: any[]) => any = fetch; + fetchImplementation: (...args: any[]) => any = (args) => fetch(args); // eslint-disable-next-line @typescript-eslint/no-explicit-any fetchRequestOptions?: Record; From fd139d9d965d9a9c920815005059ea2e7b76e903 Mon Sep 17 00:00:00 2001 From: mcgear Date: Wed, 14 Aug 2024 07:59:43 -0600 Subject: [PATCH 3/6] switch back --- langchain-core/src/runnables/base.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain-core/src/runnables/base.ts b/langchain-core/src/runnables/base.ts index 88ad852458f8..d79a19a17718 100644 --- a/langchain-core/src/runnables/base.ts +++ b/langchain-core/src/runnables/base.ts @@ -912,7 +912,7 @@ export abstract class Runnable< const outerThis = this; async function consumeRunnableStream() { try { - const runnableStream = await outerThis.streamEvents(input, config); + const runnableStream = await outerThis.stream(input, config); const tappedStream = eventStreamer.tapOutputIterable( runId, runnableStream From 59ad366c77fb3ff7083dac2e14e37953176a763d Mon Sep 17 00:00:00 2001 From: mcgear Date: Wed, 14 Aug 2024 08:00:09 -0600 Subject: [PATCH 4/6] switch back --- langchain-core/src/runnables/base.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain-core/src/runnables/base.ts b/langchain-core/src/runnables/base.ts index 88ad852458f8..d79a19a17718 100644 --- a/langchain-core/src/runnables/base.ts +++ b/langchain-core/src/runnables/base.ts @@ -912,7 +912,7 @@ export abstract class Runnable< const outerThis = this; async function consumeRunnableStream() { try { - const runnableStream = await outerThis.streamEvents(input, config); + const runnableStream = await outerThis.stream(input, config); const tappedStream = eventStreamer.tapOutputIterable( runId, runnableStream From d27930d2223de6a3fc037515aa0a5ead9fae6366 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Thu, 15 Aug 2024 05:48:51 -0700 Subject: [PATCH 5/6] Fix --- langchain-core/src/runnables/remote.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/langchain-core/src/runnables/remote.ts b/langchain-core/src/runnables/remote.ts index 1ee79849f8a4..10cabb4c338a 100644 --- a/langchain-core/src/runnables/remote.ts +++ b/langchain-core/src/runnables/remote.ts @@ -282,7 +282,9 @@ export class RemoteRunnable< private options?: RemoteRunnableOptions; // eslint-disable-next-line @typescript-eslint/no-explicit-any - fetchImplementation: (...args: any[]) => any = (args) => fetch(args); + fetchImplementation: (...args: any[]) => any = (...args: any[]) => + // @ts-expect-error Broad typing to support a range of fetch implementations + fetch(...args); // eslint-disable-next-line @typescript-eslint/no-explicit-any fetchRequestOptions?: Record; From 4453e1a2e1d6de9cfcfda6f80d85d7709b4d0377 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Thu, 15 Aug 2024 05:53:13 -0700 Subject: [PATCH 6/6] Comment --- langchain-core/src/runnables/remote.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/langchain-core/src/runnables/remote.ts b/langchain-core/src/runnables/remote.ts index 10cabb4c338a..4cae2f63d783 100644 --- a/langchain-core/src/runnables/remote.ts +++ b/langchain-core/src/runnables/remote.ts @@ -281,6 +281,9 @@ export class RemoteRunnable< private options?: RemoteRunnableOptions; + // Wrap the default fetch call due to issues with illegal invocations + // from the browser: + // https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err // eslint-disable-next-line @typescript-eslint/no-explicit-any fetchImplementation: (...args: any[]) => any = (...args: any[]) => // @ts-expect-error Broad typing to support a range of fetch implementations