From 030607b9016a9eec8dabfc89b0d6b88001cedcc9 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Tue, 11 Jun 2024 11:16:52 -0700 Subject: [PATCH 1/2] Unstructured in memory loader (#5726) * feat: add in-memory option * feat: add in memory community * fix: object destructure fix * Fix lint * Rename args and add to docstring * Export types --------- Co-authored-by: andrewdoro --- .../src/document_loaders/fs/unstructured.ts | 46 ++++++++++---- .../tests/unstructured.int.test.ts | 29 +++++++++ libs/langchain-community/.eslintrc.cjs | 1 + .../src/document_loaders/fs/unstructured.ts | 60 +++++++++++++------ .../tests/unstructured.int.test.ts | 29 +++++++++ 5 files changed, 138 insertions(+), 27 deletions(-) diff --git a/langchain/src/document_loaders/fs/unstructured.ts b/langchain/src/document_loaders/fs/unstructured.ts index edb60008aca1..e3b62a9cfbc3 100644 --- a/langchain/src/document_loaders/fs/unstructured.ts +++ b/langchain/src/document_loaders/fs/unstructured.ts @@ -126,6 +126,11 @@ type UnstructuredDirectoryLoaderOptions = UnstructuredLoaderOptions & { unknown?: UnknownHandling; }; +type UnstructuredMemoryLoaderOptions = { + buffer: Buffer; + fileName: string; +}; + /** * @deprecated - Import from "@langchain/community/document_loaders/fs/unstructured" instead. This entrypoint will be removed in 0.3.0. * @@ -139,6 +144,10 @@ type UnstructuredDirectoryLoaderOptions = UnstructuredLoaderOptions & { export class UnstructuredLoader extends BaseDocumentLoader { public filePath: string; + private buffer?: Buffer; + + private fileName?: string; + private apiUrl = "https://api.unstructured.io/general/v0/general"; private apiKey?: string; @@ -175,7 +184,9 @@ export class UnstructuredLoader extends BaseDocumentLoader { private maxCharacters?: number; constructor( - filePathOrLegacyApiUrl: string, + filePathOrLegacyApiUrlOrMemoryBuffer: + | string + | UnstructuredMemoryLoaderOptions, optionsOrLegacyFilePath: UnstructuredLoaderOptions | string = {} ) { super(); @@ -183,11 +194,20 @@ export class UnstructuredLoader extends BaseDocumentLoader { // Temporary shim to avoid breaking existing users // Remove when API keys are enforced by Unstructured and existing code will break anyway const isLegacySyntax = typeof optionsOrLegacyFilePath === "string"; - if (isLegacySyntax) { + const isMemorySyntax = + typeof filePathOrLegacyApiUrlOrMemoryBuffer === "object"; + + if (isMemorySyntax) { + this.buffer = filePathOrLegacyApiUrlOrMemoryBuffer.buffer; + this.fileName = filePathOrLegacyApiUrlOrMemoryBuffer.fileName; + } else if (isLegacySyntax) { this.filePath = optionsOrLegacyFilePath; - this.apiUrl = filePathOrLegacyApiUrl; + this.apiUrl = filePathOrLegacyApiUrlOrMemoryBuffer; } else { - this.filePath = filePathOrLegacyApiUrl; + this.filePath = filePathOrLegacyApiUrlOrMemoryBuffer; + } + + if (!isLegacySyntax) { const options = optionsOrLegacyFilePath; this.apiKey = options.apiKey; this.apiUrl = options.apiUrl ?? this.apiUrl; @@ -209,14 +229,20 @@ export class UnstructuredLoader extends BaseDocumentLoader { } async _partition() { - const { readFile, basename } = await this.imports(); + let { buffer } = this; + let { fileName } = this; + + if (!buffer) { + const { readFile, basename } = await this.imports(); - const buffer = await readFile(this.filePath); - const fileName = basename(this.filePath); + buffer = await readFile(this.filePath); + fileName = basename(this.filePath); + + // I'm aware this reads the file into memory first, but we have lots of work + // to do on then consuming Documents in a streaming fashion anyway, so not + // worried about this for now. + } - // I'm aware this reads the file into memory first, but we have lots of work - // to do on then consuming Documents in a streaming fashion anyway, so not - // worried about this for now. const formData = new FormData(); formData.append("files", new Blob([buffer]), fileName); formData.append("strategy", this.strategy); diff --git a/langchain/src/document_loaders/tests/unstructured.int.test.ts b/langchain/src/document_loaders/tests/unstructured.int.test.ts index e30913e10a2d..b0b0712118a6 100644 --- a/langchain/src/document_loaders/tests/unstructured.int.test.ts +++ b/langchain/src/document_loaders/tests/unstructured.int.test.ts @@ -3,6 +3,7 @@ import * as url from "node:url"; import * as path from "node:path"; +import { readFile } from "node:fs/promises"; import { test, expect } from "@jest/globals"; import { UnstructuredDirectoryLoader, @@ -29,6 +30,34 @@ test.skip("Test Unstructured base loader", async () => { } }); +test.skip("Test Unstructured base loader with buffer", async () => { + const filePath = path.resolve( + path.dirname(url.fileURLToPath(import.meta.url)), + "./example_data/example.txt" + ); + + const options = { + apiKey: process.env.UNSTRUCTURED_API_KEY!, + }; + + const buffer = await readFile(filePath); + const fileName = "example.txt"; + + const loader = new UnstructuredLoader( + { + buffer, + fileName, + }, + options + ); + const docs = await loader.load(); + + expect(docs.length).toBe(3); + for (const doc of docs) { + expect(typeof doc.pageContent).toBe("string"); + } +}); + test.skip("Test Unstructured base loader with fast strategy", async () => { const filePath = path.resolve( path.dirname(url.fileURLToPath(import.meta.url)), diff --git a/libs/langchain-community/.eslintrc.cjs b/libs/langchain-community/.eslintrc.cjs index 459826a03a17..fea6aa3b0a6c 100644 --- a/libs/langchain-community/.eslintrc.cjs +++ b/libs/langchain-community/.eslintrc.cjs @@ -64,6 +64,7 @@ module.exports = { "prefer-rest-params": 0, "new-cap": ["error", { properties: false, capIsNew: false }], "arrow-body-style": 0, + "prefer-destructuring": 0 }, overrides: [ { diff --git a/libs/langchain-community/src/document_loaders/fs/unstructured.ts b/libs/langchain-community/src/document_loaders/fs/unstructured.ts index f9040b11110a..62e7053f42b2 100644 --- a/libs/langchain-community/src/document_loaders/fs/unstructured.ts +++ b/libs/langchain-community/src/document_loaders/fs/unstructured.ts @@ -10,7 +10,7 @@ import { } from "langchain/document_loaders/fs/directory"; import { BaseDocumentLoader } from "@langchain/core/document_loaders/base"; -const UNSTRUCTURED_API_FILETYPES = [ +export const UNSTRUCTURED_API_FILETYPES = [ ".txt", ".text", ".pdf", @@ -94,7 +94,7 @@ export type SkipInferTableTypes = /** * Set the chunking_strategy to chunk text into larger or smaller elements. Defaults to None with optional arg of by_title */ -type ChunkingStrategy = "None" | "by_title"; +export type ChunkingStrategy = "None" | "by_title"; export type UnstructuredLoaderOptions = { apiKey?: string; @@ -115,11 +115,16 @@ export type UnstructuredLoaderOptions = { maxCharacters?: number; }; -type UnstructuredDirectoryLoaderOptions = UnstructuredLoaderOptions & { +export type UnstructuredDirectoryLoaderOptions = UnstructuredLoaderOptions & { recursive?: boolean; unknown?: UnknownHandling; }; +export type UnstructuredMemoryLoaderOptions = { + buffer: Buffer; + fileName: string; +}; + /** * A document loader that uses the Unstructured API to load unstructured * documents. It supports both the new syntax with options object and the @@ -127,10 +132,17 @@ type UnstructuredDirectoryLoaderOptions = UnstructuredLoaderOptions & { * partitioning request to the Unstructured API and retrieves the * partitioned elements. It creates a Document instance for each element * and returns an array of Document instances. + * + * It accepts either a filepath or an object containing a buffer and a filename + * as input. */ export class UnstructuredLoader extends BaseDocumentLoader { public filePath: string; + private buffer?: Buffer; + + private fileName?: string; + private apiUrl = "https://api.unstructured.io/general/v0/general"; private apiKey?: string; @@ -167,20 +179,28 @@ export class UnstructuredLoader extends BaseDocumentLoader { private maxCharacters?: number; constructor( - filePathOrLegacyApiUrl: string, - optionsOrLegacyFilePath: UnstructuredLoaderOptions | string = {} + filepathOrBufferOptions: string | UnstructuredMemoryLoaderOptions, + unstructuredOptions: UnstructuredLoaderOptions | string = {} ) { super(); // Temporary shim to avoid breaking existing users // Remove when API keys are enforced by Unstructured and existing code will break anyway - const isLegacySyntax = typeof optionsOrLegacyFilePath === "string"; - if (isLegacySyntax) { - this.filePath = optionsOrLegacyFilePath; - this.apiUrl = filePathOrLegacyApiUrl; + const isLegacySyntax = typeof unstructuredOptions === "string"; + const isMemorySyntax = typeof filepathOrBufferOptions === "object"; + + if (isMemorySyntax) { + this.buffer = filepathOrBufferOptions.buffer; + this.fileName = filepathOrBufferOptions.fileName; + } else if (isLegacySyntax) { + this.filePath = unstructuredOptions; + this.apiUrl = filepathOrBufferOptions; } else { - this.filePath = filePathOrLegacyApiUrl; - const options = optionsOrLegacyFilePath; + this.filePath = filepathOrBufferOptions; + } + + if (!isLegacySyntax) { + const options = unstructuredOptions; this.apiKey = options.apiKey ?? getEnvironmentVariable("UNSTRUCTURED_API_KEY"); this.apiUrl = @@ -205,14 +225,20 @@ export class UnstructuredLoader extends BaseDocumentLoader { } async _partition() { - const { readFile, basename } = await this.imports(); + let buffer = this.buffer; + let fileName = this.fileName; + + if (!buffer) { + const { readFile, basename } = await this.imports(); - const buffer = await readFile(this.filePath); - const fileName = basename(this.filePath); + buffer = await readFile(this.filePath); + fileName = basename(this.filePath); + + // I'm aware this reads the file into memory first, but we have lots of work + // to do on then consuming Documents in a streaming fashion anyway, so not + // worried about this for now. + } - // I'm aware this reads the file into memory first, but we have lots of work - // to do on then consuming Documents in a streaming fashion anyway, so not - // worried about this for now. const formData = new FormData(); formData.append("files", new Blob([buffer]), fileName); formData.append("strategy", this.strategy); diff --git a/libs/langchain-community/src/document_loaders/tests/unstructured.int.test.ts b/libs/langchain-community/src/document_loaders/tests/unstructured.int.test.ts index e30913e10a2d..b0b0712118a6 100644 --- a/libs/langchain-community/src/document_loaders/tests/unstructured.int.test.ts +++ b/libs/langchain-community/src/document_loaders/tests/unstructured.int.test.ts @@ -3,6 +3,7 @@ import * as url from "node:url"; import * as path from "node:path"; +import { readFile } from "node:fs/promises"; import { test, expect } from "@jest/globals"; import { UnstructuredDirectoryLoader, @@ -29,6 +30,34 @@ test.skip("Test Unstructured base loader", async () => { } }); +test.skip("Test Unstructured base loader with buffer", async () => { + const filePath = path.resolve( + path.dirname(url.fileURLToPath(import.meta.url)), + "./example_data/example.txt" + ); + + const options = { + apiKey: process.env.UNSTRUCTURED_API_KEY!, + }; + + const buffer = await readFile(filePath); + const fileName = "example.txt"; + + const loader = new UnstructuredLoader( + { + buffer, + fileName, + }, + options + ); + const docs = await loader.load(); + + expect(docs.length).toBe(3); + for (const doc of docs) { + expect(typeof doc.pageContent).toBe("string"); + } +}); + test.skip("Test Unstructured base loader with fast strategy", async () => { const filePath = path.resolve( path.dirname(url.fileURLToPath(import.meta.url)), From 99608992d7660e9b59c0ba615e539dff56421906 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Tue, 11 Jun 2024 11:28:17 -0700 Subject: [PATCH 2/2] infra[minor]: Add vertexai to latest/lowest ci (#5727) --- .github/workflows/compatibility.yml | 65 ++++++++++++------- dependency_range_tests/docker-compose.yml | 42 ++++++++---- .../scripts/vertexai/node/package.json | 9 +++ .../node/update_resolutions_lowest.js | 36 ++++++++++ .../scripts/vertexai/node/yarn.lock | 22 +++++++ .../scripts/vertexai/test-with-latest-deps.sh | 16 +++++ .../scripts/vertexai/test-with-lowest-deps.sh | 27 ++++++++ 7 files changed, 182 insertions(+), 35 deletions(-) create mode 100644 dependency_range_tests/scripts/vertexai/node/package.json create mode 100644 dependency_range_tests/scripts/vertexai/node/update_resolutions_lowest.js create mode 100644 dependency_range_tests/scripts/vertexai/node/yarn.lock create mode 100644 dependency_range_tests/scripts/vertexai/test-with-latest-deps.sh create mode 100644 dependency_range_tests/scripts/vertexai/test-with-lowest-deps.sh diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 6aacdab1f1b0..d8ab26254f31 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -29,7 +29,7 @@ env: # so that they run in parallel instead of overwhelming the default 2 CPU runner. jobs: # LangChain - test-langchain-with-latest-deps: + langchain-latest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -38,14 +38,10 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} cache: "yarn" - - name: Install dependencies - run: yarn install --immutable - - name: Build `@langchain/standard-tests` - run: yarn build --filter=@langchain/standard-tests - name: Test LangChain with latest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-langchain-with-latest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run langchain-latest-deps - test-langchain-with-lowest-deps: + langchain-lowest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -54,15 +50,11 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} cache: "yarn" - - name: Install dependencies - run: yarn install --immutable - - name: Build `@langchain/standard-tests` - run: yarn build --filter=@langchain/standard-tests - name: Test LangChain with lowest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-langchain-with-lowest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run langchain-lowest-deps # Community - test-community-with-latest-deps: + community-latest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -76,9 +68,9 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/community` with latest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-community-with-latest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run community-latest-deps - test-community-with-lowest-deps: + community-lowest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -92,10 +84,10 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/community` with lowest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-community-with-lowest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run community-lowest-deps # OpenAI - test-openai-with-latest-deps: + openai-latest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -109,9 +101,9 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/openai` with latest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-openai-with-latest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run openai-latest-deps - test-openai-with-lowest-deps: + openai-lowest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -125,10 +117,10 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/openai` with lowest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-openai-with-lowest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run openai-lowest-deps # Anthropic - test-anthropic-with-latest-deps: + anthropic-latest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -142,9 +134,9 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/anthropic` with latest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-anthropic-with-latest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run anthropic-latest-deps - test-anthropic-with-lowest-deps: + anthropic-lowest-deps: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -158,4 +150,29 @@ jobs: - name: Build `@langchain/standard-tests` run: yarn build --filter=@langchain/standard-tests - name: Test `@langchain/anthropic` with lowest deps - run: docker compose -f dependency_range_tests/docker-compose.yml run test-anthropic-with-lowest-deps + run: docker compose -f dependency_range_tests/docker-compose.yml run anthropic-lowest-deps + + # VertexAI + vertexai-latest-deps: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "yarn" + - name: Test `@langchain/google-vertexai` with latest deps + run: docker compose -f dependency_range_tests/docker-compose.yml run vertexai-latest-deps + + vertexai-lowest-deps: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "yarn" + - name: Test `@langchain/google-vertexai` with lowest deps + run: docker compose -f dependency_range_tests/docker-compose.yml run vertexai-lowest-deps diff --git a/dependency_range_tests/docker-compose.yml b/dependency_range_tests/docker-compose.yml index b5729ae14e74..9c2f4ebdbc28 100644 --- a/dependency_range_tests/docker-compose.yml +++ b/dependency_range_tests/docker-compose.yml @@ -1,7 +1,7 @@ version: "3" services: # LangChain - test-langchain-with-latest-deps: + langchain-latest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -12,7 +12,7 @@ services: - ../langchain:/langchain - ./scripts:/scripts command: bash /scripts/langchain/test-with-latest-deps.sh - test-langchain-with-lowest-deps: + langchain-lowest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -20,15 +20,12 @@ services: COHERE_API_KEY: ${COHERE_API_KEY} working_dir: /app volumes: - - ../turbo.json:/turbo.json - - ../package.json:/package.json - - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../langchain:/langchain - ./scripts:/scripts command: bash /scripts/langchain/test-with-lowest-deps.sh # Community - test-community-with-latest-deps: + community-latest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -42,7 +39,7 @@ services: - ../libs/langchain-community:/libs/langchain-community - ./scripts:/scripts command: bash /scripts/with_standard_tests/community/test-with-latest-deps.sh - test-community-with-lowest-deps: + community-lowest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -58,7 +55,7 @@ services: command: bash /scripts/with_standard_tests/community/test-with-lowest-deps.sh # OpenAI - test-openai-with-latest-deps: + openai-latest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -72,7 +69,7 @@ services: - ../libs/langchain-openai:/libs/langchain-openai - ./scripts:/scripts command: bash /scripts/with_standard_tests/openai/test-with-latest-deps.sh - test-openai-with-lowest-deps: + openai-lowest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -88,7 +85,7 @@ services: command: bash /scripts/with_standard_tests/openai/test-with-lowest-deps.sh # Anthropic - test-anthropic-with-latest-deps: + anthropic-latest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -102,7 +99,7 @@ services: - ../libs/langchain-anthropic:/libs/langchain-anthropic - ./scripts:/scripts command: bash /scripts/with_standard_tests/anthropic/test-with-latest-deps.sh - test-anthropic-with-lowest-deps: + anthropic-lowest-deps: image: node:18 environment: PUPPETEER_SKIP_DOWNLOAD: "true" @@ -116,3 +113,26 @@ services: - ../libs/langchain-anthropic:/libs/langchain-anthropic - ./scripts:/scripts command: bash /scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh + + # VertexAI + vertexai-latest-deps: + image: node:18 + environment: + PUPPETEER_SKIP_DOWNLOAD: "true" + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" + working_dir: /app + volumes: + - ../libs/langchain-google-vertexai:/libs/langchain-google-vertexai + - ./scripts:/scripts + command: bash /scripts/vertexai/test-with-latest-deps.sh + vertexai-lowest-deps: + image: node:18 + environment: + PUPPETEER_SKIP_DOWNLOAD: "true" + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" + working_dir: /app + volumes: + - ../libs/langchain-google-vertexai:/libs/langchain-google-vertexai + - ./scripts:/scripts + command: bash /scripts/vertexai/test-with-lowest-deps.sh + \ No newline at end of file diff --git a/dependency_range_tests/scripts/vertexai/node/package.json b/dependency_range_tests/scripts/vertexai/node/package.json new file mode 100644 index 000000000000..a4622fc74597 --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/node/package.json @@ -0,0 +1,9 @@ +{ + "name": "dependency-range-tests", + "version": "0.0.0", + "private": true, + "description": "Tests dependency ranges for LangChain.", + "dependencies": { + "semver": "^7.5.4" + } +} \ No newline at end of file diff --git a/dependency_range_tests/scripts/vertexai/node/update_resolutions_lowest.js b/dependency_range_tests/scripts/vertexai/node/update_resolutions_lowest.js new file mode 100644 index 000000000000..b8768d8a7156 --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/node/update_resolutions_lowest.js @@ -0,0 +1,36 @@ +const fs = require("fs"); +const semver = require("semver"); + +const communityPackageJsonPath = "package.json"; + +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { + const minVersion = semver.minVersion( + currentPackageJson.dependencies["@langchain/core"] + ).version; + currentPackageJson.overrides = { + ...currentPackageJson.overrides, + "@langchain/core": minVersion, + }; + currentPackageJson.dependencies = { + ...currentPackageJson.dependencies, + "@langchain/core": minVersion, + }; +} + +if (currentPackageJson.dependencies["@langchain/google-gauth"] && !currentPackageJson.dependencies["@langchain/google-gauth"].includes("rc")) { + const minVersion = semver.minVersion( + currentPackageJson.dependencies["@langchain/google-gauth"] + ).version; + currentPackageJson.overrides = { + ...currentPackageJson.overrides, + "@langchain/google-gauth": minVersion, + }; + currentPackageJson.dependencies = { + ...currentPackageJson.dependencies, + "@langchain/google-gauth": minVersion, + }; +} + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/vertexai/node/yarn.lock b/dependency_range_tests/scripts/vertexai/node/yarn.lock new file mode 100644 index 000000000000..50ac73caa812 --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/node/yarn.lock @@ -0,0 +1,22 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +semver@^7.5.4: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== diff --git a/dependency_range_tests/scripts/vertexai/test-with-latest-deps.sh b/dependency_range_tests/scripts/vertexai/test-with-latest-deps.sh new file mode 100644 index 000000000000..e5eb224b71e1 --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/test-with-latest-deps.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +export CI=true + +# enable extended globbing for omitting build artifacts +shopt -s extglob + +# avoid copying build artifacts from the host +cp -r ../libs/langchain-google-vertexai/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./ + +yarn + +# Check the test command completes successfully +NODE_OPTIONS=--experimental-vm-modules yarn run jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50% diff --git a/dependency_range_tests/scripts/vertexai/test-with-lowest-deps.sh b/dependency_range_tests/scripts/vertexai/test-with-lowest-deps.sh new file mode 100644 index 000000000000..9a95587c845c --- /dev/null +++ b/dependency_range_tests/scripts/vertexai/test-with-lowest-deps.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +export CI=true + +# enable extended globbing for omitting build artifacts +shopt -s extglob + +# avoid copying build artifacts from the host +cp -r ../libs/langchain-google-vertexai/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./ + +mkdir -p /updater_script +cp -r /scripts/vertexai/node/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) /updater_script/ + +cd /updater_script + +yarn + +cd /app + +node /updater_script/update_resolutions_lowest.js + +yarn + +# Check the test command completes successfully +NODE_OPTIONS=--experimental-vm-modules yarn run jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%