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/scripts/deployDomainVercel.sh b/.github/scripts/deployDomainVercel.sh new file mode 100644 index 000000000000..f27bb803c8b6 --- /dev/null +++ b/.github/scripts/deployDomainVercel.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Check if an argument is provided +if [ $# -eq 0 ]; then + echo "Error: Please provide a version string as an argument." + exit 1 +fi + +inputString=$1 + +# Check if VERCEL_TOKEN is set +if [ -z "$VERCEL_TOKEN" ]; then + echo "Error: VERCEL_TOKEN is not set." + exit 1 +fi + +# save stdout and stderr to files +vercel deploy --prebuilt --token="$VERCEL_TOKEN" >deployment-url.txt 2>error.txt + +# check the exit code +code=$? +if [ $code -eq 0 ]; then + # Set the deploymentUrl using the input string + deploymentUrl="${inputString}.api.js.langchain.com" + vercel alias $(cat deployment-url.txt) $deploymentUrl --token="$VERCEL_TOKEN" --scope="langchain" +else + # Handle the error + errorMessage=$(cat error.txt) + echo "There was an error: $errorMessage" +fi \ No newline at end of file diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 9174f2fc31ef..3f0a82c37fea 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -6,10 +6,10 @@ on: pull_request: # Only run this workflow if the following directories have changed. paths: - - 'langchain/**' - - 'langchain-core/**' - - 'libs/**' - workflow_dispatch: # Allows triggering the workflow manually in GitHub UI + - "langchain/**" + - "langchain-core/**" + - "libs/**" + 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. @@ -24,7 +24,7 @@ concurrency: env: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" - NODE_VERSION: "18.x" + NODE_VERSION: "20.x" COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} # Run a separate job for each check in the docker-compose file, @@ -75,42 +75,42 @@ jobs: - name: Test LangChain with lowest deps run: docker compose -f dependency_range_tests/docker-compose.yml run langchain-lowest-deps - # Community - community-latest-deps: - runs-on: ubuntu-latest - needs: get-changed-files - if: contains(needs.get-changed-files.outputs.changed_files, 'langchain-core/') || contains(needs.get-changed-files.outputs.changed_files, 'libs/langchain-openai/') || contains(needs.get-changed-files.outputs.changed_files, 'libs/langchain-community/') - 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 `@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 community-latest-deps + # # Community + # community-latest-deps: + # runs-on: ubuntu-latest + # needs: get-changed-files + # if: contains(needs.get-changed-files.outputs.changed_files, 'langchain-core/') || contains(needs.get-changed-files.outputs.changed_files, 'libs/langchain-openai/') || contains(needs.get-changed-files.outputs.changed_files, 'libs/langchain-community/') + # 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 `@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 community-latest-deps - community-lowest-deps: - runs-on: ubuntu-latest - needs: get-changed-files - if: contains(needs.get-changed-files.outputs.changed_files, 'libs/langchain-community/') - 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 `@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 community-lowest-deps + # community-lowest-deps: + # runs-on: ubuntu-latest + # needs: get-changed-files + # if: contains(needs.get-changed-files.outputs.changed_files, 'libs/langchain-community/') + # 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 `@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 community-lowest-deps community-npm-install: runs-on: ubuntu-latest diff --git a/.github/workflows/deploy-api-refs-preview.yml b/.github/workflows/deploy-api-refs-preview.yml index db2c512d18fa..65904ae772a0 100644 --- a/.github/workflows/deploy-api-refs-preview.yml +++ b/.github/workflows/deploy-api-refs-preview.yml @@ -2,7 +2,8 @@ name: Deploy API Refs Preview on: workflow_dispatch: # Allows triggering the workflow manually in GitHub UI - pull_request: + # Avoid deploying on PR due to rate limits + # pull_request: # 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. diff --git a/.github/workflows/deploy-api-refs-prod.yml b/.github/workflows/deploy-api-refs-prod.yml index c26b880732e9..5b4a0e4bcbd0 100644 --- a/.github/workflows/deploy-api-refs-prod.yml +++ b/.github/workflows/deploy-api-refs-prod.yml @@ -3,7 +3,7 @@ name: Deploy API Refs Prod on: workflow_dispatch: # Allows triggering the workflow manually in GitHub UI push: - branches: ["main"] + branches: ["main", "v0.2"] # 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. @@ -34,6 +34,21 @@ jobs: - name: Build All Projects run: yarn turbo:command build --filter=!examples --filter=!api_refs --filter=!core_docs --filter=!create-langchain-integration - name: Build Project Artifacts - run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} - - name: Deploy Project Artifacts to Vercel - run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} \ No newline at end of file + run: | + if [ ${{ github.ref }} = 'refs/heads/main' ]; then + vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + else + vercel build --token=${{ secrets.VERCEL_TOKEN }} + fi + - name: Deploy to Vercel + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + run: | + if [ ${{ github.ref }} = 'refs/heads/main' ]; then + vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} + elif [ ${{ github.ref }} = 'refs/heads/v0.2' ]; then + .github/scripts/deployDomainVercel.sh v02 + else + echo "Error: Deployment is only allowed for 'main' or 'v0.2' branches." + exit 1 + fi \ No newline at end of file diff --git a/.github/workflows/standard-tests.yml b/.github/workflows/standard-tests.yml index f732f1f3c8d7..21048ad6710d 100644 --- a/.github/workflows/standard-tests.yml +++ b/.github/workflows/standard-tests.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - package: [anthropic, cohere, google-genai, groq, mistralai, aws] + package: [anthropic, cohere, google-genai, groq, mistralai, aws, google-vertexai-web] steps: - uses: actions/checkout@v4 - name: Use Node.js 18.x @@ -24,16 +24,15 @@ jobs: - name: Run integration tests for ${{ matrix.package }} run: yarn turbo test:integration --filter=@langchain/${{ matrix.package }} env: - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} - GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} - GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} - MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} - DISABLE_CONSOLE_LOGS: "true" - # @langchain/aws credentials - BEDROCK_AWS_ACCESS_KEY_ID: ${{ secrets.BEDROCK_AWS_ACCESS_KEY_ID }} - BEDROCK_AWS_SECRET_ACCESS_KEY: ${{ secrets.BEDROCK_AWS_SECRET_ACCESS_KEY }} - BEDROCK_AWS_REGION: "us-east-1" + ANTHROPIC_API_KEY: ${{ matrix.package == 'anthropic' && secrets.ANTHROPIC_API_KEY || '' }} + COHERE_API_KEY: ${{ matrix.package == 'cohere' && secrets.COHERE_API_KEY || '' }} + GOOGLE_API_KEY: ${{ matrix.package == 'google-genai' && secrets.GOOGLE_API_KEY || '' }} + GROQ_API_KEY: ${{ matrix.package == 'groq' && secrets.GROQ_API_KEY || '' }} + MISTRAL_API_KEY: ${{ matrix.package == 'mistralai' && secrets.MISTRAL_API_KEY || '' }} + BEDROCK_AWS_ACCESS_KEY_ID: ${{ matrix.package == 'aws' && secrets.BEDROCK_AWS_ACCESS_KEY_ID || '' }} + BEDROCK_AWS_SECRET_ACCESS_KEY: ${{ matrix.package == 'aws' && secrets.BEDROCK_AWS_SECRET_ACCESS_KEY || '' }} + BEDROCK_AWS_REGION: ${{ matrix.package == 'aws' && 'us-east-1' || '' }} + GOOGLE_VERTEX_AI_WEB_CREDENTIALS: ${{ matrix.package == 'google-vertexai-web' && secrets.GOOGLE_VERTEX_AI_WEB_CREDENTIALS || '' }} # The `@langchain/openai` package contains standard tests for ChatOpenAI and AzureChatOpenAI # We want to run these separately, so we need to pass the exact path for each test, which means @@ -55,7 +54,6 @@ jobs: run: yarn workspace @langchain/openai test:single src/tests/chat_models_structured_output.int.test.ts src/tests/chat_models-extended.int.test.ts src/tests/chat_models-vision.int.test.ts src/tests/chat_models.int.test.ts src/tests/chat_models.standard.int.test.ts env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - DISABLE_CONSOLE_LOGS: "true" standard-tests-azure-openai: runs-on: ubuntu-latest @@ -77,7 +75,6 @@ jobs: AZURE_OPENAI_API_DEPLOYMENT_NAME: "chat" AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }} AZURE_OPENAI_BASE_PATH: ${{ secrets.AZURE_OPENAI_BASE_PATH }} - DISABLE_CONSOLE_LOGS: "true" standard-tests-bedrock: runs-on: ubuntu-latest @@ -98,4 +95,21 @@ jobs: BEDROCK_AWS_REGION: "us-east-1" BEDROCK_AWS_SECRET_ACCESS_KEY: ${{ secrets.BEDROCK_AWS_SECRET_ACCESS_KEY }} BEDROCK_AWS_ACCESS_KEY_ID: ${{ secrets.BEDROCK_AWS_ACCESS_KEY_ID }} - DISABLE_CONSOLE_LOGS: "true" + + standard-tests-fireworks: + 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 + cache: "yarn" + - name: Install dependencies + run: yarn install --immutable --mode=skip-build + - name: Build `@langchain/community` + run: yarn build --filter=@langchain/community + - name: Run standard tests (integration) for `@langchain/community` ChatFireworks + run: yarn workspace @langchain/community test:single src/chat_models/tests/chatfireworks.standard.int.test.ts + env: + FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }} diff --git a/.github/workflows/validate_new_notebooks.yml b/.github/workflows/validate_new_notebooks.yml index bb6bffebc062..2d3580464fe6 100644 --- a/.github/workflows/validate_new_notebooks.yml +++ b/.github/workflows/validate_new_notebooks.yml @@ -50,9 +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 - yarn notebook:validate "$notebook" + 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 \ No newline at end of file + fi diff --git a/.vercelignore b/.vercelignore new file mode 100644 index 000000000000..b4990557b566 --- /dev/null +++ b/.vercelignore @@ -0,0 +1,4 @@ +node_modules/ +**/node_modules/ +.next/ +**/.next/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a45a37c2e606..66afe82b8794 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 @@ -105,9 +105,9 @@ You can invoke the script by calling `yarn release`. If new dependencies have be There are three parameters which can be passed to this script, one required and two optional. -- __Required__: ``. eg: `@langchain/core` The name of the package to release. Can be found in the `name` value of the package's `package.json` -- __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. Generally, this is not necessary. -- __Optional__: `--tag ` eg `--tag beta` Add a tag to the NPM release. Useful if you want to push a release candidate. +- **Required**: ``. eg: `@langchain/core` The name of the package to release. Can be found in the `name` value of the package's `package.json` +- **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. Generally, this is not necessary. +- **Optional**: `--tag ` eg `--tag beta` Add a tag to the NPM release. Useful if you want to push a release candidate. 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. @@ -323,6 +323,10 @@ Similar to linting, we recognize documentation can be annoying. If you do not wa Documentation and the skeleton lives under the `docs/` folder. Example code is imported from under the `examples/` folder. +**If you are contributing an integration, please copy and use the appropriate template from here:** + +https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-scripts/src/cli/docs/templates + ### Running examples If you add a new major piece of functionality, it is helpful to add an 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/deno.json b/deno.json index 15679236f0e4..4c6004fa02b2 100644 --- a/deno.json +++ b/deno.json @@ -1,20 +1,20 @@ { "imports": { - "langchain/": "npm:/langchain/", + "langchain/": "npm:/langchain@0.3.2/", + "@langchain/anthropic": "npm:@langchain/anthropic@0.3.0", + "@langchain/cloudflare": "npm:@langchain/cloudflare@0.1.0", + "@langchain/community/": "npm:/@langchain/community@0.3.0/", + "@langchain/openai": "npm:@langchain/openai@0.3.0", + "@langchain/cohere": "npm:@langchain/cohere@0.3.0", + "@langchain/textsplitters": "npm:@langchain/textsplitters@0.1.0", + "@langchain/google-vertexai-web": "npm:@langchain/google-vertexai-web@0.1.0", + "@langchain/mistralai": "npm:@langchain/mistralai@0.1.0", + "@langchain/core/": "npm:/@langchain/core@0.3.1/", + "@langchain/pinecone": "npm:@langchain/pinecone@0.1.0", + "@langchain/google-common": "npm:@langchain/google-common@0.1.0", + "@langchain/langgraph": "npm:/@langchain/langgraph@0.2.3", + "@langchain/langgraph/": "npm:/@langchain/langgraph@0.2.3/", "@faker-js/faker": "npm:@faker-js/faker", - "@langchain/anthropic": "npm:@langchain/anthropic", - "@langchain/cloudflare": "npm:@langchain/cloudflare", - "@langchain/community/": "npm:/@langchain/community@0.2.2/", - "@langchain/openai": "npm:@langchain/openai", - "@langchain/cohere": "npm:@langchain/cohere", - "@langchain/textsplitters": "npm:@langchain/textsplitters", - "@langchain/google-vertexai-web": "npm:@langchain/google-vertexai-web", - "@langchain/mistralai": "npm:@langchain/mistralai", - "@langchain/core/": "npm:/@langchain/core@0.2.16/", - "@langchain/pinecone": "npm:@langchain/pinecone", - "@langchain/google-common": "npm:@langchain/google-common", - "@langchain/langgraph": "npm:/@langchain/langgraph@0.0.21", - "@langchain/langgraph/": "npm:/@langchain/langgraph@0.0.21/", "@microsoft/fetch-event-source": "npm:@microsoft/fetch-event-source", "@pinecone-database/pinecone": "npm:@pinecone-database/pinecone", "cheerio": "npm:cheerio", 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..0833d484b46c --- /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) { + delete currentPackageJson.devDependencies; +} + +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..1f66fd5c5448 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,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" + +node "update_resolutions_npm.js" + # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" -npm install - +npm install @langchain/core --production +npm install --production 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 = `