From 93fb71fc9855f961882d0c67f5199bd9765a1479 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Tue, 10 Sep 2024 11:17:29 -0700 Subject: [PATCH] fix(core): Pin TypeScript version for now for export test failures, add asyncDispose (#6723) --- environment_tests/test-exports-tsc/main.ts | 4 ++-- environment_tests/test-exports-tsc/package.json | 5 +---- langchain-core/src/utils/stream.ts | 14 +++++++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/environment_tests/test-exports-tsc/main.ts b/environment_tests/test-exports-tsc/main.ts index 861bbf86c2db..2303896a168f 100644 --- a/environment_tests/test-exports-tsc/main.ts +++ b/environment_tests/test-exports-tsc/main.ts @@ -1,5 +1,5 @@ import { ChatOpenAI } from "@langchain/openai"; -import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents"; +import { createOpenAIToolsAgent, AgentExecutor } from "langchain/agents"; import { pull } from "langchain/hub"; import type { ChatPromptTemplate } from "@langchain/core/prompts"; @@ -11,7 +11,7 @@ const prompt = await pull( "hwchase17/openai-functions-agent" ); -const agent = await createOpenAIFunctionsAgent({ +const agent = await createOpenAIToolsAgent({ llm: model, prompt, tools: [] diff --git a/environment_tests/test-exports-tsc/package.json b/environment_tests/test-exports-tsc/package.json index 812e01a2516c..0facd117bf18 100644 --- a/environment_tests/test-exports-tsc/package.json +++ b/environment_tests/test-exports-tsc/package.json @@ -20,13 +20,10 @@ "@langchain/core": "workspace:*", "@langchain/openai": "workspace:*", "langchain": "workspace:*", - "typescript": "latest" + "typescript": "5.5.4" }, "devDependencies": { "@types/node": "^18.15.11", "prettier": "^2.8.3" - }, - "resolutions": { - "@langchain/core": "~0.2.0" } } diff --git a/langchain-core/src/utils/stream.ts b/langchain-core/src/utils/stream.ts index 91a9810e2d25..aa9db0604637 100644 --- a/langchain-core/src/utils/stream.ts +++ b/langchain-core/src/utils/stream.ts @@ -71,6 +71,12 @@ export class IterableReadableStream return this; } + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore Not present in Node 18 types, required in latest Node 22 + async [Symbol.asyncDispose]() { + await this.return(); + } + static fromReadableStream(stream: ReadableStream) { // From https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams#reading_the_stream const reader = stream.getReader(); @@ -245,7 +251,7 @@ export class AsyncGeneratorWithSetup< } async return( - value: TReturn | PromiseLike + value?: TReturn | PromiseLike ): Promise> { return this.generator.return(value); } @@ -257,6 +263,12 @@ export class AsyncGeneratorWithSetup< [Symbol.asyncIterator]() { return this; } + + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore Not present in Node 18 types, required in latest Node 22 + async [Symbol.asyncDispose]() { + await this.return(); + } } export async function pipeGeneratorWithSetup<