From 1c6b5b2f05ea148d2da2a7aae247445a62909df7 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Sat, 16 Dec 2023 13:41:54 -0800 Subject: [PATCH] Add transform to required methods --- langchain-core/src/runnables/base.ts | 5 +++++ .../src/runnables/tests/runnable_interface.test.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/langchain-core/src/runnables/base.ts b/langchain-core/src/runnables/base.ts index 8a9b73ba133f..e1a1c4c0d815 100644 --- a/langchain-core/src/runnables/base.ts +++ b/langchain-core/src/runnables/base.ts @@ -65,6 +65,11 @@ export interface RunnableInterface< input: RunInput, options?: Partial ): Promise>; + + transform( + generator: AsyncGenerator, + options: Partial + ): AsyncGenerator; } export type RunnableFunc = ( diff --git a/langchain-core/src/runnables/tests/runnable_interface.test.ts b/langchain-core/src/runnables/tests/runnable_interface.test.ts index 0e99a4c19b82..d8c20e3bbe71 100644 --- a/langchain-core/src/runnables/tests/runnable_interface.test.ts +++ b/langchain-core/src/runnables/tests/runnable_interface.test.ts @@ -41,6 +41,11 @@ interface RunnableInterfaceV0 { input: RunInput, options?: Partial ): Promise>; + + transform( + generator: AsyncGenerator, + options: Partial + ): AsyncGenerator; } class IterableReadableStreamV0 extends ReadableStream { @@ -222,6 +227,14 @@ class RunnableV0 ): Promise> { throw new Error("Not implemented"); } + + // eslint-disable-next-line require-yield + async *transform( + _generator: AsyncGenerator, + _options: Partial + ): AsyncGenerator { + throw new Error("Not implemented"); + } } test("Pipe with a class that implements a runnable interface", async () => {