diff --git a/langchain/src/load/tests/__snapshots__/load.test.ts.snap b/langchain/src/load/tests/__snapshots__/load.test.ts.snap index 9318852df261..b323f9fdad11 100644 --- a/langchain/src/load/tests/__snapshots__/load.test.ts.snap +++ b/langchain/src/load/tests/__snapshots__/load.test.ts.snap @@ -279,19 +279,6 @@ kwargs: " `; -exports[`serialize + deserialize llm with optional deps 1`] = ` -"lc: 1 -type: constructor -id: - - langchain - - llms - - cohere - - Cohere -kwargs: - temperature: 0.5 -" -`; - exports[`serialize + deserialize llmchain with list output parser 1`] = ` "lc: 1 type: constructor diff --git a/langchain/src/load/tests/load.test.ts b/langchain/src/load/tests/load.test.ts index b498857fa622..54ac32d657f2 100644 --- a/langchain/src/load/tests/load.test.ts +++ b/langchain/src/load/tests/load.test.ts @@ -2,7 +2,6 @@ import { test, expect } from "@jest/globals"; import { stringify } from "yaml"; import { z } from "zod"; import { RunnableSequence } from "@langchain/core/runnables"; -import { Cohere } from "@langchain/cohere"; import { OpenAI, ChatOpenAI } from "@langchain/openai"; import { @@ -161,26 +160,6 @@ test("serialize + deserialize llm", async () => { expect(JSON.stringify(llm3, null, 2)).toBe(str); }); -test("serialize + deserialize llm with optional deps", async () => { - const llm = new Cohere({ temperature: 0.5, apiKey: "cohere-key" }); - const str = JSON.stringify(llm, null, 2); - expect(stringify(JSON.parse(str))).toMatchSnapshot(); - const llm2 = await load( - str, - { COHERE_API_KEY: "cohere-key" }, - { "langchain/llms/cohere": { Cohere } } - ); - expect(llm2).toBeInstanceOf(Cohere); - expect(JSON.stringify(llm2, null, 2)).toBe(str); - const llm3 = await load( - str, - { COHERE_API_KEY: "cohere-key" }, - { "langchain/llms/cohere": import("@langchain/cohere") } - ); - expect(llm3).toBeInstanceOf(Cohere); - expect(JSON.stringify(llm3, null, 2)).toBe(str); -}); - test("serialize + deserialize llm chain string prompt", async () => { const llm = new OpenAI({ temperature: 0.5, @@ -455,30 +434,30 @@ test.skip("serialize + deserialize agent", async () => { }); test("override name of objects when serialising", async () => { - const llm = new Cohere({ temperature: 0.5, apiKey: "cohere-key" }); + const llm = new OpenAI({ temperature: 0.5, apiKey: "openai-key" }); const str = JSON.stringify(llm, null, 2); - class MangledName extends Cohere {} - const llm2 = await load( + class MangledName extends OpenAI {} + const llm2 = await load( str, - { COHERE_API_KEY: "cohere-key" }, - { "langchain/llms/cohere": { Cohere: MangledName } } + { OPENAI_API_KEY: "openai-key" }, + { "langchain/llms/openai": { OpenAI: MangledName } } ); expect(JSON.stringify(llm2, null, 2)).toBe(str); }); test("Should load traces even if the constructor name changes (minified environments)", async () => { - const llm = new Cohere({ temperature: 0.5, apiKey: "cohere-key" }); + const llm = new OpenAI({ temperature: 0.5, apiKey: "openai-key" }); Object.defineProperty(llm.constructor, "name", { value: "x", }); const str = JSON.stringify(llm, null, 2); console.log(str); - const llm2 = await load( + const llm2 = await load( str, { COHERE_API_KEY: "cohere-key" }, - { "langchain/llms/cohere": { Cohere } } + { "langchain/llms/openai": { OpenAI } } ); console.log(JSON.stringify(llm2, null, 2)); expect(JSON.stringify(llm2, null, 2)).toBe(str);