Skip to content

Commit

Permalink
langchain[patch]: Miscellaneous test fixes (#3497)
Browse files Browse the repository at this point in the history
* Fix bug

* Small fixes
  • Loading branch information
jacoblee93 authored Dec 2, 2023
1 parent cd7e640 commit 791e314
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 50 deletions.
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 @@
},
"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 () => {

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 {
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

2 comments on commit 791e314

@vercel
Copy link

@vercel vercel bot commented on 791e314 Dec 2, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 791e314 Dec 2, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

langchainjs-docs – ./docs/core_docs/

langchainjs-docs-langchain.vercel.app
langchainjs-docs-ruddy.vercel.app
langchainjs-docs-git-main-langchain.vercel.app
js.langchain.com

Please sign in to comment.