Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Ultrahi authored Jan 5, 2024
2 parents 068f9b1 + 7261afd commit e01e57a
Show file tree
Hide file tree
Showing 1,227 changed files with 22,094 additions and 6,782 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,17 @@ jobs:
uses:
./.github/workflows/test-exports.yml
secrets: inherit

examples-build:
name: Build examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install dependencies
run: yarn install --immutable
- name: Build examples
run: yarn build --filter=examples
52 changes: 52 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Dependency compatibility tests

on:
push:
branches: ["main"]
pull_request:
# Do not run this workflow if only docs changed.
paths-ignore:
- 'docs/**'
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI

# If another push to the same PR or branch happens while this workflow is still running,
# cancel the earlier run in favor of the next run.
#
# There's no point in testing an outdated version of the code. GitHub only allows
# a limited number of job runners to be active at the same time, so it's better to cancel
# pointless jobs early so that more useful jobs can run sooner.
concurrency:
group: exports-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
NODE_VERSION: "18.x"

# Run a separate job for each check in the docker-compose file,
# so that they run in parallel instead of overwhelming the default 2 CPU runner.
jobs:
test-langchain-with-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 with latest deps
run: docker compose -f dependency_range_tests/docker-compose.yml run test-langchain-with-latest-deps

test-langchain-with-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 with lowest deps
run: docker compose -f dependency_range_tests/docker-compose.yml run test-langchain-with-lowest-deps
14 changes: 7 additions & 7 deletions .github/workflows/test-exports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
SKIP_API_DOCS: true

- name: Test esbuild exports
run: docker compose -f docker-compose.yml run test-exports-esbuild
run: docker compose -f environment_tests/docker-compose.yml run test-exports-esbuild

exports-esm:
runs-on: ubuntu-latest
Expand All @@ -60,7 +60,7 @@ jobs:
SKIP_API_DOCS: true

- name: Test esm exports
run: docker compose -f docker-compose.yml run test-exports-esm
run: docker compose -f environment_tests/docker-compose.yml run test-exports-esm

exports-cjs:
runs-on: ubuntu-latest
Expand All @@ -80,7 +80,7 @@ jobs:
SKIP_API_DOCS: true

- name: Test cjs exports
run: docker compose -f docker-compose.yml run test-exports-cjs
run: docker compose -f environment_tests/docker-compose.yml run test-exports-cjs

exports-cf:
runs-on: ubuntu-latest
Expand All @@ -100,7 +100,7 @@ jobs:
SKIP_API_DOCS: true

- name: Test cf exports
run: docker compose -f docker-compose.yml run test-exports-cf
run: docker compose -f environment_tests/docker-compose.yml run test-exports-cf

exports-vercel:
runs-on: ubuntu-latest
Expand All @@ -120,7 +120,7 @@ jobs:
SKIP_API_DOCS: true

- name: Test vercel exports
run: docker compose -f docker-compose.yml run test-exports-vercel
run: docker compose -f environment_tests/docker-compose.yml run test-exports-vercel

exports-vite:
runs-on: ubuntu-latest
Expand All @@ -140,7 +140,7 @@ jobs:
SKIP_API_DOCS: true

- name: Test vite exports
run: docker compose -f docker-compose.yml run test-exports-vite
run: docker compose -f environment_tests/docker-compose.yml run test-exports-vite

# exports-bun:
# runs-on: ubuntu-latest
Expand All @@ -160,4 +160,4 @@ jobs:
# SKIP_API_DOCS: true

# - name: Test bun exports
# run: docker compose -f docker-compose.yml run test-exports-bun
# run: docker compose -f environment_tests/docker-compose.yml run test-exports-bun
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,14 @@ You can invoke the release flow by calling `yarn release` from the package root.
There are three parameters which can be passed to this script, one required and two optional.

- __Required__: `--workspace <workspace name>`. eg: `--workspace @langchain/core` (always appended as the first flag when running `yarn release`)
- __Optional__: `--version <version number>` eg: `--version 1.0.8`. Defaults to adding one to the patch version.
- __Optional__: `--bump-deps` eg `--bump-deps` Will find all packages in the repo which depend on this workspace and checkout a new branch, update the dep version, run yarn install, commit & push to new branch.
- __Optional__: `--tag <tag>` eg `--tag beta` Add a tag to the NPM release.
- __Optional__: `--inc <inc>` eg `--inc patch` The semver increment to apply to the version. Can be one of `major`, `minor`, `patch`, `premajor`, `preminor`, `prepatch`, or `prerelease`. Defaults to `patch`.

This script automatically bumps the package version, creates a new release branch with the changes, pushes the branch to GitHub, uses `release-it` to automatically release to NPM, and more depending on the flags passed.

Halfway through this script, you'll be prompted to enter an NPM OTP (typically from an authenticator app). This value is not stored anywhere and is only used to authenticate the NPM release.

Full example: `yarn release @langchain/core --version 2.0.0 --bump-deps --tag beta --inc major`.
Full example: `yarn release @langchain/core --bump-deps --tag beta`.

### 🛠️ Tooling

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ This library aims to assist in the development of those types of applications. C

**💬 Chatbots**

- [Documentation](https://js.langchain.com/docs/modules/model_io/models/chat/)
- [Documentation](https://js.langchain.com/docs/modules/model_io/chat/)
- End-to-end Example: [Chat-LangChain](https://github.com/langchain-ai/chat-langchain)

## 🚀 How does LangChain help?
Expand Down
30 changes: 30 additions & 0 deletions dependency_range_tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3"
services:
test-langchain-with-latest-deps:
image: node:18
environment:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
working_dir: /app
volumes:
- ../langchain:/langchain
- ./scripts:/scripts
command: bash /scripts/test-langchain-with-latest-deps.sh
test-langchain-with-lowest-deps:
image: node:18
environment:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
working_dir: /app
volumes:
- ../langchain:/langchain
- ./scripts:/scripts
command: bash /scripts/test-langchain-with-lowest-deps.sh
success:
image: alpine:3.14
command: echo "Success"
depends_on:
test-langchain-with-latest-deps:
condition: service_completed_successfully
test-langchain-with-lowest-deps:
condition: service_completed_successfully
9 changes: 9 additions & 0 deletions dependency_range_tests/scripts/node/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
34 changes: 34 additions & 0 deletions dependency_range_tests/scripts/node/update_resolutions_lowest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require("fs");
const semver = require("semver");

const currentPackageJson = JSON.parse(fs.readFileSync("./package.json"));

if (currentPackageJson.dependencies["@langchain/core"]) {
const minVersion = semver.minVersion(
currentPackageJson.dependencies["@langchain/core"]
).version;
currentPackageJson.resolutions = {
...currentPackageJson.resolutions,
"@langchain/core": minVersion,
};
currentPackageJson.dependencies = {
...currentPackageJson.dependencies,
"@langchain/core": minVersion,
};
}

if (currentPackageJson.dependencies["@langchain/community"]) {
const minVersion = semver.minVersion(
currentPackageJson.dependencies["@langchain/community"]
).version;
currentPackageJson.resolutions = {
...currentPackageJson.resolutions,
"@langchain/community": minVersion,
};
currentPackageJson.dependencies = {
...currentPackageJson.dependencies,
"@langchain/community": minVersion,
};
}

fs.writeFileSync("./package.json", JSON.stringify(currentPackageJson, null, 2));
22 changes: 22 additions & 0 deletions dependency_range_tests/scripts/node/yarn.lock
Original file line number Diff line number Diff line change
@@ -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==
16 changes: 16 additions & 0 deletions dependency_range_tests/scripts/test-langchain-with-latest-deps.sh
Original file line number Diff line number Diff line change
@@ -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 ../langchain/!(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%
27 changes: 27 additions & 0 deletions dependency_range_tests/scripts/test-langchain-with-lowest-deps.sh
Original file line number Diff line number Diff line change
@@ -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 ../langchain/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) ./

mkdir -p /updater_script
cp -r /scripts/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%
Loading

0 comments on commit e01e57a

Please sign in to comment.