Skip to content
Draft
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
19 changes: 0 additions & 19 deletions libs/providers/langchain-google-common/jest.config.cjs

This file was deleted.

12 changes: 0 additions & 12 deletions libs/providers/langchain-google-common/jest.env.cjs

This file was deleted.

15 changes: 8 additions & 7 deletions libs/providers/langchain-google-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
"lint": "pnpm lint:eslint && pnpm lint:dpdm",
"lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
"clean": "rm -rf .turbo dist/",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "NODE_OPTIONS=--experimental-vm-modules pnpm run jest --config jest.config.cjs --testTimeout 100000",
"test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
"test": "vitest run",
"test:watch": "vitest",
"test:int": "vitest run --mode int",
"test:standard:unit": "vitest run --mode standard-unit",
"test:standard:int": "vitest run --mode standard-int",
"test:standard": "pnpm test:standard:unit && pnpm test:standard:int",
"format": "prettier --config .prettierrc --write \"src\"",
"format:check": "prettier --config .prettierrc --check \"src\""
},
Expand All @@ -31,7 +33,7 @@
"uuid": "^10.0.0"
},
"peerDependencies": {
"@langchain/core": ">=0.3.58 <0.4.0"
"@langchain/core": "^1.0.0-alpha.6"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
Expand All @@ -44,14 +46,13 @@
"dotenv": "^16.3.1",
"dpdm": "^3.14.0",
"eslint": "^9.34.0",
"jest": "^29.5.0",
"jest-environment-node": "^29.6.4",
"prettier": "^2.8.3",
"release-it": "^19.0.4",
"release-it-pnpm": "^4.6.6",
"rollup": "^4.5.2",
"ts-jest": "^29.1.0",
"typescript": "~5.8.3",
"vitest": "^3.2.4",
"zod": "^3.25.76"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { expect, test, jest } from "@jest/globals";
// import { expect, test, jest } from "@jest/globals";
import { describe, test, expect, vi } from "vitest";
import {
AIMessage,
BaseMessage,
Expand Down Expand Up @@ -61,7 +62,7 @@ describe("Mock ChatGoogle - Gemini", () => {
test("Setting invalid model parameters", async () => {
expect(() => {
const model = new ChatGoogle({
temperature: 1.2,
temperature: 2.2,
});
expect(model).toBeNull(); // For linting. Should never reach.
}).toThrowError(/temperature/);
Expand Down Expand Up @@ -536,7 +537,7 @@ describe("Mock ChatGoogle - Gemini", () => {
];

const retryableError = new MockClientError(429);
const requestSpy = jest
const requestSpy = vi
.spyOn(MockClient.prototype, "request")
.mockRejectedValueOnce(retryableError);

Expand Down
6 changes: 3 additions & 3 deletions libs/providers/langchain-google-common/src/tests/llms.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, jest } from "@jest/globals";
import { describe, expect, test, vi } from "vitest";
import {
BaseMessage,
HumanMessageChunk,
Expand Down Expand Up @@ -34,7 +34,7 @@ describe("Mock Google LLM", () => {
test("Setting invalid model parameters", async () => {
expect(() => {
const model = new GoogleLLM({
temperature: 1.2,
temperature: 2.2,
});
expect(model).toBeNull(); // For linting. Should never reach.
}).toThrowError(/temperature/);
Expand Down Expand Up @@ -206,7 +206,7 @@ describe("Mock Google LLM", () => {
});

const retryableError = new MockClientError(429);
const requestSpy = jest
const requestSpy = vi
.spyOn(MockClient.prototype, "request")
.mockRejectedValueOnce(retryableError);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { test } from "@jest/globals";
import { describe, expect, test } from "vitest";
import { MockClientAuthInfo, mockId } from "./mock.js";
import { ChatGoogle } from "./chat_models.test.js";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { beforeEach, expect, test } from "@jest/globals";
import { beforeEach, describe, expect, test } from "vitest";
import { InMemoryStore } from "@langchain/core/stores";
import { SerializedConstructor } from "@langchain/core/load/serializable";
import { load } from "@langchain/core/load";
Expand Down
67 changes: 67 additions & 0 deletions libs/providers/langchain-google-common/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {
configDefaults,
defineConfig,
type UserConfigExport,
} from "vitest/config";

export default defineConfig((env) => {
const common: UserConfigExport = {
test: {
environment: "node",
hideSkippedTests: true,
testTimeout: 30_000,
maxWorkers: 0.5,
exclude: ["**/*.int.test.ts", ...configDefaults.exclude],
setupFiles: ["dotenv/config"],
},
};

if (env.mode === "standard-unit") {
return {
test: {
...common.test,
testTimeout: 100_000,
exclude: configDefaults.exclude,
include: ["**/*.standard.test.ts"],
name: "standard-unit",
environment: "node",
},
};
}

if (env.mode === "standard-int") {
return {
test: {
...common.test,
testTimeout: 100_000,
exclude: configDefaults.exclude,
include: ["**/*.standard.int.test.ts"],
name: "standard-int",
environment: "node",
},
};
}

if (env.mode === "int") {
return {
test: {
...common.test,
globals: false,
testTimeout: 100_000,
exclude: configDefaults.exclude,
include: ["**/*.int.test.ts"],
name: "int",
environment: "node",
},
};
}

return {
test: {
...common.test,
environment: "node",
include: configDefaults.include,
typecheck: { enabled: true },
},
};
});
20 changes: 0 additions & 20 deletions libs/providers/langchain-google-gauth/jest.config.cjs

This file was deleted.

12 changes: 0 additions & 12 deletions libs/providers/langchain-google-gauth/jest.env.cjs

This file was deleted.

16 changes: 7 additions & 9 deletions libs/providers/langchain-google-gauth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
"lint": "pnpm lint:eslint && pnpm lint:dpdm",
"lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
"clean": "rm -rf .turbo dist/",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:single": "NODE_OPTIONS=--experimental-vm-modules pnpm run jest --config jest.config.cjs --testTimeout 100000",
"test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
"test:standard:unit": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.standard\\.test.ts --testTimeout 100000 --maxWorkers=50%",
"test:standard:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.standard\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
"test": "vitest run",
"test:watch": "vitest",
"test:int": "vitest run --mode int",
"test:standard:unit": "vitest run --mode standard-unit",
"test:standard:int": "vitest run --mode standard-int",
"test:standard": "pnpm test:standard:unit && pnpm test:standard:int",
"format": "prettier --config .prettierrc --write \"src\"",
"format:check": "prettier --config .prettierrc --check \"src\""
Expand All @@ -35,22 +34,21 @@
"google-auth-library": "^10.1.0"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
"@langchain/eslint": "workspace:*",
"@langchain/core": "workspace:*",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tsconfig/recommended": "^1.0.3",
"dotenv": "^16.3.1",
"dpdm": "^3.14.0",
"eslint": "^9.34.0",
"jest": "^29.5.0",
"jest-environment-node": "^29.6.4",
"prettier": "^2.8.3",
"release-it": "^19.0.4",
"release-it-pnpm": "^4.6.6",
"rollup": "^4.5.2",
"ts-jest": "^29.1.0",
"typescript": "~5.8.3",
"vitest": "^3.2.4",
"zod": "^3.25.76"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, describe } from "@jest/globals";
import { expect, test, describe } from "vitest";
import { Readable } from "stream";
import { NodeJsonStream } from "../auth.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from "@jest/globals";
import { describe, expect, test } from "vitest";
import { BaseLanguageModelInput } from "@langchain/core/language_models/base";
import { ChatPromptValue } from "@langchain/core/prompt_values";
import {
Expand Down Expand Up @@ -28,7 +28,9 @@ import { BlobStoreGoogleCloudStorage } from "../media.js";

describe("GAuth Chat", () => {
test("invoke", async () => {
const model = new ChatGoogle();
const model = new ChatGoogle({
modelName: "gemini-2.0-flash",
Copy link
Member

Choose a reason for hiding this comment

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

not blocking, but we're preferring model for this field name

});
const res = await model.invoke("What is 1 + 1?");
expect(res).toBeDefined();
expect(res._getType()).toEqual("ai");
Expand All @@ -54,7 +56,9 @@ describe("GAuth Chat", () => {
});

test("generate", async () => {
const model = new ChatGoogle();
const model = new ChatGoogle({
modelName: "gemini-2.0-flash",
});
const messages: BaseMessage[] = [
new SystemMessage(
"You will reply to all requests to flip a coin with either H, indicating heads, or T, indicating tails."
Expand All @@ -72,7 +76,7 @@ describe("GAuth Chat", () => {

expect(typeof aiMessage.content).toBe("string");
const text = aiMessage.content as string;
expect(["H", "T"]).toContainEqual(text);
expect(["H", "T"]).toContainEqual(text.trim());

/*
expect(aiMessage.content.length).toBeGreaterThan(0);
Expand All @@ -89,7 +93,9 @@ describe("GAuth Chat", () => {
});

test("stream", async () => {
const model = new ChatGoogle();
const model = new ChatGoogle({
modelName: "gemini-2.0-flash",
});
const input: BaseLanguageModelInput = new ChatPromptValue([
new SystemMessage(
"You will reply to all requests to flip a coin with either H, indicating heads, or T, indicating tails."
Expand Down Expand Up @@ -135,7 +141,9 @@ describe("GAuth Chat", () => {
],
},
];
const model = new ChatGoogle().bindTools(tools);
const model = new ChatGoogle({
modelName: "gemini-2.0-flash",
}).bindTools(tools);
const result = await model.invoke("Run a test on the cobalt project");
expect(result).toHaveProperty("content");
expect(result.content).toBe("");
Expand Down Expand Up @@ -179,7 +187,9 @@ describe("GAuth Chat", () => {
],
},
];
const model = new ChatGoogle().bindTools(tools);
const model = new ChatGoogle({
modelName: "gemini-2.0-flash",
}).bindTools(tools);
const toolResult = {
testPassed: true,
};
Expand Down Expand Up @@ -222,7 +232,9 @@ describe("GAuth Chat", () => {
required: ["location"],
},
};
const model = new ChatGoogle().withStructuredOutput(tool);
const model = new ChatGoogle({
modelName: "gemini-2.0-flash",
}).withStructuredOutput(tool);
const result = await model.invoke("What is the weather in Paris?");
expect(result).toHaveProperty("location");
});
Expand Down Expand Up @@ -256,7 +268,7 @@ describe("GAuth Chat", () => {
resolvers: [resolver],
});
const model = new ChatGoogle({
modelName: "gemini-1.5-flash",
modelName: "gemini-2.0-flash",
apiConfig: {
mediaManager,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from "fs/promises";
import { test } from "@jest/globals";
import { describe, expect, test } from "vitest";
import { GoogleCloudStorageUri } from "@langchain/google-common/experimental/media";
import { MediaBlob } from "@langchain/google-common/experimental/utils/media_core";
import {
Expand Down
Loading