Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacob/core #3354

Merged
merged 25 commits into from
Nov 22, 2023
Merged
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
50 changes: 25 additions & 25 deletions .github/workflows/test-exports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn workspace langchain build
run: yarn workspace langchain-core build && yarn workspace langchain build
shell: bash
env:
SKIP_API_DOCS: true
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn workspace langchain build
run: yarn workspace langchain-core build && yarn workspace langchain build
shell: bash
env:
SKIP_API_DOCS: true
Expand All @@ -74,7 +74,7 @@ jobs:
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn workspace langchain build
run: yarn workspace langchain-core build && yarn workspace langchain build
shell: bash
env:
SKIP_API_DOCS: true
Expand All @@ -94,7 +94,7 @@ jobs:
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn workspace langchain build
run: yarn workspace langchain-core build && yarn workspace langchain build
shell: bash
env:
SKIP_API_DOCS: true
Expand All @@ -114,7 +114,7 @@ jobs:
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn workspace langchain build
run: yarn workspace langchain-core build && yarn workspace langchain build
shell: bash
env:
SKIP_API_DOCS: true
Expand All @@ -134,30 +134,30 @@ jobs:
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn workspace langchain build
run: yarn workspace langchain-core build && yarn workspace langchain build
shell: bash
env:
SKIP_API_DOCS: true

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

exports-bun:
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: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn workspace langchain build
shell: bash
env:
SKIP_API_DOCS: true

- name: Test bun exports
run: docker compose -f docker-compose.yml run test-exports-bun
# exports-bun:
# 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: Install dependencies
# run: yarn install --immutable
# - name: Build
# run: yarn workspace langchain-core build && yarn workspace langchain build
# shell: bash
# env:
# SKIP_API_DOCS: true

# - name: Test bun exports
# run: docker compose -f docker-compose.yml run test-exports-bun
27 changes: 17 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- ./environment_tests/test-exports-esbuild:/package
- ./environment_tests/scripts:/scripts
- ./langchain:/langchain
- ./langchain-core:/langchain-core
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-esm:
image: node:18
Expand All @@ -21,6 +22,7 @@ services:
- ./environment_tests/test-exports-esm:/package
- ./environment_tests/scripts:/scripts
- ./langchain:/langchain
- ./langchain-core:/langchain-core
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-cjs:
image: node:18
Expand All @@ -32,6 +34,7 @@ services:
- ./environment_tests/test-exports-cjs:/package
- ./environment_tests/scripts:/scripts
- ./langchain:/langchain
- ./langchain-core:/langchain-core
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-cf:
image: node:18
Expand All @@ -43,6 +46,7 @@ services:
- ./environment_tests/test-exports-cf:/package
- ./environment_tests/scripts:/scripts
- ./langchain:/langchain
- ./langchain-core:/langchain-core
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-vercel:
image: node:18
Expand All @@ -54,6 +58,7 @@ services:
- ./environment_tests/test-exports-vercel:/package
- ./environment_tests/scripts:/scripts
- ./langchain:/langchain
- ./langchain-core:/langchain-core
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-vite:
image: node:18
Expand All @@ -65,15 +70,17 @@ services:
- ./environment_tests/test-exports-vite:/package
- ./environment_tests/scripts:/scripts
- ./langchain:/langchain
- ./langchain-core:/langchain-core
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-bun:
image: oven/bun
working_dir: /app
volumes:
- ./environment_tests/test-exports-bun:/package
- ./environment_tests/scripts:/scripts
- ./langchain:/langchain-workspace
command: bash /scripts/docker-bun-ci-entrypoint.sh
# test-exports-bun:
# image: oven/bun
# working_dir: /app
# volumes:
# - ./environment_tests/test-exports-bun:/package
# - ./environment_tests/scripts:/scripts
# - ./langchain:/langchain-workspace
# - ./langchain-core:/langchain-core-workspace
# command: bash /scripts/docker-bun-ci-entrypoint.sh
success:
image: alpine:3.14
command: echo "Success"
Expand All @@ -90,5 +97,5 @@ services:
condition: service_completed_successfully
test-exports-vite:
condition: service_completed_successfully
test-exports-bun:
condition: service_completed_successfully
# test-exports-bun:
# condition: service_completed_successfully
4 changes: 1 addition & 3 deletions docs/api_refs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "next dev -p 3001",
"typedoc": "npx typedoc --options typedoc.json",
"build:scripts": "node ./scripts/generate-api-refs.js && node ./scripts/update-typedoc-css.js",
"build": "yarn build:scripts && next build",
"build": "yarn workspace langchain-core build && yarn workspace langchain build && yarn build:scripts && next build",
"start": "yarn build && next start -p 3001",
"lint": "next lint"
},
Expand All @@ -16,14 +16,12 @@
"react-dom": "^18"
},
"devDependencies": {
"@types/fs-extra": "^11",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.0.1",
"fs-extra": "^11.1.1",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"ts-morph": "^20.0.0",
Expand Down
5 changes: 2 additions & 3 deletions docs/api_refs/scripts/generate-api-refs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { Project, SyntaxKind } = require("ts-morph");
const { exec } = require("child_process");
const fse = require("fs-extra");

async function updateCodeWithIgnoreTags(tsConfigFilePath) {
const project = new Project({
Expand Down Expand Up @@ -70,7 +69,7 @@ async function updateCodeWithIgnoreTags(tsConfigFilePath) {
async function copyLangChain(pathToLangChain) {
// copy the entire langchain dir to .

await fse.copy(pathToLangChain, "./langchain", { overwrite: false });
await execAsync(`cp -r ${pathToLangChain} ./langchain`);
return {
rootPath: `${process.cwd()}/langchain`,
tsConfigPath: `${process.cwd()}/langchain/tsconfig.json`,
Expand All @@ -79,7 +78,7 @@ async function copyLangChain(pathToLangChain) {

async function deleteLangChain(pathToLangChain) {
// delete the langchain dir
await fse.remove(pathToLangChain);
await execAsync(`rm -rf ${pathToLangChain}`);
}

const execAsync = async (command, options) => new Promise((resolve, reject) => {
Expand Down
1 change: 1 addition & 0 deletions docs/api_refs/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
"./langchain/src/experimental/hubs/makersuite/googlemakersuitehub.ts",
"./langchain/src/experimental/chains/violation_of_expectations/index.ts",
"./langchain/src/evaluation/index.ts",
"./langchain/src/runnables/index.ts",
"./langchain/src/runnables/remote.ts"
]
}
12 changes: 12 additions & 0 deletions environment_tests/scripts/docker-bun-ci-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ shopt -s extglob
# avoid copying build artifacts from the host
cp -r ../package/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) .

mkdir ../langchain-core
cp -r ../langchain-core-workspace/!(node_modules|build|.next|.turbo) ../langchain-core

mkdir ../langchain
cp -r ../langchain-workspace/!(node_modules|build|.next|.turbo) ../langchain

# Link the package locally
cd ../langchain-core
bun link

# Reinstall deps with bun because bun doesn't install deps of linked deps
bun install --no-save

# Link the package locally
cd ../langchain
sed -i 's/"langchain-core": "[^\"]*"/"langchain-core": "link:langchain-core"/g' package.json
bun link

# Reinstall deps with bun because bun doesn't install deps of linked deps
Expand All @@ -23,6 +34,7 @@ bun install --no-save
cd ../app

# Replace the workspace dependency with the local copy, and install all others
sed -i 's/"langchain-core": "workspace:\*"/"langchain-core": "link:langchain-core"/g' package.json
sed -i 's/"langchain": "workspace:\*"/"langchain": "link:langchain"/g' package.json
bun install --no-save

Expand Down
1 change: 1 addition & 0 deletions environment_tests/scripts/docker-ci-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cp ../root/yarn.lock ../root/.yarnrc.yml .
# Replace the workspace dependency with the local copy, and install all others
# Avoid calling "yarn add ../langchain" as yarn berry does seem to hang for ~30s
# before installation actually occurs
sed -i 's/"langchain-core": "workspace:\*"/"langchain-core": "..\/langchain-core"/g' package.json
sed -i 's/"langchain": "workspace:\*"/"langchain": "..\/langchain"/g' package.json
yarn install --no-immutable

Expand Down
3 changes: 2 additions & 1 deletion environment_tests/test-exports-bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"dependencies": {
"d3-dsv": "2",
"hnswlib-node": "^1.4.2",
"langchain": "workspace:*"
"langchain": "workspace:*",
"langchain-core": "workspace:*"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
Expand Down
1 change: 1 addition & 0 deletions environment_tests/test-exports-bun/src/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ export * from "langchain/experimental/chat_models/bittensor";
export * from "langchain/experimental/chat_models/ollama_functions";
export * from "langchain/experimental/chains/violation_of_expectations";
export * from "langchain/evaluation";
export * from "langchain/runnables";
export * from "langchain/runnables/remote";
3 changes: 2 additions & 1 deletion environment_tests/test-exports-cf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"wrangler": "3.7.0"
},
"dependencies": {
"langchain": "workspace:*"
"langchain": "workspace:*",
"langchain-core": "workspace:*"
},
"private": true,
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions environment_tests/test-exports-cf/src/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ export * from "langchain/experimental/chat_models/bittensor";
export * from "langchain/experimental/chat_models/ollama_functions";
export * from "langchain/experimental/chains/violation_of_expectations";
export * from "langchain/evaluation";
export * from "langchain/runnables";
export * from "langchain/runnables/remote";
3 changes: 2 additions & 1 deletion environment_tests/test-exports-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"dependencies": {
"d3-dsv": "2",
"hnswlib-node": "^1.4.2",
"langchain": "workspace:*"
"langchain": "workspace:*",
"langchain-core": "workspace:*"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
Expand Down
1 change: 1 addition & 0 deletions environment_tests/test-exports-cjs/src/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ const experimental_chat_models_bittensor = require("langchain/experimental/chat_
const experimental_chat_models_ollama_functions = require("langchain/experimental/chat_models/ollama_functions");
const experimental_chains_violation_of_expectations = require("langchain/experimental/chains/violation_of_expectations");
const evaluation = require("langchain/evaluation");
const runnables = require("langchain/runnables");
const runnables_remote = require("langchain/runnables/remote");
3 changes: 2 additions & 1 deletion environment_tests/test-exports-esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"dependencies": {
"d3-dsv": "2",
"hnswlib-node": "^1.4.2",
"langchain": "workspace:*"
"langchain": "workspace:*",
"langchain-core": "workspace:*"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
Expand Down
1 change: 1 addition & 0 deletions environment_tests/test-exports-esbuild/src/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ import * as experimental_chat_models_bittensor from "langchain/experimental/chat
import * as experimental_chat_models_ollama_functions from "langchain/experimental/chat_models/ollama_functions";
import * as experimental_chains_violation_of_expectations from "langchain/experimental/chains/violation_of_expectations";
import * as evaluation from "langchain/evaluation";
import * as runnables from "langchain/runnables";
import * as runnables_remote from "langchain/runnables/remote";
3 changes: 2 additions & 1 deletion environment_tests/test-exports-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"dependencies": {
"d3-dsv": "2",
"hnswlib-node": "^1.4.2",
"langchain": "workspace:*"
"langchain": "workspace:*",
"langchain-core": "workspace:*"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
Expand Down
1 change: 1 addition & 0 deletions environment_tests/test-exports-esm/src/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ import * as experimental_chat_models_bittensor from "langchain/experimental/chat
import * as experimental_chat_models_ollama_functions from "langchain/experimental/chat_models/ollama_functions";
import * as experimental_chains_violation_of_expectations from "langchain/experimental/chains/violation_of_expectations";
import * as evaluation from "langchain/evaluation";
import * as runnables from "langchain/runnables";
import * as runnables_remote from "langchain/runnables/remote";
1 change: 1 addition & 0 deletions environment_tests/test-exports-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"eslint": "8.37.0",
"eslint-config-next": "13.3.0",
"langchain": "workspace:*",
"langchain-core": "workspace:*",
"next": "13.4.9",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
1 change: 1 addition & 0 deletions environment_tests/test-exports-vercel/src/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ export * from "langchain/experimental/chat_models/bittensor";
export * from "langchain/experimental/chat_models/ollama_functions";
export * from "langchain/experimental/chains/violation_of_expectations";
export * from "langchain/evaluation";
export * from "langchain/runnables";
export * from "langchain/runnables/remote";
3 changes: 2 additions & 1 deletion environment_tests/test-exports-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"test": "tsc"
},
"dependencies": {
"langchain": "workspace:*"
"langchain": "workspace:*",
"langchain-core": "workspace:*"
},
"devDependencies": {
"typescript": "^5.0.0",
Expand Down
1 change: 1 addition & 0 deletions environment_tests/test-exports-vite/src/entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ export * from "langchain/experimental/chat_models/bittensor";
export * from "langchain/experimental/chat_models/ollama_functions";
export * from "langchain/experimental/chains/violation_of_expectations";
export * from "langchain/evaluation";
export * from "langchain/runnables";
export * from "langchain/runnables/remote";
11 changes: 0 additions & 11 deletions examples/src/indexes/vector_stores/prisma_vectorstore/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,4 @@ export const run = async () => {
// Use the default filter a.k.a {"content": "default"}
const resultTwo = await vectorStore.similaritySearch("Hello world", 1);
console.log(resultTwo);

// Override the local filter
const resultThree = await vectorStore.similaritySearchWithScore(
"Hello world",
1,
{
content: { equals: "different_content" },
customForeignKey: { in: ["<id1>", "<id2>", "<id3>"] },
}
);
console.log(resultThree);
};
Loading