Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Pin TypeScript version for now for export test failures, add asyncDispose #6723

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading