CLI for interacting with LangChain templates and applications
—
Create LangChain integration packages with automated scaffolding, template processing, and documentation generation for various component types. This namespace provides tools for building LangChain integrations with external services and libraries.
Creates a new integration package with standardized structure, template processing, and development dependencies.
langchain integration new [options]
Options:
--name TEXT The name of the integration to create (required, prompt if not provided)
--name-class TEXT The PascalCase name for classes (e.g. MyIntegration)
--src TEXT Template file to copy (can be repeated)
--dst TEXT Destination path for template file (can be repeated)Usage Examples:
# Create full integration package interactively
langchain integration new --name my-integration
# Create with specific class name
langchain integration new --name my-integration --name-class MyCustomIntegration
# Copy specific template files
langchain integration new --name my-integration --src chat_models.py --dst my_integration/chat_models.py
# Copy multiple template files
langchain integration new --name my-integration \
--src chat_models.py --dst my_integration/chat.py \
--src embeddings.py --dst my_integration/embeddings.pyName Processing:
Integration names are automatically processed:
my-custom-integrationlangchain-my-custom-integrationlangchain_my_custom_integrationMyCustomIntegrationGenerate integration documentation using pre-built templates for different component types.
langchain integration create-doc [options]
Options:
--name TEXT Kebab-case integration name (required, prompt if not provided)
--name-class TEXT PascalCase integration name
--component-type TEXT Component type (default: ChatModel)
--destination-dir TEXT Relative path to docs directory (required, prompt if not provided)Supported Component Types:
ChatModel: Chat model implementationsDocumentLoader: Document loading utilitiesTool: LangChain toolsVectorStore: Vector storage implementationsEmbeddings: Text embedding modelsByteStore: Key-value storageLLM: Language model implementationsProvider: Service provider integrationsToolkit: Tool collectionsRetriever: Document retrieval systemsUsage Examples:
# Create chat model documentation
langchain integration create-doc --name openai --component-type ChatModel --destination-dir docs/docs/integrations/chat/
# Create vector store documentation
langchain integration create-doc --name pinecone --component-type VectorStore --destination-dir docs/docs/integrations/vectorstores/
# Create documentation with custom class name
langchain integration create-doc --name vertex-ai --name-class VertexAI --component-type ChatModel --destination-dir docs/docs/integrations/chat/def new(
name: str,
name_class: Optional[str] = None,
src: Optional[list[str]] = None,
dst: Optional[list[str]] = None,
) -> None:
"""Create a new integration package."""
def create_doc(
name: str,
name_class: Optional[str] = None,
component_type: str = "ChatModel",
destination_dir: str = "docs/docs/integrations/chat/",
) -> None:
"""Create a new integration doc."""
def _process_name(name: str, *, community: bool = False) -> Replacements:
"""
Process integration name into various template replacement formats.
Args:
name: Raw integration name
community: Whether this is a community integration
Returns:
Replacements dictionary with processed name variants
Raises:
ValueError: If name doesn't match required pattern
"""class Replacements(TypedDict):
"""Template replacement mappings."""
__package_name__: str
__module_name__: str
__ModuleName__: str
__MODULE_NAME__: str
__package_name_short__: str
__package_name_short_snake__: str
TEMPLATE_MAP: dict[str, str] = {
"ChatModel": "chat.ipynb",
"DocumentLoader": "document_loaders.ipynb",
"Tool": "tools.ipynb",
"VectorStore": "vectorstores.ipynb",
"Embeddings": "text_embedding.ipynb",
"ByteStore": "kv_store.ipynb",
"LLM": "llms.ipynb",
"Provider": "provider.ipynb",
"Toolkit": "toolkits.ipynb",
"Retriever": "retrievers.ipynb",
}Full integration packages have the following structure:
langchain-my-integration/
├── pyproject.toml # Package configuration
├── README.md # Package documentation
├── langchain_my_integration/ # Main package
│ ├── __init__.py # Package exports
│ ├── chat_models.py # Chat model implementations
│ ├── embeddings.py # Embedding implementations
│ ├── vectorstores.py # Vector store implementations
│ └── ... # Other component types
├── tests/ # Test suite
│ ├── integration_tests/ # Integration tests
│ └── unit_tests/ # Unit tests
└── docs/ # DocumentationThe integration template system includes:
chat_models.py - Chat completion interfacesembeddings.py - Text embedding modelsvectorstores.py - Vector database integrationsdocument_loaders.py - Document ingestiontools.py - LangChain tool implementationstoolkits.py - Tool collectionsretrievers.py - Document retrieval systemsTemplates use these replacement variables:
__package_name__: Full package name (e.g., langchain-my-integration)__module_name__: Python module name (e.g., langchain_my_integration)__ModuleName__: PascalCase class prefix (e.g., MyIntegration)__MODULE_NAME__: Uppercase constant prefix (e.g., MY_INTEGRATION)__package_name_short__: Short name (e.g., my-integration)__package_name_short_snake__: Snake case short name (e.g., my_integration)Template processing includes:
Integration packages include comprehensive development tooling:
[dependency-groups]
dev = ["pytest", "pytest-watcher"]
lint = ["ruff", "mypy"]
test = ["langchain-core", "langchain"]
typing = ["langchain"]
test_integration = []Integration names must follow strict patterns:
langchain- prefix handlingClass names must follow Python conventions:
The system validates:
Follow LangChain patterns for each component type:
from langchain_core.chat_models import BaseChatModel
class MyIntegrationChatModel(BaseChatModel):
"""Chat model implementation."""
# Implementation detailsUse Pydantic for configuration:
from pydantic import BaseModel, Field
class MyIntegrationConfig(BaseModel):
api_key: str = Field(..., description="API key for service")
base_url: str = Field(default="https://api.example.com")Implement comprehensive error handling:
from langchain_core.exceptions import LangChainException
class MyIntegrationError(LangChainException):
"""Integration-specific errors."""Include both unit and integration tests:
Install with Tessl CLI
npx tessl i tessl/pypi-langchain-cli