Skip to content

Commit

Permalink
langchain lowest and latest working
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 10, 2024
1 parent 56663e9 commit 3881093
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 80 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
- 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

Expand All @@ -61,6 +63,8 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
- 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

Expand Down
9 changes: 6 additions & 3 deletions dependency_range_tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ 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
Expand All @@ -31,9 +34,6 @@ 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
- ../libs/langchain-community:/libs/langchain-community
- ./scripts:/scripts
command: bash /scripts/community/test-with-latest-deps.sh
Expand All @@ -45,6 +45,9 @@ 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
- ../libs/langchain-community:/libs/langchain-community
- ./scripts:/scripts
command: bash /scripts/community/test-with-lowest-deps.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const fs = require("fs");
const semver = require("semver");

const currentPackageJson = JSON.parse(fs.readFileSync("./package.json"));
const communityPackageJsonPath = "/app/monorepo/libs/langchain-community/package.json";

const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath));

if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) {
const minVersion = semver.minVersion(
Expand Down Expand Up @@ -31,4 +33,4 @@ if (currentPackageJson.dependencies["@langchain/openai"] && !currentPackageJson.
};
}

fs.writeFileSync("./package.json", JSON.stringify(currentPackageJson, null, 2));
fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2));
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");

const standardTestsPackageJsonPath = "./libs/langchain-standard-tests/package.json";
const standardTestsPackageJsonPath = "/app/monorepo/libs/langchain-standard-tests/package.json";

const currentPackageJson = JSON.parse(fs.readFileSync(standardTestsPackageJsonPath));

Expand Down
30 changes: 8 additions & 22 deletions dependency_range_tests/scripts/community/test-with-latest-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,20 @@ export CI=true
shopt -s extglob

# avoid copying build artifacts from the host
mkdir -p ./libs/langchain-community/ ./libs/langchain-standard-tests/
cp -r ../libs/langchain-community/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./libs/langchain-community/
cp -r ../libs/langchain-standard-tests ./libs/langchain-standard-tests/
cp ../turbo.json ./
cp ../package.json ./
cp -r ../libs/langchain-community/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./

ls ./libs
# ls ./libs/langchain-community
ls ./libs/langchain-standard-tests/langchain-standard-tests
mkdir -p /updater_script
cp -r /scripts/community/node/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) /updater_script/

# Copy all contents from ./libs/langchain-standard-tests/langchain-standard-tests to ./libs/langchain-standard-tests
cp -r ./libs/langchain-standard-tests/langchain-standard-tests/* ./libs/langchain-standard-tests/
cd /updater_script

# Delete the ./libs/langchain-standard-tests/langchain-standard-tests directory
rm -rf ./libs/langchain-standard-tests/langchain-standard-tests
yarn

ls ./libs/langchain-standard-tests
cd /app

# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p /updater_script
cp /scripts/community/node/update_workspace_dependencies.js /updater_script/
node /updater_script/update_workspace_dependencies.js
node /updater_script/update_resolutions_lowest.js

yarn

# Check the test command completes successfully
ls
ls ./libs
cd ./libs/langchain-community && yarn test
# yarn run jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%
NODE_OPTIONS=--experimental-vm-modules yarn run jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%
55 changes: 45 additions & 10 deletions dependency_range_tests/scripts/community/test-with-lowest-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,59 @@ set -euxo pipefail

export CI=true

# New monorepo directory paths
monorepo_dir="/app/monorepo"
monorepo_libs_dir="$monorepo_dir/libs"
monorepo_community_dir="$monorepo_libs_dir/langchain-community"
monorepo_standard_tests_dir="$monorepo_libs_dir/langchain-standard-tests"

# Updater script will not live inside the monorepo
updater_script_dir="/app/updater_script"

# Original directory paths
original_community_dir="/libs/langchain-community"
original_standard_tests_dir="/libs/langchain-standard-tests"
original_package_json_dir="/package.json"
original_turbo_json_dir="/turbo.json"
original_updater_script_dir="/scripts/community/node"

# enable extended globbing for omitting build artifacts
shopt -s extglob

# avoid copying build artifacts from the host
cp -r ../libs/langchain-community/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./
# Create the top level monorepo directory
mkdir -p "$monorepo_dir"

mkdir -p /updater_script
cp -r /scripts/community/node/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) /updater_script/
# Copy `@langchain/standard-tests` WITH build artifacts from the host.
# This is because we build @langchain/standard-tests before running this script.
mkdir -p "$monorepo_standard_tests_dir/"
cp -r "$original_standard_tests_dir"/* "$monorepo_standard_tests_dir/"

cd /updater_script
# Copy `@langchain/community` WITHOUT build artifacts from the host.
mkdir -p "$monorepo_community_dir/"
cp -r "$original_community_dir"/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) "$monorepo_community_dir/"

yarn
# Copy the turbo and package.json files for monorepo
cp "$original_turbo_json_dir" "$monorepo_dir/"
cp "$original_package_json_dir" "$monorepo_dir/"

cd /app
# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p "$updater_script_dir"
cp "$original_updater_script_dir"/* "$updater_script_dir/"

node /updater_script/update_resolutions_lowest.js
# Install deps (e.g semver) for the updater script
cd "$updater_script_dir"
yarn
# Run the updater scripts
node "update_workspace_dependencies.js"
node "update_resolutions_lowest.js"

# Navigate back to monorepo root and install dependencies
cd "$monorepo_dir"
yarn

# Check the test command completes successfully
NODE_OPTIONS=--experimental-vm-modules yarn run jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%
# Navigate into `@langchain/community` and run tests
# We need to run inside the community directory so turbo repo does
# not try to build the package/it's workspace dependencies.
cd "$monorepo_community_dir"
yarn test
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const fs = require("fs");
const semver = require("semver");

const currentPackageJson = JSON.parse(fs.readFileSync("./package.json"));
const communityPackageJsonPath = "/app/monorepo/langchain/package.json";

const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath));

if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) {
const minVersion = semver.minVersion(
Expand Down Expand Up @@ -45,4 +47,4 @@ if (currentPackageJson.dependencies["@langchain/textsplitters"] && !currentPacka
};
}

fs.writeFileSync("./package.json", JSON.stringify(currentPackageJson, null, 2));
fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fs = require("fs");

const standardTestsPackageJsonPath = "/app/monorepo/libs/langchain-standard-tests/package.json";

const currentPackageJson = JSON.parse(fs.readFileSync(standardTestsPackageJsonPath));

if (currentPackageJson.dependencies["@langchain/core"]) {
currentPackageJson.dependencies = {
...currentPackageJson.dependencies,
"@langchain/core": "latest",
};
}

if (currentPackageJson.devDependencies["@langchain/scripts"]) {
currentPackageJson.devDependencies = {
...currentPackageJson.devDependencies,
"@langchain/scripts": "latest",
};
}

fs.writeFileSync(standardTestsPackageJsonPath, JSON.stringify(currentPackageJson, null, 2));
55 changes: 45 additions & 10 deletions dependency_range_tests/scripts/langchain/test-with-lowest-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,59 @@ set -euxo pipefail

export CI=true

# New monorepo directory paths
monorepo_dir="/app/monorepo"
monorepo_libs_dir="$monorepo_dir/libs"
monorepo_langchain_dir="$monorepo_dir/langchain"
monorepo_standard_tests_dir="$monorepo_libs_dir/langchain-standard-tests"

# Updater script will not live inside the monorepo
updater_script_dir="/app/updater_script"

# Original directory paths
original_langchain_dir="/langchain"
original_standard_tests_dir="/libs/langchain-standard-tests"
original_package_json_dir="/package.json"
original_turbo_json_dir="/turbo.json"
original_updater_script_dir="/scripts/langchain/node"

# enable extended globbing for omitting build artifacts
shopt -s extglob

# avoid copying build artifacts from the host
cp -r ../langchain/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./
# Create the top level monorepo directory
mkdir -p "$monorepo_dir"

mkdir -p /updater_script
cp -r /scripts/langchain/node/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) /updater_script/
# Copy `@langchain/standard-tests` WITH build artifacts from the host.
# This is because we build @langchain/standard-tests before running this script.
mkdir -p "$monorepo_standard_tests_dir/"
cp -r "$original_standard_tests_dir"/* "$monorepo_standard_tests_dir/"

cd /updater_script
# Copy `langchain` WITHOUT build artifacts from the host.
mkdir -p "$monorepo_langchain_dir/"
cp -r "$original_langchain_dir"/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) "$monorepo_langchain_dir/"

yarn
# Copy the turbo and package.json files for monorepo
cp "$original_turbo_json_dir" "$monorepo_dir/"
cp "$original_package_json_dir" "$monorepo_dir/"

cd /app
# Replace any workspace dependencies in `@langchain/standard-tests`
# with "latest" for the version.
mkdir -p "$updater_script_dir"
cp "$original_updater_script_dir"/* "$updater_script_dir/"

node /updater_script/update_resolutions_lowest.js
# Install deps (e.g semver) for the updater script
cd "$updater_script_dir"
yarn
# Run the updater scripts
node "update_workspace_dependencies.js"
node "update_resolutions_lowest.js"

# Navigate back to monorepo root and install dependencies
cd "$monorepo_dir"
yarn

# Check the test command completes successfully
NODE_OPTIONS=--experimental-vm-modules yarn run jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%
# Navigate into `langchain` and run tests
# We need to run inside the `langchain` directory so turbo repo does
# not try to build the package/it's workspace dependencies.
cd "$monorepo_langchain_dir"
yarn test
2 changes: 1 addition & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@
"clean": "rm -rf .turbo dist/",
"prepack": "yarn build",
"release": "release-it --only-version --config .release-it.json",
"test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
"test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
"test:integration": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
"test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-anthropic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@jest/globals": "^29.5.0",
"@langchain/community": "workspace:*",
"@langchain/scripts": "~0.0.14",
"@langchain/standard-tests": "workspace:*",
"@langchain/standard-tests": "0.0.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"dpdm": "^3.12.0",
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-azure-openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@azure/identity": "^4.0.1",
"@jest/globals": "^29.5.0",
"@langchain/scripts": "~0.0.14",
"@langchain/standard-tests": "workspace:*",
"@langchain/standard-tests": "0.0.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"dpdm": "^3.12.0",
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@cloudflare/workers-types": "^4.20231218.0",
"@jest/globals": "^29.5.0",
"@langchain/scripts": "~0.0.14",
"@langchain/standard-tests": "workspace:*",
"@langchain/standard-tests": "0.0.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tsconfig/recommended": "^1.0.3",
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-cohere/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@jest/globals": "^29.5.0",
"@langchain/scripts": "~0.0.14",
"@langchain/standard-tests": "workspace:*",
"@langchain/standard-tests": "0.0.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tsconfig/recommended": "^1.0.3",
Expand Down
12 changes: 8 additions & 4 deletions libs/langchain-community/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"author": "LangChain",
"license": "MIT",
"dependencies": {
"@langchain/core": "~0.2.6",
"@langchain/openai": "~0.1.0",
"@langchain/core": "0.2.6",
"@langchain/openai": "0.1.0",
"binary-extensions": "^2.2.0",
"expr-eval": "^2.0.2",
"flat": "^5.0.2",
Expand Down Expand Up @@ -79,7 +79,7 @@
"@huggingface/inference": "^2.6.4",
"@jest/globals": "^29.5.0",
"@langchain/scripts": "~0.0.14",
"@langchain/standard-tests": "workspace:*",
"@langchain/standard-tests": "0.0.0",
"@layerup/layerup-security": "^1.5.12",
"@mendable/firecrawl-js": "^0.0.13",
"@mlc-ai/web-llm": "^0.2.40",
Expand Down Expand Up @@ -4019,5 +4019,9 @@
"chains/graph_qa/cypher.js",
"chains/graph_qa/cypher.d.ts",
"chains/graph_qa/cypher.d.cts"
]
],
"resolutions": {
"@langchain/core": "0.2.6",
"@langchain/openai": "0.1.0"
}
}
2 changes: 1 addition & 1 deletion libs/langchain-google-gauth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"devDependencies": {
"@jest/globals": "^29.5.0",
"@langchain/scripts": "~0.0.14",
"@langchain/standard-tests": "workspace:*",
"@langchain/standard-tests": "0.0.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tsconfig/recommended": "^1.0.3",
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-google-genai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"devDependencies": {
"@jest/globals": "^29.5.0",
"@langchain/scripts": "~0.0.14",
"@langchain/standard-tests": "workspace:*",
"@langchain/standard-tests": "0.0.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tsconfig/recommended": "^1.0.3",
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-groq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@jest/globals": "^29.5.0",
"@langchain/openai": "workspace:^",
"@langchain/scripts": "~0.0.14",
"@langchain/standard-tests": "workspace:*",
"@langchain/standard-tests": "0.0.0",
"@swc/core": "^1.3.90",
"@swc/jest": "^0.2.29",
"@tsconfig/recommended": "^1.0.3",
Expand Down
Loading

0 comments on commit 3881093

Please sign in to comment.