Skip to main content

LangLens Logo

LangLens

Node-Level Observability for LangChain and LangGraph.

LangLens is a lightweight visual tracer and debugger designed specifically for LLM-powered applications. It captures detailed execution logs from your agents and chains, allowing you to inspect every LLM call, tool execution, and state transition with precision.

LangLens Screenshot


✨ Features

  • 🔍 Interactive Trace Viewer: Explore complex workflows through a rich graphical interface.
  • 🧩 Node-Level Granularity: Deep dive into individual chain runs, LLM inputs/outputs, and tool executions.
  • 💻 VS Code Extension: Debug your traces directly inside VS Code with a custom editor experience.
  • 🚀 CLI Tool: Quickly host a local viewer for any .langlens file.
  • 🔌 Seamless Integration: Add observability to your existing projects with a single line of code.

🏗️ How it Works

LangLens bridges the gap between your LLM execution and visual debugging:

graph TD
    subgraph "Capture Phase"
    A[LLM App] -- "1. LangChain Callbacks" --> B(LangLens Handler)
    B -- "2. Stream Events" --> C[[.langlens file]]
    end

    subgraph "Visualization Phase"
    C -- "3a. CLI Server" --> D[Web Browser]
    C -- "3b. Custom Editor" --> E[VS Code IDE]

    D --> F{Interactive UI}
    E --> F

    F -- "4. Inspect Nodes" --> G[Observability & Debugging]
    end
  1. Capture: The LangLensCallbackHandler hooks into LangChain's event system to record starts, ends, and errors of every chain, tool, and LLM call.
  2. Storage: Events are serialized and saved into a .langlens file (JSONL format), providing a portable trace of the entire execution.
  3. Visualization:
    • The CLI Tool launches a local Python server that hosts a Svelte-based frontend.
    • The VS Code Extension registers as a custom editor for .langlens files, embedding the same Svelte UI directly into your workspace.
  4. Debugging: Use the interactive graph to navigate complex agentic workflows and inspect raw inputs/outputs at any level of the tree.

📦 Installation

Python Package

Install LangLens via pip:

pip install langlens

VS Code Extension

Install the LangLens Viewer from the VS Code Marketplace.

🚀 Quick Start

1. Integrate the Callback

Add the LangLensCallbackHandler to your LangChain or LangGraph execution config.

from langlens import LangLensCallbackHandler
from langchain_openai import ChatOpenAI

# Initialize the handler (creates a logs.langlens file)
handler = LangLensCallbackHandler(filename="logs.langlens")

# Attach it to your run
llm = ChatOpenAI()
config = {"callbacks": [handler]}
response = llm.invoke("How does a sunrise look from Mars?", config=config)

2. Visualize the Trace

Option A: Using the CLI

Run the following command to start a local server and open the viewer in your browser:

langlens visualize logs.langlens

Option B: Using VS Code

Simply open any .langlens file. The LangLens Viewer will automatically render the interactive trace.

🛠️ Development

Local Setup

  1. Build the Web UI: This bundles the Svelte app and copies assets to the Python and VS Code extension folders.

    ./build_ui.sh
    
  2. Install Python Package (Editable mode):

    pip install -e .
    
  3. VS Code Extension:

    • Open the vscode-extension folder in VS Code.
    • Run pnpm install.
    • Press F5 to start the Extension Development Host.

Packaging

To build distribution packages manually:

./scripts/package.sh

📄 License

This project is licensed under the MIT License.

Release files for langlens 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langlens 0.1.2
File Size Uploaded
langlens-0.1.2.tar.gz 280.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langlens 0.1.2
File Interpreter ABI Platform
langlens-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 565.5 kB

Release files / langlens-0.1.2.tar.gz

Download URL langlens-0.1.2.tar.gz
Size 280.3 kB
Tags Source
SHA-256 checksum
How to use checksums
341692b2e38ea8025f3891cb11d1d3dacc47bb5335a1a18703a12370f25fef93
BLAKE2b-256 checksum
How to use checksums
d546dffb633b52642c5eead2d0848697e7984f106f1a6bfbcbae6f8888b53186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / langlens-0.1.2-py3-none-any.whl

Download URL langlens-0.1.2-py3-none-any.whl
Size 285.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8fdee4c1001a3c428451e58afe58144b0e01fdb1673b6f9da7714bc9950f050
BLAKE2b-256 checksum
How to use checksums
716503c097f55fa9cd78122992af383e6ec4df8851fd458e2082820df0664fba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page