Skip to content

Commit

Permalink
fix(core): Pin TypeScript version for now for export test failures, a…
Browse files Browse the repository at this point in the history
…dd asyncDispose (#6723)
  • Loading branch information
jacoblee93 authored Sep 10, 2024
1 parent 66569b3 commit 93fb71f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions environment_tests/test-exports-tsc/main.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -11,7 +11,7 @@ const prompt = await pull<ChatPromptTemplate>(
"hwchase17/openai-functions-agent"
);

const agent = await createOpenAIFunctionsAgent({
const agent = await createOpenAIToolsAgent({
llm: model,
prompt,
tools: []
Expand Down
5 changes: 1 addition & 4 deletions environment_tests/test-exports-tsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
14 changes: 13 additions & 1 deletion langchain-core/src/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ export class IterableReadableStream<T>
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<T>(stream: ReadableStream<T>) {
// From https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams#reading_the_stream
const reader = stream.getReader();
Expand Down Expand Up @@ -245,7 +251,7 @@ export class AsyncGeneratorWithSetup<
}

async return(
value: TReturn | PromiseLike<TReturn>
value?: TReturn | PromiseLike<TReturn>
): Promise<IteratorResult<T>> {
return this.generator.return(value);
}
Expand All @@ -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<
Expand Down

0 comments on commit 93fb71f

Please sign in to comment.