Implementation:Langchain ai Langchain Partner Directory Layout
Overview
Concrete reference template for a LangChain partner integration package, provided by the langchain-deepseek package at libs/partners/deepseek/.
Description
The libs/partners/deepseek/ directory serves as the canonical reference for how a LangChain partner integration package is laid out. It demonstrates the full set of required directories and files that every partner package must include to function correctly within the monorepo's build, test, lint, and release pipelines.
Required directories:
| Directory / File | Purpose |
|---|---|
langchain_deepseek/ |
Python package containing integration source code |
langchain_deepseek/__init__.py |
Public API surface with __all__ and __version__
|
langchain_deepseek/chat_models.py |
Chat model implementation (ChatDeepSeek)
|
langchain_deepseek/py.typed |
PEP 561 type-checking marker |
langchain_deepseek/data/ |
Static data (model profiles) |
tests/unit_tests/ |
Unit tests (no network access) |
tests/integration_tests/ |
Integration tests (real API calls) |
scripts/ |
Package automation utilities |
Makefile |
Standardized make targets |
pyproject.toml |
Build system, dependencies, tool configuration |
README.md |
Package description and usage |
LICENSE |
MIT license |
uv.lock |
Locked dependency versions |
Usage
Use this layout as a starting template when creating any new partner integration. Copy the directory structure from libs/partners/deepseek/ and replace deepseek with the new integration name throughout.
Code Reference
Source Location: libs/partners/deepseek/ (entire directory)
Directory tree:
libs/partners/deepseek/
LICENSE
Makefile
README.md
pyproject.toml
uv.lock
langchain_deepseek/
__init__.py
chat_models.py
py.typed
data/
_profiles.py
tests/
__init__.py
unit_tests/
__init__.py
test_chat_models.py
integration_tests/
__init__.py
test_chat_models.py
scripts/
check_imports.py
Makefile targets:
# Run unit tests (network disabled)
test tests:
uv run --group test pytest --disable-socket --allow-unix-socket $(TEST_FILE)
# Run integration tests (network enabled)
integration_test integration_tests:
uv run --group test --group test_integration pytest --timeout=30 $(TEST_FILE)
# Lint: ruff check + ruff format --diff + mypy
lint lint_diff lint_package lint_tests:
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES) --diff
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && uv run --all-groups mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
# Format code
format format_diff:
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff format $(PYTHON_FILES)
[ "$(PYTHON_FILES)" = "" ] || uv run --all-groups ruff check --fix $(PYTHON_FILES)
I/O Contract
| Input | Description |
|---|---|
| Directory structure | Must match the canonical layout above |
pyproject.toml |
Must declare langchain-core as a dependency
|
Makefile |
Must provide test, lint, format, integration_tests targets
|
| Output | Description |
|---|---|
| Installable package | pip install langchain-<name> from the built wheel
|
| Passing CI checks | Lint, unit tests, and integration tests all pass |
Usage Examples
Creating a new partner package from the template:
# Copy the deepseek package as a starting point
cp -r libs/partners/deepseek libs/partners/myservice
# Rename the Python package directory
mv libs/partners/myservice/langchain_deepseek libs/partners/myservice/langchain_myservice
# Update all references from "deepseek" to "myservice" in:
# - pyproject.toml (name, description, URLs)
# - __init__.py (imports)
# - chat_models.py (class name, env vars)
# - Makefile (lint_diff --relative path)
# - tests/ (imports, class names)
Running tests in the partner package:
cd libs/partners/deepseek
# Install dependencies
uv sync --group test
# Run unit tests
make test
# Run integration tests (requires DEEPSEEK_API_KEY)
make integration_tests