diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml index 69112bbcddc1..383adfa0f68b 100644 --- a/.github/DISCUSSION_TEMPLATE/q-a.yml +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -21,8 +21,8 @@ body: Relevant links to check before opening a question to see if your question has already been answered, fixed or if there's another way to solve your problem: - [LangChain.js documentation with the integrated search](https://js.langchain.com/v0.2/docs/introduction), - [API Reference](https://v02.api.js.langchain.com/), + [LangChain.js documentation with the integrated search](https://js.langchain.com/docs/introduction), + [API Reference](https://api.js.langchain.com/), [GitHub search](https://github.com/langchain-ai/langchainjs), [LangChain.js Github Discussions](https://github.com/langchain-ai/langchainjs/discussions), [LangChain.js Github Issues](https://github.com/langchain-ai/langchainjs/issues?q=is%3Aissue), diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 169d0fcf84b7..b1063e54b46b 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -15,8 +15,8 @@ body: Relevant links to check before filing a bug report to see if your issue has already been reported, fixed or if there's another way to solve your problem: - [LangChain.js documentation with the integrated search](https://js.langchain.com/v0.2/docs/introduction), - [API Reference](https://v02.api.js.langchain.com/), + [LangChain.js documentation with the integrated search](https://js.langchain.com/docs/introduction), + [API Reference](https://api.js.langchain.com/), [GitHub search](https://github.com/langchain-ai/langchainjs), [LangChain.js Github Discussions](https://github.com/langchain-ai/langchainjs/discussions), [LangChain.js Github Issues](https://github.com/langchain-ai/langchainjs/issues?q=is%3Aissue), diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml index 5944f3e2bdf5..35ada1d22652 100644 --- a/.github/ISSUE_TEMPLATE/documentation.yml +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -20,8 +20,8 @@ body: If you're in the wrong place, here are some helpful links to find a better place to ask your question: - [LangChain.js documentation with the integrated search](https://js.langchain.com/v0.2/docs/introduction), - [API Reference](https://v02.api.js.langchain.com/), + [LangChain.js documentation with the integrated search](https://js.langchain.com/docs/introduction), + [API Reference](https://api.js.langchain.com/), [GitHub search](https://github.com/langchain-ai/langchainjs), [LangChain.js Github Discussions](https://github.com/langchain-ai/langchainjs/discussions), [LangChain.js Github Issues](https://github.com/langchain-ai/langchainjs/issues?q=is%3Aissue), diff --git a/.github/workflows/validate_new_notebooks.yml b/.github/workflows/validate_new_notebooks.yml index d61b7ab9ec77..2d3580464fe6 100644 --- a/.github/workflows/validate_new_notebooks.yml +++ b/.github/workflows/validate_new_notebooks.yml @@ -50,10 +50,21 @@ jobs: run: | notebooks=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | tr ' ' '\n' | grep '^docs/core_docs/.*\.ipynb$' || true) if [ -n "$notebooks" ]; then + failed_notebooks=() for notebook in $notebooks; do absolute_path="$GITHUB_WORKSPACE/$notebook" + set +e yarn workspace @langchain/scripts notebook_validate "$absolute_path" + if [ $? -ne 0 ]; then + failed_notebooks+=("$notebook") + fi + set -e done + if [ ${#failed_notebooks[@]} -ne 0 ]; then + echo "The following notebooks failed validation:" + printf '%s\n' "${failed_notebooks[@]}" + exit 1 + fi else echo "No notebooks in docs/core_docs to validate." fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a45a37c2e606..5b49049e637a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ LangChain supports several different types of integrations with third-party prov We welcome such contributions, but ask that you read our dedicated [integration contribution guide](https://github.com/langchain-ai/langchainjs/blob/main/.github/contributing/INTEGRATIONS.md) for specific details and patterns to consider before opening a pull request. -You can also check out the [guides on extending LangChain.js](https://js.langchain.com/v0.2/docs/how_to/#custom) in our docs. +You can also check out the [guides on extending LangChain.js](https://js.langchain.com/docs/how_to/#custom) in our docs. #### Integration packages diff --git a/README.md b/README.md index bcf98e556a10..988669952b12 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ LangChain is written in TypeScript and can be used in: - **Reason**: rely on a language model to reason (about how to answer based on provided context, what actions to take, etc.) This framework consists of several parts. -- **Open-source libraries**: Build your applications using LangChain's open-source [building blocks](https://js.langchain.com/v0.2/docs/concepts#langchain-expression-language), [components](https://js.langchain.com/v0.2/docs/concepts), and [third-party integrations](https://js.langchain.com/v0.2/docs/integrations/platforms/). -Use [LangGraph.js](https://js.langchain.com/v0.2/docs/concepts/#langgraphjs) to build stateful agents with first-class streaming and human-in-the-loop support. +- **Open-source libraries**: Build your applications using LangChain's open-source [building blocks](https://js.langchain.com/docs/concepts#langchain-expression-language), [components](https://js.langchain.com/docs/concepts), and [third-party integrations](https://js.langchain.com/docs/integrations/platforms/). +Use [LangGraph.js](https://js.langchain.com/docs/concepts/#langgraphjs) to build stateful agents with first-class streaming and human-in-the-loop support. - **Productionization**: Use [LangSmith](https://docs.smith.langchain.com/) to inspect, monitor and evaluate your chains, so that you can continuously optimize and deploy with confidence. -- **Deployment**: Turn your LangGraph applications into production-ready APIs and Assistants with [LangGraph Cloud](https://langchain-ai.github.io/langgraph/cloud/) (currently Python-only). +- **Deployment**: Turn your LangGraph applications into production-ready APIs and Assistants with [LangGraph Cloud](https://langchain-ai.github.io/langgraph/cloud/). The LangChain libraries themselves are made up of several different packages. - **[`@langchain/core`](https://github.com/langchain-ai/langchainjs/blob/main/langchain-core)**: Base abstractions and LangChain Expression Language. @@ -53,12 +53,12 @@ This library aims to assist in the development of those types of applications. C **❓Question Answering over specific documents** -- [Documentation](https://js.langchain.com/v0.2/docs/tutorials/rag/) +- [Documentation](https://js.langchain.com/docs/tutorials/rag/) - End-to-end Example: [Doc-Chatbot](https://github.com/dissorial/doc-chatbot) **πŸ’¬ Chatbots** -- [Documentation](https://js.langchain.com/v0.2/docs/tutorials/chatbot) +- [Documentation](https://js.langchain.com/docs/tutorials/chatbot) - End-to-end Example: [Chat-LangChain](https://github.com/langchain-ai/chat-langchain) ## πŸš€ How does LangChain help? @@ -81,15 +81,15 @@ Data Augmented Generation involves specific types of chains that first interact **πŸ€– Agents:** -Agents allow an LLM autonomy over how a task is accomplished. Agents make decisions about which Actions to take, then take that Action, observe the result, and repeat until the task is complete. LangChain provides a [standard interface for agents](https://js.langchain.com/v0.2/docs/concepts/#agents), along with [LangGraph.js](https://github.com/langchain-ai/langgraphjs/) for building custom agents. +Agents allow an LLM autonomy over how a task is accomplished. Agents make decisions about which Actions to take, then take that Action, observe the result, and repeat until the task is complete. LangChain provides a [standard interface for agents](https://js.langchain.com/docs/concepts/#agents), along with [LangGraph.js](https://github.com/langchain-ai/langgraphjs/) for building custom agents. ## πŸ“– Documentation Please see [here](https://js.langchain.com) for full documentation, which includes: -- [Getting started](https://js.langchain.com/v0.2/docs/introduction): installation, setting up the environment, simple examples -- Overview of the [interfaces](https://js.langchain.com/v0.2/docs/how_to/lcel_cheatsheet/), [modules](https://js.langchain.com/v0.2/docs/concepts) and [integrations](https://js.langchain.com/v0.2/docs/integrations/platforms/) -- [Tutorial](https://js.langchain.com/v0.2/docs/tutorials/) walkthroughs +- [Getting started](https://js.langchain.com/docs/introduction): installation, setting up the environment, simple examples +- Overview of the [interfaces](https://js.langchain.com/docs/how_to/lcel_cheatsheet/), [modules](https://js.langchain.com/docs/concepts) and [integrations](https://js.langchain.com/docs/integrations/platforms/) +- [Tutorial](https://js.langchain.com/docs/tutorials/) walkthroughs - [Reference](https://api.js.langchain.com): full API docs ## πŸ’ Contributing diff --git a/cookbook/rag_fusion.ipynb b/cookbook/rag_fusion.ipynb index 4ca55c2055bd..fe1587d5bea9 100644 --- a/cookbook/rag_fusion.ipynb +++ b/cookbook/rag_fusion.ipynb @@ -19,7 +19,7 @@ "source": [ "## Setup\n", "\n", - "For this example we'll use an in memory store as our vectorstore/retriever, and some fake data. You can swap out the vectorstore for your [preferred LangChain.js option](https://js.langchain.com/v0.2/docs/integrations/vectorstores) later.\n" + "For this example we'll use an in memory store as our vectorstore/retriever, and some fake data. You can swap out the vectorstore for your [preferred LangChain.js option](https://js.langchain.com/docs/integrations/vectorstores) later.\n" ] }, { diff --git a/dependency_range_tests/scripts/langchain/node/update_resolutions_latest.js b/dependency_range_tests/scripts/langchain/node/update_resolutions_latest.js new file mode 100644 index 000000000000..ac3609e60a8a --- /dev/null +++ b/dependency_range_tests/scripts/langchain/node/update_resolutions_latest.js @@ -0,0 +1,17 @@ +const fs = require("fs"); + +const communityPackageJsonPath = "package.json"; +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; + currentPackageJson.peerDependencies["@langchain/core"] = "latest"; +} + +// Stupid hack +currentPackageJson.resolutions = { + ...currentPackageJson.resolutions, + "jackspeak": "2.1.1" +}; + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/langchain/node/update_resolutions_lowest.js b/dependency_range_tests/scripts/langchain/node/update_resolutions_lowest.js index 5712a8b5770c..badc28a30819 100644 --- a/dependency_range_tests/scripts/langchain/node/update_resolutions_lowest.js +++ b/dependency_range_tests/scripts/langchain/node/update_resolutions_lowest.js @@ -5,28 +5,24 @@ const communityPackageJsonPath = "package.json"; const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); -if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { +if (currentPackageJson.peerDependencies["@langchain/core"] && !currentPackageJson.peerDependencies["@langchain/core"].includes("rc")) { const minVersion = semver.minVersion( - currentPackageJson.dependencies["@langchain/core"] + currentPackageJson.peerDependencies["@langchain/core"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/core": minVersion, - }; - currentPackageJson.dependencies = { - ...currentPackageJson.dependencies, + currentPackageJson.peerDependencies = { + ...currentPackageJson.peerDependencies, "@langchain/core": minVersion, }; } +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; +} + if (currentPackageJson.dependencies["@langchain/openai"] && !currentPackageJson.dependencies["@langchain/openai"].includes("rc")) { const minVersion = semver.minVersion( currentPackageJson.dependencies["@langchain/openai"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/openai": minVersion, - }; currentPackageJson.dependencies = { ...currentPackageJson.dependencies, "@langchain/openai": minVersion, @@ -37,14 +33,16 @@ if (currentPackageJson.dependencies["@langchain/textsplitters"] && !currentPacka const minVersion = semver.minVersion( currentPackageJson.dependencies["@langchain/textsplitters"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/textsplitters": minVersion, - }; currentPackageJson.dependencies = { ...currentPackageJson.dependencies, "@langchain/textsplitters": minVersion, }; } +// Stupid hack +currentPackageJson.resolutions = { + ...currentPackageJson.resolutions, + "jackspeak": "2.1.1" +}; + fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/langchain/test-with-latest-deps.sh b/dependency_range_tests/scripts/langchain/test-with-latest-deps.sh index ca79988c4346..4488c5710cb7 100644 --- a/dependency_range_tests/scripts/langchain/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/langchain/test-with-latest-deps.sh @@ -10,7 +10,19 @@ 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/langchain/node/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) /updater_script/ + +cd /updater_script + +yarn + +cd /app + +node /updater_script/update_resolutions_latest.js + yarn +yarn add @langchain/core # 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/langchain/test-with-lowest-deps.sh b/dependency_range_tests/scripts/langchain/test-with-lowest-deps.sh index e7f36a21cd01..36cf0443d9e1 100644 --- a/dependency_range_tests/scripts/langchain/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/langchain/test-with-lowest-deps.sh @@ -21,7 +21,11 @@ cd /app node /updater_script/update_resolutions_lowest.js +# Read the @langchain/core version from peerDependencies +core_version=$(node -p "require('./package.json').peerDependencies['@langchain/core']") + yarn +yarn add @langchain/core@$core_version # 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/with_standard_tests/anthropic/node/update_resolutions_latest.js b/dependency_range_tests/scripts/with_standard_tests/anthropic/node/update_resolutions_latest.js new file mode 100644 index 000000000000..2c2c9317d4db --- /dev/null +++ b/dependency_range_tests/scripts/with_standard_tests/anthropic/node/update_resolutions_latest.js @@ -0,0 +1,11 @@ +const fs = require("fs"); + +const communityPackageJsonPath = "/app/monorepo/libs/langchain-anthropic/package.json"; +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; + currentPackageJson.peerDependencies["@langchain/core"] = "latest"; +} + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/anthropic/node/update_resolutions_lowest.js b/dependency_range_tests/scripts/with_standard_tests/anthropic/node/update_resolutions_lowest.js index d2ed5e7ac928..5500268dba0d 100644 --- a/dependency_range_tests/scripts/with_standard_tests/anthropic/node/update_resolutions_lowest.js +++ b/dependency_range_tests/scripts/with_standard_tests/anthropic/node/update_resolutions_lowest.js @@ -5,18 +5,18 @@ const communityPackageJsonPath = "/app/monorepo/libs/langchain-anthropic/package const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); -if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { +if (currentPackageJson.peerDependencies["@langchain/core"] && !currentPackageJson.peerDependencies["@langchain/core"].includes("rc")) { const minVersion = semver.minVersion( - currentPackageJson.dependencies["@langchain/core"] + currentPackageJson.peerDependencies["@langchain/core"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/core": minVersion, - }; - currentPackageJson.dependencies = { - ...currentPackageJson.dependencies, + currentPackageJson.peerDependencies = { + ...currentPackageJson.peerDependencies, "@langchain/core": minVersion, }; } +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; +} + fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-latest-deps.sh index 80beb0a3568d..bcf32dfbaa9a 100644 --- a/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-latest-deps.sh @@ -23,6 +23,7 @@ cd "$updater_script_dir" # Update any workspace dep to the latest version since not all workspaces are # available in the test enviroment. node "update_workspace_deps.js" +node "update_resolutions_latest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" @@ -32,4 +33,6 @@ yarn # We need to run inside the anthropic directory so turbo repo does # not try to build the package/its workspace dependencies. cd "$monorepo_anthropic_dir" + +yarn add @langchain/core yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh index 0ae8ac11503b..11eae9e21a80 100644 --- a/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh @@ -5,7 +5,7 @@ set -euxo pipefail export CI=true monorepo_dir="/app/monorepo" -monorepo_openai_dir="/app/monorepo/libs/langchain-anthropic" +monorepo_anthropic_dir="/app/monorepo/libs/langchain-anthropic" updater_script_dir="/app/updater_script" original_updater_script_dir="/scripts/with_standard_tests/anthropic/node" @@ -20,8 +20,8 @@ cp "$original_updater_script_dir"/* "$updater_script_dir/" cd "$updater_script_dir" yarn # Run the updater script -node "update_resolutions_lowest.js" node "update_workspace_deps.js" +node "update_resolutions_lowest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" @@ -30,5 +30,11 @@ yarn # Navigate into `@langchain/anthropic` to build and run tests # We need to run inside the package directory so turbo repo does # not try to build the package/its workspace dependencies. -cd "$monorepo_openai_dir" +cd "$monorepo_anthropic_dir" + +# Read the @langchain/core version from peerDependencies +core_version=$(node -p "require('./package.json').peerDependencies['@langchain/core']") + +# Install @langchain/core at the specified version +yarn add @langchain/core@$core_version yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/cohere/node/update_resolutions_latest.js b/dependency_range_tests/scripts/with_standard_tests/cohere/node/update_resolutions_latest.js new file mode 100644 index 000000000000..607a8d3298b6 --- /dev/null +++ b/dependency_range_tests/scripts/with_standard_tests/cohere/node/update_resolutions_latest.js @@ -0,0 +1,11 @@ +const fs = require("fs"); + +const communityPackageJsonPath = "/app/monorepo/libs/langchain-cohere/package.json"; +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; + currentPackageJson.peerDependencies["@langchain/core"] = "latest"; +} + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/cohere/node/update_resolutions_lowest.js b/dependency_range_tests/scripts/with_standard_tests/cohere/node/update_resolutions_lowest.js index 4f349584032b..10b1cc7160e7 100644 --- a/dependency_range_tests/scripts/with_standard_tests/cohere/node/update_resolutions_lowest.js +++ b/dependency_range_tests/scripts/with_standard_tests/cohere/node/update_resolutions_lowest.js @@ -5,18 +5,18 @@ const communityPackageJsonPath = "/app/monorepo/libs/langchain-cohere/package.js const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); -if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { +if (currentPackageJson.peerDependencies["@langchain/core"] && !currentPackageJson.peerDependencies["@langchain/core"].includes("rc")) { const minVersion = semver.minVersion( - currentPackageJson.dependencies["@langchain/core"] + currentPackageJson.peerDependencies["@langchain/core"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/core": minVersion, - }; - currentPackageJson.dependencies = { - ...currentPackageJson.dependencies, + currentPackageJson.peerDependencies = { + ...currentPackageJson.peerDependencies, "@langchain/core": minVersion, }; } +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; +} + fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh index 0c7c23bd9793..24c5ccc872f8 100644 --- a/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh @@ -6,11 +6,24 @@ export CI=true # New monorepo directory paths monorepo_dir="/app/monorepo" -monorepo_openai_dir="/app/monorepo/libs/langchain-cohere" +monorepo_cohere_dir="/app/monorepo/libs/langchain-cohere" + +# Updater script will not live inside the monorepo +updater_script_dir="/app/updater_script" + +# Original directory paths +original_updater_script_dir="/scripts/with_standard_tests/cohere/node" # Run the shared script to copy all necessary folders/files bash /scripts/with_standard_tests/shared.sh cohere +mkdir -p "$updater_script_dir" +cp "$original_updater_script_dir"/* "$updater_script_dir/" +cd "$updater_script_dir" +# Update any workspace dep to the latest version since not all workspaces are +# available in the test enviroment. +node "update_resolutions_latest.js" + # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" yarn @@ -18,5 +31,7 @@ yarn # Navigate into `@langchain/cohere` to build and run tests # We need to run inside the cohere directory so turbo repo does # not try to build the package/its workspace dependencies. -cd "$monorepo_openai_dir" +cd "$monorepo_cohere_dir" + +yarn add @langchain/core yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh index 7ec4bc0c2d84..3868e0a9d6c0 100644 --- a/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh @@ -32,4 +32,10 @@ yarn # We need to run inside the cohere directory so turbo repo does # not try to build the package/its workspace dependencies. cd "$monorepo_cohere_dir" + +# Read the @langchain/core version from peerDependencies +core_version=$(node -p "require('./package.json').peerDependencies['@langchain/core']") + +# Install @langchain/core at the specified version +yarn add @langchain/core@$core_version yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_latest.js b/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_latest.js new file mode 100644 index 000000000000..6c143c486d54 --- /dev/null +++ b/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_latest.js @@ -0,0 +1,16 @@ +const fs = require("fs"); + +const communityPackageJsonPath = "/app/monorepo/libs/langchain-community/package.json"; +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; + currentPackageJson.peerDependencies["@langchain/core"] = "latest"; +} + +if (currentPackageJson.dependencies["@langchain/openai"]) { + delete currentPackageJson.dependencies["@langchain/openai"]; + currentPackageJson.dependencies["@langchain/openai"] = "latest"; +} + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_lowest.js b/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_lowest.js index b0da1629189e..791929cdca90 100644 --- a/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_lowest.js +++ b/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_lowest.js @@ -5,32 +5,32 @@ const communityPackageJsonPath = "/app/monorepo/libs/langchain-community/package const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); -if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { +if (currentPackageJson.peerDependencies["@langchain/core"] && !currentPackageJson.peerDependencies["@langchain/core"].includes("rc")) { const minVersion = semver.minVersion( - currentPackageJson.dependencies["@langchain/core"] + currentPackageJson.peerDependencies["@langchain/core"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/core": minVersion, - }; - currentPackageJson.dependencies = { - ...currentPackageJson.dependencies, + currentPackageJson.peerDependencies = { + ...currentPackageJson.peerDependencies, "@langchain/core": minVersion, }; } +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; +} + if (currentPackageJson.dependencies["@langchain/openai"] && !currentPackageJson.dependencies["@langchain/openai"].includes("rc")) { const minVersion = semver.minVersion( currentPackageJson.dependencies["@langchain/openai"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/openai": minVersion, - }; currentPackageJson.dependencies = { ...currentPackageJson.dependencies, "@langchain/openai": minVersion, }; } +if (currentPackageJson.devDependencies["@langchain/openai"]) { + delete currentPackageJson.devDependencies["@langchain/openai"]; +} + fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_npm.js b/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_npm.js new file mode 100644 index 000000000000..9a80bc65bade --- /dev/null +++ b/dependency_range_tests/scripts/with_standard_tests/community/node/update_resolutions_npm.js @@ -0,0 +1,10 @@ +const fs = require("fs"); + +const communityPackageJsonPath = "/app/monorepo/libs/langchain-community/package.json"; +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; +} + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/community/npm-install.sh b/dependency_range_tests/scripts/with_standard_tests/community/npm-install.sh index c5294fe8eb2f..4e33fae2dd58 100644 --- a/dependency_range_tests/scripts/with_standard_tests/community/npm-install.sh +++ b/dependency_range_tests/scripts/with_standard_tests/community/npm-install.sh @@ -8,10 +8,23 @@ export CI=true monorepo_dir="/app/monorepo" monorepo_community_dir="/app/monorepo/libs/langchain-community" +# Updater script will not live inside the monorepo +updater_script_dir="/app/updater_script" + +# Original directory paths +original_updater_script_dir="/scripts/with_standard_tests/community/node" + # Run the shared script to copy all necessary folders/files bash /scripts/with_standard_tests/shared.sh community +mkdir -p "$updater_script_dir" +cp "$original_updater_script_dir"/* "$updater_script_dir/" +cd "$updater_script_dir" + +node "update_resolutions_npm.js" + # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +npm install @langchain/core npm install diff --git a/dependency_range_tests/scripts/with_standard_tests/community/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/community/test-with-latest-deps.sh index f7c65b71ac00..df63a38f8546 100644 --- a/dependency_range_tests/scripts/with_standard_tests/community/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/community/test-with-latest-deps.sh @@ -8,9 +8,22 @@ export CI=true monorepo_dir="/app/monorepo" monorepo_community_dir="/app/monorepo/libs/langchain-community" +# Updater script will not live inside the monorepo +updater_script_dir="/app/updater_script" + +# Original directory paths +original_updater_script_dir="/scripts/with_standard_tests/community/node" + # Run the shared script to copy all necessary folders/files bash /scripts/with_standard_tests/shared.sh community +mkdir -p "$updater_script_dir" +cp "$original_updater_script_dir"/* "$updater_script_dir/" +cd "$updater_script_dir" +# Update any workspace dep to the latest version since not all workspaces are +# available in the test enviroment. +node "update_resolutions_latest.js" + # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" yarn @@ -19,4 +32,6 @@ yarn # We need to run inside the community directory so turbo repo does # not try to build the package/its workspace dependencies. cd "$monorepo_community_dir" + +yarn add @langchain/core yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/community/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/community/test-with-lowest-deps.sh index a96debf040b7..e6d70012a809 100644 --- a/dependency_range_tests/scripts/with_standard_tests/community/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/community/test-with-lowest-deps.sh @@ -32,4 +32,10 @@ yarn # We need to run inside the package directory so turbo repo does # not try to build the package/its workspace dependencies. cd "$monorepo_community_dir" + +# Read the @langchain/core version from peerDependencies +core_version=$(node -p "require('./package.json').peerDependencies['@langchain/core']") + +# Install @langchain/core at the specified version +yarn add @langchain/core@$core_version yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/update_resolutions_latest.js b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/update_resolutions_latest.js new file mode 100644 index 000000000000..78c768cd15a1 --- /dev/null +++ b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/update_resolutions_latest.js @@ -0,0 +1,11 @@ +const fs = require("fs"); + +const communityPackageJsonPath = "/app/monorepo/libs/langchain-google-vertexai/package.json"; +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; + currentPackageJson.peerDependencies["@langchain/core"] = "latest"; +} + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/update_resolutions_lowest.js b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/update_resolutions_lowest.js index a600da592199..91d3e5eab402 100644 --- a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/update_resolutions_lowest.js +++ b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/update_resolutions_lowest.js @@ -5,28 +5,24 @@ const communityPackageJsonPath = "/app/monorepo/libs/langchain-google-vertexai/p const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); -if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { +if (currentPackageJson.peerDependencies["@langchain/core"] && !currentPackageJson.peerDependencies["@langchain/core"].includes("rc")) { const minVersion = semver.minVersion( - currentPackageJson.dependencies["@langchain/core"] + currentPackageJson.peerDependencies["@langchain/core"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/core": minVersion, - }; - currentPackageJson.dependencies = { - ...currentPackageJson.dependencies, + currentPackageJson.peerDependencies = { + ...currentPackageJson.peerDependencies, "@langchain/core": minVersion, }; } +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; +} + 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, diff --git a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh index 3d43d870e321..567366beb19e 100644 --- a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh @@ -6,11 +6,24 @@ export CI=true # New monorepo directory paths monorepo_dir="/app/monorepo" -monorepo_openai_dir="/app/monorepo/libs/langchain-google-vertexai" +monorepo_vertexai_dir="/app/monorepo/libs/langchain-google-vertexai" + +# Updater script will not live inside the monorepo +updater_script_dir="/app/updater_script" + +# Original directory paths +original_updater_script_dir="/scripts/with_standard_tests/google-vertexai/node" # Run the shared script to copy all necessary folders/files bash /scripts/with_standard_tests/shared.sh google-vertexai +mkdir -p "$updater_script_dir" +cp "$original_updater_script_dir"/* "$updater_script_dir/" +cd "$updater_script_dir" +# Update any workspace dep to the latest version since not all workspaces are +# available in the test enviroment. +node "update_resolutions_latest.js" + # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" yarn @@ -18,5 +31,7 @@ yarn # Navigate into `@langchain/google-vertexai` to build and run tests # We need to run inside the google-vertexai directory so turbo repo does # not try to build the package/its workspace dependencies. -cd "$monorepo_openai_dir" +cd "$monorepo_vertexai_dir" + +yarn add @langchain/core @langchain/google-gauth yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh index a8de92d9b983..23dcf3ba0d82 100644 --- a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh @@ -5,7 +5,7 @@ set -euxo pipefail export CI=true monorepo_dir="/app/monorepo" -monorepo_openai_dir="/app/monorepo/libs/langchain-google-vertexai" +monorepo_vertexai_dir="/app/monorepo/libs/langchain-google-vertexai" updater_script_dir="/app/updater_script" updater_script_dir="/app/updater_script" original_updater_script_dir="/scripts/with_standard_tests/google-vertexai/node" @@ -31,5 +31,11 @@ yarn # Navigate into `@langchain/package` to build and run tests # We need to run inside the package directory so turbo repo does # not try to build the package/its workspace dependencies. -cd "$monorepo_openai_dir" +cd "$monorepo_vertexai_dir" + +# Read the @langchain/core version from peerDependencies +core_version=$(node -p "require('./package.json').peerDependencies['@langchain/core']") + +# Install @langchain/core at the specified version +yarn add @langchain/core@$core_version yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/node/update_workspace_dependencies.js b/dependency_range_tests/scripts/with_standard_tests/node/update_workspace_dependencies.js index 755700a9c749..2d769e5d0082 100644 --- a/dependency_range_tests/scripts/with_standard_tests/node/update_workspace_dependencies.js +++ b/dependency_range_tests/scripts/with_standard_tests/node/update_workspace_dependencies.js @@ -14,7 +14,7 @@ if (currentPackageJson.dependencies["@langchain/core"]) { if (currentPackageJson.devDependencies["@langchain/scripts"]) { currentPackageJson.devDependencies = { ...currentPackageJson.devDependencies, - "@langchain/scripts": "latest", + "@langchain/scripts": "*", }; } diff --git a/dependency_range_tests/scripts/with_standard_tests/openai/node/update_resolutions_latest.js b/dependency_range_tests/scripts/with_standard_tests/openai/node/update_resolutions_latest.js new file mode 100644 index 000000000000..c402ea87ed7d --- /dev/null +++ b/dependency_range_tests/scripts/with_standard_tests/openai/node/update_resolutions_latest.js @@ -0,0 +1,11 @@ +const fs = require("fs"); + +const communityPackageJsonPath = "/app/monorepo/libs/langchain-openai/package.json"; +const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); + +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; + currentPackageJson.peerDependencies["@langchain/core"] = "latest"; +} + +fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/openai/node/update_resolutions_lowest.js b/dependency_range_tests/scripts/with_standard_tests/openai/node/update_resolutions_lowest.js index d54d62d708e7..ed5b19175245 100644 --- a/dependency_range_tests/scripts/with_standard_tests/openai/node/update_resolutions_lowest.js +++ b/dependency_range_tests/scripts/with_standard_tests/openai/node/update_resolutions_lowest.js @@ -5,18 +5,18 @@ const communityPackageJsonPath = "/app/monorepo/libs/langchain-openai/package.js const currentPackageJson = JSON.parse(fs.readFileSync(communityPackageJsonPath)); -if (currentPackageJson.dependencies["@langchain/core"] && !currentPackageJson.dependencies["@langchain/core"].includes("rc")) { +if (currentPackageJson.peerDependencies["@langchain/core"] && !currentPackageJson.peerDependencies["@langchain/core"].includes("rc")) { const minVersion = semver.minVersion( - currentPackageJson.dependencies["@langchain/core"] + currentPackageJson.peerDependencies["@langchain/core"] ).version; - currentPackageJson.overrides = { - ...currentPackageJson.overrides, - "@langchain/core": minVersion, - }; - currentPackageJson.dependencies = { - ...currentPackageJson.dependencies, + currentPackageJson.peerDependencies = { + ...currentPackageJson.peerDependencies, "@langchain/core": minVersion, }; } +if (currentPackageJson.devDependencies["@langchain/core"]) { + delete currentPackageJson.devDependencies["@langchain/core"]; +} + fs.writeFileSync(communityPackageJsonPath, JSON.stringify(currentPackageJson, null, 2)); diff --git a/dependency_range_tests/scripts/with_standard_tests/openai/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/openai/test-with-latest-deps.sh index 69bb581e414a..2080ec786467 100644 --- a/dependency_range_tests/scripts/with_standard_tests/openai/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/openai/test-with-latest-deps.sh @@ -8,9 +8,22 @@ export CI=true monorepo_dir="/app/monorepo" monorepo_openai_dir="/app/monorepo/libs/langchain-openai" +# Updater script will not live inside the monorepo +updater_script_dir="/app/updater_script" + +# Original directory paths +original_updater_script_dir="/scripts/with_standard_tests/openai/node" + # Run the shared script to copy all necessary folders/files bash /scripts/with_standard_tests/shared.sh openai +mkdir -p "$updater_script_dir" +cp "$original_updater_script_dir"/* "$updater_script_dir/" +cd "$updater_script_dir" +# Update any workspace dep to the latest version since not all workspaces are +# available in the test enviroment. +node "update_resolutions_latest.js" + # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" yarn @@ -19,4 +32,6 @@ yarn # We need to run inside the openai directory so turbo repo does # not try to build the package/its workspace dependencies. cd "$monorepo_openai_dir" + +yarn add @langchain/core yarn test diff --git a/dependency_range_tests/scripts/with_standard_tests/openai/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/openai/test-with-lowest-deps.sh index 91536708b13c..6f47d13e8aa1 100644 --- a/dependency_range_tests/scripts/with_standard_tests/openai/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/openai/test-with-lowest-deps.sh @@ -32,4 +32,10 @@ yarn # We need to run inside the package directory so turbo repo does # not try to build the package/its workspace dependencies. cd "$monorepo_openai_dir" + +# Read the @langchain/core version from peerDependencies +core_version=$(node -p "require('./package.json').peerDependencies['@langchain/core']") + +# Install @langchain/core at the specified version +yarn add @langchain/core@$core_version yarn test diff --git a/docs/api_refs/scripts/create-entrypoints.js b/docs/api_refs/scripts/create-entrypoints.js index 6ffd4d34a056..9f51f27fa1b2 100644 --- a/docs/api_refs/scripts/create-entrypoints.js +++ b/docs/api_refs/scripts/create-entrypoints.js @@ -28,7 +28,7 @@ const BASE_TYPEDOC_CONFIG = { name: "LangChain.js", skipErrorChecking: true, exclude: ["dist"], - hostedBaseUrl: "https://v02.api.js.langchain.com/", + hostedBaseUrl: "https://v03.api.js.langchain.com/", entryPointStrategy: "packages", }; diff --git a/docs/api_refs/scripts/typedoc-plugin.js b/docs/api_refs/scripts/typedoc-plugin.js index d3eae80196ab..b32db37d77d6 100644 --- a/docs/api_refs/scripts/typedoc-plugin.js +++ b/docs/api_refs/scripts/typedoc-plugin.js @@ -67,7 +67,8 @@ const SCRIPT_HTML = `