!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss")}catch(t){}return!1}())

[Skip to main content](#__docusaurus_skipToContent_fallback)

You are viewing the **preview** v0.2 docs. View the **stable** v0.1 docs [here](/v0.1/docs/get_started/introduction/). Leave feedback on the v0.2 docs [here](https://github.com/langchain-ai/langchainjs/discussions/5386).

[

![🦜️🔗 Langchain](/v0.2/img/brand/wordmark.png)![🦜️🔗 Langchain](/v0.2/img/brand/wordmark-dark.png)

](/v0.2/)[Integrations](/v0.2/docs/integrations/platforms/)[API Reference](https://v02.api.js.langchain.com)

[More](#)

*   [People](/v0.2/docs/people/)
*   [Community](/v0.2/docs/community)
*   [Tutorials](/v0.2/docs/additional_resources/tutorials)
*   [Contributing](/v0.2/docs/contributing)

[v0.2](#)

*   [v0.2](/v0.2/docs/introduction)
*   [v0.1](https://js.langchain.com/v0.1/docs/get_started/introduction)

[🦜🔗](#)

*   [LangSmith](https://smith.langchain.com)
*   [LangSmith Docs](https://docs.smith.langchain.com)
*   [LangChain Hub](https://smith.langchain.com/hub)
*   [LangServe](https://github.com/langchain-ai/langserve)
*   [Python Docs](https://python.langchain.com/)

[Chat](https://chatjs.langchain.com)[](https://github.com/langchain-ai/langchainjs)

Search

*   [Contributing](/v0.2/docs/contributing/)
    
    *   [Welcome Contributors](/v0.2/docs/contributing/)
    *   [Repository Structure](/v0.2/docs/contributing/repo_structure)
    *   [Contribute Code](/v0.2/docs/contributing/code)
    *   [Testing](/v0.2/docs/contributing/testing)
    *   [Documentation](/v0.2/docs/contributing/documentation/style_guide)
        
    *   [Contribute Integrations](/v0.2/docs/contributing/integrations)
    *   [FAQ](/v0.2/docs/contributing/faq)

*   [](/v0.2/)
*   Contributing
*   Contribute Code

On this page

Contribute Code
===============

To contribute to this project, please follow the ["fork and pull request"](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) workflow. Please do not try to push directly to this repo unless you are a maintainer.

Please follow the checked-in pull request template when opening pull requests. Note related issues and tag relevant maintainers.

Pull requests cannot land without passing the formatting, linting, and testing checks first. See [Testing](#testing) and [Formatting and Linting](#formatting-and-linting) for how to run these checks locally.

It's essential that we maintain great documentation and testing. If you:

*   Fix a bug
    *   Add a relevant unit or integration test when possible. These live in `**/tests/*.test.ts` and `**/tests/*.int.test.ts/`.
*   Make an improvement
    *   Update any affected example notebooks and documentation. These live in `docs`.
    *   Update unit and integration tests when relevant.
*   Add a feature
    *   Add a demo notebook/MDX file in `docs/core_docs/docs`.
    *   Add unit and integration tests.

We are a small, progress-oriented team. If there's something you'd like to add or change, opening a pull request is the best way to get our attention.

🚀 Quick Start[​](#-quick-start "Direct link to 🚀 Quick Start")
----------------------------------------------------------------

This quick start guide explains how to run the repository locally. For a [development container](https://containers.dev/), see the [.devcontainer folder](https://github.com/langchain-ai/langchainjs/tree/main/.devcontainer).

### 🏭 Release process[​](#-release-process "Direct link to 🏭 Release process")

As of now, LangChain has an ad hoc release process: releases are cut with high frequency by a developer and published to [npm](https://www.npmjs.com/package/langchain).

LangChain follows the [semver](https://semver.org/) versioning standard. However, as pre-1.0 software, even patch releases may contain [non-backwards-compatible changes](https://semver.org/#spec-item-4).

If your contribution has made its way into a release, we will want to give you credit on Twitter (only if you want though)! If you have a Twitter account you would like us to mention, please let us know in the PR or in another manner.

#### Integration releases[​](#integration-releases "Direct link to Integration releases")

The release script can be executed only while on a fresh `main` branch, with no un-committed changes, from the package root. If working from a fork of the repository, make sure to sync the forked `main` branch with the upstream `main` branch first.

You can invoke the script by calling `yarn release`. If new dependencies have been added to the integration package, install them first (i.e. run `yarn`, then `yarn release`).

There are three parameters which can be passed to this script, one required and two optional.

*   **Required**: `<workspace name>`. 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 <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.

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

> **Note** Unless releasing `langchain`, `no` should be answered to all prompts following `Publish @langchain/<package> to npm?`. Then, the change should be manually committed with the following commit message: `<package>[patch]: Release <new version>`. E.g.: `groq[patch]: Release 0.0.1`.

Docker must be running if releasing one of `langchain`, `@langchain/core` or `@langchain/community`. These packages run LangChain's export tests, which run inside docker containers.

Full example: `yarn release @langchain/core`.

### 🛠️ Tooling[​](#️-tooling "Direct link to 🛠️ Tooling")

This project uses the following tools, which are worth getting familiar with if you plan to contribute:

*   **[yarn](https://yarnpkg.com/) (v3.4.1)** - dependency management
*   **[eslint](https://eslint.org/)** - enforcing standard lint rules
*   **[prettier](https://prettier.io/)** - enforcing standard code formatting
*   **[jest](https://jestjs.io/)** - testing code
*   **[TypeDoc](https://typedoc.org/)** - reference doc generation from comments
*   **[Docusaurus](https://docusaurus.io/)** - static site generation for documentation

🚀 Quick Start[​](#-quick-start-1 "Direct link to 🚀 Quick Start")
------------------------------------------------------------------

Clone this repo, then cd into it:

    cd langchainjs

Next, try running the following common tasks:

✅ Common Tasks[​](#-common-tasks "Direct link to ✅ Common Tasks")
-----------------------------------------------------------------

Our goal is to make it as easy as possible for you to contribute to this project. All of the below commands should be run from within a workspace directory (e.g. `langchain`, `libs/langchain-community`) unless otherwise noted.

    cd langchain

Or, if you are working on a community integration:

    cd libs/langchain-community

### Setup[​](#setup "Direct link to Setup")

**Prerequisite**: Node version 18+ is required. Please check node version `node -v` and update it if required.

To get started, you will need to install the dependencies for the project. To do so, run:

    yarn

Then, you will need to switch directories into `langchain-core` and build core by running:

    cd ../langchain-coreyarnyarn build

### Linting[​](#linting "Direct link to Linting")

We use [eslint](https://eslint.org/) to enforce standard lint rules. To run the linter, run:

    yarn lint

### Formatting[​](#formatting "Direct link to Formatting")

We use [prettier](https://prettier.io) to enforce code formatting style. To run the formatter, run:

    yarn format

To just check for formatting differences, without fixing them, run:

    yarn format:check

### Testing[​](#testing "Direct link to Testing")

In general, tests should be added within a `tests/` folder alongside the modules they are testing.

**Unit tests** cover modular logic that does not require calls to outside APIs.

If you add new logic, please add a unit test. Unit tests should be called `*.test.ts`.

To run only unit tests, run:

    yarn test

#### Running a single test[​](#running-a-single-test "Direct link to Running a single test")

To run a single test, run the following from within a workspace:

    yarn test:single /path/to/yourtest.test.ts

This is useful for developing individual features.

**Integration tests** cover logic that requires making calls to outside APIs (often integration with other services).

If you add support for a new external API, please add a new integration test. Integration tests should be called `*.int.test.ts`.

Note that most integration tests require credentials or other setup. You will likely need to set up a `langchain/.env` or `libs/langchain-community/.env` file like the example [here](https://github.com/langchain-ai/langchainjs/blob/main/langchain/.env.example).

We generally recommend only running integration tests with `yarn test:single`, but if you want to run all integration tests, run:

    yarn test:integration

### Building[​](#building "Direct link to Building")

To build the project, run:

    yarn build

### Adding an Entrypoint[​](#adding-an-entrypoint "Direct link to Adding an Entrypoint")

LangChain exposes multiple subpaths the user can import from, e.g.

    import { OpenAI } from "langchain/llms/openai";

We call these subpaths "entrypoints". In general, you should create a new entrypoint if you are adding a new integration with a 3rd party library. If you're adding self-contained functionality without any external dependencies, you can add it to an existing entrypoint.

In order to declare a new entrypoint that users can import from, you should edit the `langchain/langchain.config.js` or `libs/langchain-community/langchain.config.js` file. To add an entrypoint `tools` that imports from `tools/index.ts` you'd add the following to the `entrypoints` key inside the `config` variable:

    // ...entrypoints: {  // ...  tools: "tools/index",},// ...

If you're adding a new integration which requires installing a third party dependency, you must add the entrypoint to the `requiresOptionalDependency` array, also located inside `langchain/langchain.config.js` or `libs/langchain-community/langchain.config.js`.

    // ...requiresOptionalDependency: [  // ...  "tools/index",],// ...

This will make sure the entrypoint is included in the published package, and in generated documentation.

Documentation[​](#documentation "Direct link to Documentation")
---------------------------------------------------------------

### Contribute Documentation[​](#contribute-documentation "Direct link to Contribute Documentation")

#### Install dependencies[​](#install-dependencies "Direct link to Install dependencies")

##### Note: you only need to follow these steps if you are building the docs site locally.[​](#note-you-only-need-to-follow-these-steps-if-you-are-building-the-docs-site-locally "Direct link to Note: you only need to follow these steps if you are building the docs site locally.")

1.  [Quarto](https://quarto.org/) - package that converts Jupyter notebooks (`.ipynb` files) into `.mdx` files for serving in Docusaurus.
2.  `yarn build --filter=core_docs` - It's as simple as that! (or you can simply run `yarn build` from `docs/core_docs/`)

All notebooks are converted to `.md` files and automatically gitignored. If you would like to create a non notebook doc, it must be a `.mdx` file.

### Writing Notebooks[​](#writing-notebooks "Direct link to Writing Notebooks")

When adding new dependencies inside the notebook you must update the import map inside `deno.json` in the root of the LangChain repo.

This is required because the notebooks use the Deno runtime, and Deno formats imports differently than Node.js.

Example:

    // Import in Node:import { z } from "zod";// Import in Deno:import { z } from "npm:/zod";

See examples inside `deno.json` for more details.

Docs are largely autogenerated by [TypeDoc](https://typedoc.org/) from the code.

For that reason, we ask that you add good documentation to all classes and methods.

Similar to linting, we recognize documentation can be annoying. If you do not want to do it, please contact a project maintainer, and they can help you with it. We do not want this to be a blocker for good code getting contributed.

Documentation and the skeleton lives under the `docs/` folder. Example code is imported from under the `examples/` folder.

### Running examples[​](#running-examples "Direct link to Running examples")

If you add a new major piece of functionality, it is helpful to add an example to showcase how to use it. Most of our users find examples to be the most helpful kind of documentation.

Examples can be added in the `examples/src` directory, e.g. `examples/src/path/to/example`. This example can then be invoked with `yarn example path/to/example` at the top level of the repo.

To run examples that require an environment variable, you'll need to add a `.env` file under `examples/.env`.

### Build Documentation Locally[​](#build-documentation-locally "Direct link to Build Documentation Locally")

To generate and view the documentation locally, change to the project root and run `yarn` to ensure dependencies get installed in both the `docs/` and `examples/` workspaces:

    cd ..yarn

Then run:

    yarn docs

Advanced[​](#advanced "Direct link to Advanced")
------------------------------------------------

**Environment tests** test whether LangChain works across different JS environments, including Node.js (both ESM and CJS), Edge environments (eg. Cloudflare Workers), and browsers (using Webpack).

To run the environment tests with Docker, run the following command from the project root:

    yarn test:exports:docker

* * *

#### Was this page helpful?

  

#### You can leave detailed feedback [on GitHub](https://github.com/langchain-ai/langchainjs/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CPlease+write+a+comprehensive+title+after+the+%27DOC%3A+%27+prefix%3E).

[

Previous

Repository Structure

](/v0.2/docs/contributing/repo_structure)[

Next

Testing

](/v0.2/docs/contributing/testing)

*   [🚀 Quick Start](#-quick-start)
    *   [🏭 Release process](#-release-process)
    *   [🛠️ Tooling](#️-tooling)
*   [🚀 Quick Start](#-quick-start-1)
*   [✅ Common Tasks](#-common-tasks)
    *   [Setup](#setup)
    *   [Linting](#linting)
    *   [Formatting](#formatting)
    *   [Testing](#testing)
    *   [Building](#building)
    *   [Adding an Entrypoint](#adding-an-entrypoint)
*   [Documentation](#documentation)
    *   [Contribute Documentation](#contribute-documentation)
    *   [Writing Notebooks](#writing-notebooks)
    *   [Running examples](#running-examples)
    *   [Build Documentation Locally](#build-documentation-locally)
*   [Advanced](#advanced)

Community

*   [Discord](https://discord.gg/cU2adEyC7w)
*   [Twitter](https://twitter.com/LangChainAI)

GitHub

*   [Python](https://github.com/langchain-ai/langchain)
*   [JS/TS](https://github.com/langchain-ai/langchainjs)

More

*   [Homepage](https://langchain.com)
*   [Blog](https://blog.langchain.dev)

Copyright © 2024 LangChain, Inc.