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

langchain[patch]: Miscellaneous test fixes #3497

Merged
merged 3 commits into from
Dec 2, 2023
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
2 changes: 1 addition & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there! 👋 I noticed the update to the "@langchain/core" dependency from "~0.0.5" to "~0.0.6" in the package.json. This change may impact peer/dev/hard dependencies, so I'm flagging it for the maintainers to review. Great work on the PR! 🚀

"dependencies": {
"@anthropic-ai/sdk": "^0.9.1",
"@langchain/core": "~0.0.5",
"@langchain/core": "~0.0.6",
"binary-extensions": "^2.2.0",
"expr-eval": "^2.0.2",
"flat": "^5.0.2",
Expand Down
6 changes: 3 additions & 3 deletions langchain/src/callbacks/tests/langchain_tracer.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ test("Test traced chain with tags", async () => {

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey team, just a heads up that I've flagged the change in the test file for the LANGCHAIN_TRACING_V2 environment variable. It looks like the variable is being explicitly set in the test, so it might need a review. Let me know if you need any further assistance with this.

test("Test Traced Agent with concurrency", async () => {
process.env.LANGCHAIN_TRACING_V2 = "true";
const model = new OpenAI({ temperature: 0 });
const model = new ChatOpenAI({ temperature: 0 });
const tools = [
new SerpAPI(process.env.SERPAPI_API_KEY, {
location: "Austin,Texas,United States",
Expand All @@ -98,7 +98,7 @@ test("Test Traced Agent with concurrency", async () => {
];

const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "zero-shot-react-description",
agentType: "openai-functions",
verbose: true,
});

Expand Down Expand Up @@ -130,7 +130,7 @@ test("Test Traced Agent with chat model", async () => {
];

const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "chat-zero-shot-react-description",
agentType: "openai-functions",
verbose: true,
metadata: { c: "d" },
});
Expand Down
45 changes: 1 addition & 44 deletions langchain/src/util/tiktoken.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1 @@
import {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey team, just a heads up that this PR introduces a new fetch request for an external HTTP resource. This comment is to flag the change for maintainers to review the addition of this new request.

Tiktoken,
TiktokenBPE,
TiktokenEncoding,
TiktokenModel,
getEncodingNameForModel,
} from "js-tiktoken/lite";
import { AsyncCaller } from "./async_caller.js";

const cache: Record<string, Promise<TiktokenBPE>> = {};

const caller = /* #__PURE__ */ new AsyncCaller({});

export async function getEncoding(
encoding: TiktokenEncoding,
options?: {
signal?: AbortSignal;
extendedSpecialTokens?: Record<string, number>;
}
) {
if (!(encoding in cache)) {
cache[encoding] = caller
.fetch(`https://tiktoken.pages.dev/js/${encoding}.json`, {
signal: options?.signal,
})
.then((res) => res.json())
.catch((e) => {
delete cache[encoding];
throw e;
});
}

return new Tiktoken(await cache[encoding], options?.extendedSpecialTokens);
}

export async function encodingForModel(
model: TiktokenModel,
options?: {
signal?: AbortSignal;
extendedSpecialTokens?: Record<string, number>;
}
) {
return getEncoding(getEncodingNameForModel(model), options);
}
export * from "@langchain/core/utils/tiktoken";
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7997,7 +7997,7 @@ __metadata:
languageName: unknown
linkType: soft

"@langchain/core@workspace:*, @langchain/core@workspace:langchain-core, @langchain/core@~0.0.5":
"@langchain/core@workspace:*, @langchain/core@workspace:langchain-core, @langchain/core@~0.0.6":
version: 0.0.0-use.local
resolution: "@langchain/core@workspace:langchain-core"
dependencies:
Expand Down Expand Up @@ -22607,7 +22607,7 @@ __metadata:
"@gradientai/nodejs-sdk": ^1.2.0
"@huggingface/inference": ^2.6.4
"@jest/globals": ^29.5.0
"@langchain/core": ~0.0.5
"@langchain/core": ~0.0.6
"@mozilla/readability": ^0.4.4
"@notionhq/client": ^2.2.10
"@opensearch-project/opensearch": ^2.2.0
Expand Down