langchain-ai/langchain
Getting started
This page walks through cloning the monorepo, installing dependencies, and running tests, lint, and type checks. The instructions follow the conventions in CLAUDE.md / AGENTS.md at the repository root.
Prerequisites
- Python 3.10–3.14 — every package's
pyproject.tomldeclaresrequires-python = ">=3.10.0,<4.0.0". uv— the project usesuvfor dependency resolution and editable installs. Install withpipx install uvorcurl -LsSf https://astral.sh/uv/install.sh | sh.make— most package directories have aMakefileexposingmake test,make lint,make format.git— for cloning and the editable workspace links between packages.
Clone
git clone https://github.com/langchain-ai/langchain.git
cd langchainSome integration packages live in sibling repositories (for example langchain-google, langchain-aws). If you plan to develop against them, clone them next to langchain/ so the [tool.uv.sources] paths in pyproject.toml (which point one level up, e.g. ../langchain-google/) resolve correctly.
Install a single package
Each package under libs/ is independently versioned and ships its own uv.lock. To work on one package, cd into it and run uv sync:
cd libs/core
uv sync --all-groups # install every dependency group
uv sync --group test # or just one groupThe most useful groups (defined in each pyproject.toml):
| Group | Purpose |
|---|---|
test |
Unit tests, no network |
test_integration |
Integration tests that hit real APIs |
lint |
ruff |
typing |
mypy and stub packages |
dev |
Extras like jupyter (only in some packages) |
[tool.uv.sources] in each pyproject.toml points at sibling packages with editable = true, so changes in libs/core/ are immediately visible to libs/langchain_v1/ without reinstalling.
Run tests
# From any libs/<package>/ directory
make test # unit tests, no network
make test_watch # runs pytest-watcher
make integration_test # integration tests (some require API keys)
make benchmark # the few packages that ship pytest-benchmarkOr invoke pytest directly:
uv run --group test pytest tests/unit_tests/test_specific.py
uv run --group test pytest tests/unit_tests -k "tool_calling"Lint and format
make lint # ruff check + format check + mypy (varies per package)
make format # ruff format + ruff check --fixThe repo's ruff config selects ALL rules with a small ignore list (see any pyproject.toml's [tool.ruff.lint]). Imports are absolute everywhere — ban-relative-imports = "all" is enabled.
Type-check
uv run --group lint mypy .
# or, when the package's Makefile defines it:
make lint_package # runs mypy with the package-specific overrideslangchain-core and langchain both use mypy in strict = true mode with enable_error_code = "deprecated". Some test directories opt out (see [tool.mypy.overrides] and [tool.ruff.lint.extend-per-file-ignores]).
Run the whole workspace
There is no top-level Makefile — tests, lint, and builds always run inside a single package directory. The .github/workflows/check_diffs.yml workflow handles which packages to test in CI based on the changed file paths, using _test.yml, _lint.yml, and the other reusable workflows.
To exercise everything locally before opening a PR:
for pkg in libs/core libs/langchain_v1 libs/langchain libs/text-splitters libs/standard-tests libs/model-profiles libs/partners/*/; do
echo "=== $pkg ==="
(cd "$pkg" && uv sync --all-groups && make lint && make test)
doneThis is what CI effectively does, package by package.
Build a wheel
cd libs/<package>
uv build # creates dist/*.whl and dist/*.tar.gz via hatchlinghatchling is the build backend for every package in the workspace.
Common tasks
Refresh model capability data
The langchain-profiles CLI in libs/model-profiles/langchain_model_profiles/cli.py pulls model metadata from models.dev and writes it into a partner's data/ directory. See packages/model-profiles and the example invocations in CLAUDE.md.
Add a new partner integration
When adding a new partner under libs/partners/, several auxiliary files need updates — .github/dependabot.yml, .github/scripts/pr-labeler-config.json, .github/workflows/_release.yml, auto-label-by-package.yml, check_diffs.yml, integration_tests.yml, pr_lint.yml. The full list lives in CLAUDE.md under "Adding a new partner to CI".
Documentation
- Conceptual docs and tutorials: https://docs.langchain.com/oss/python/langchain/overview
- API reference: https://reference.langchain.com/python/
- Source for the docs site:
langchain-ai/docs(separate repository, sometimes cloned at../docs/) - Contributing guide: https://docs.langchain.com/oss/python/contributing/overview
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.