or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

app-management.mdcode-migration.mdindex.mdintegration-development.mdtemplate-development.mdutilities.md
tile.json

tessl/pypi-langchain-cli

CLI for interacting with LangChain templates and applications

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/langchain-cli@0.0.x

To install, run

npx @tessl/cli install tessl/pypi-langchain-cli@0.0.0

index.mddocs/

LangChain CLI

A command-line interface for interacting with LangChain templates and applications. The CLI enables developers to create, manage, and serve LangChain applications through simple commands, supporting template management, project scaffolding, and application deployment in the LangChain ecosystem.

Package Information

  • Package Name: langchain-cli
  • Package Type: pypi
  • Language: Python
  • Installation: pip install langchain-cli

Core Imports

Import the CLI programmatically (though primarily used as CLI tool):

from langchain_cli.cli import app
from langchain_cli import __version__

Basic Usage

Command Line Interface

The primary interface is through command-line commands:

# Create a new LangServe application
langchain app new my-app

# Add a template to your app
langchain app add my-template

# Serve your application locally
langchain app serve --port 8000 --host 0.0.0.0

# Create a new template package
langchain template new my-template

# Create integration packages
langchain integration new my-integration

# Migrate LangChain code to newer versions
langchain migrate --diff

# Serve application (auto-detects template vs app)
langchain serve --port 8000 --host 0.0.0.0

Programmatic Usage

While primarily a CLI tool, some components can be used programmatically:

from langchain_cli.utils.packages import get_package_root, get_langserve_export
from langchain_cli.utils.git import parse_dependencies
from langchain_cli import __version__

# Get version information
print(__version__)

# Find package root directory
project_root = get_package_root()

# Parse dependency specifications
deps = parse_dependencies(["template-name"], [], [], [])

Architecture

The CLI is built using Typer and organized into functional namespaces:

  • Main CLI: Entry point with global commands and namespace routing
  • App Namespace: LangServe application lifecycle management
  • Template Namespace: Template development and serving
  • Integration Namespace: LangChain integration package creation
  • Migration Namespace: Code migration utilities using Grit
  • Utilities: Shared functionality for git operations, package management, and file processing

Capabilities

Application Management

Create, manage, and serve LangServe applications with template integration, dependency management, and local development server functionality.

# CLI Commands (app namespace)
# langchain app new [name] [options]
# langchain app add [dependencies] [options]
# langchain app remove [api_paths] [options]
# langchain app serve [options]

Application Management

Template Development

Create and develop installable LangChain template packages with scaffolding, development server, and template discovery capabilities.

# CLI Commands (template namespace)  
# langchain template new [name] [options]
# langchain template serve [options]
# langchain template list [contains]

Template Development

Integration Development

Create LangChain integration packages with automated scaffolding, template processing, and documentation generation for various component types.

# CLI Commands (integration namespace)
# langchain integration new [options]
# langchain integration create-doc [options]

Integration Development

Code Migration

Migrate LangChain code to newer versions using Grit pattern matching with interactive and diff modes for safe code transformation.

# CLI Commands (migrate)
# langchain migrate [grit-args] [options]

Code Migration

Application Serving

Auto-detect and serve LangServe applications or templates with smart detection of project type and configuration.

# CLI Commands (root level)
# langchain serve [options]

This root-level serve command automatically detects whether the current directory contains a LangServe application or template and serves accordingly, providing a unified interface for development servers.

Utility Functions

Core utility functions for package management, git operations, project configuration, and event tracking used throughout the CLI.

def get_package_root(cwd: Optional[Path] = None) -> Path: ...
def get_langserve_export(filepath: Path) -> LangServeExport: ...
def parse_dependencies(dependencies: Optional[list[str]], repo: list[str], branch: list[str], api_path: list[str]) -> list[DependencySource]: ...
def update_repo(gitstring: str, ref: Optional[str], repo_dir: Path) -> Path: ...

Utility Functions

Types

class LangServeExport(TypedDict):
    """Fields from pyproject.toml relevant to LangServe."""
    module: str
    attr: str  
    package_name: str

class DependencySource(TypedDict):
    """Dependency source information."""
    git: str
    ref: Optional[str]
    subdirectory: Optional[str]
    api_path: Optional[str]
    event_metadata: dict[str, Any]

class EventDict(TypedDict):
    """Event data structure for analytics tracking."""
    event: str
    properties: Optional[dict[str, Any]]