Skip to main content

A visual tracer and debugger for LangChain and LangGraph

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langlens-0.1.1.tar.gz (280.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langlens-0.1.1-py3-none-any.whl (285.2 kB view details)

Uploaded Python 3

File details

Details for the file langlens-0.1.1.tar.gz.

File metadata

  • Download URL: langlens-0.1.1.tar.gz
  • Upload date:
  • Size: 280.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for langlens-0.1.1.tar.gz
Algorithm Hash digest
SHA256 53135b32d2cd108d3ced59632a206fcc5d346e160bb092b1666815415ff7d4d1
MD5 7c84e47ad07b1ae2297f84909828b53a
BLAKE2b-256 0543815fdf3222dc3ef9da18eb8d4c4b7735b4ada7a889279cab0f608690f17c

See more details on using hashes here.

File details

Details for the file langlens-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: langlens-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 285.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for langlens-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cca384381090d32e56578a93bce36802a161db78453c016793b419b02f34888a
MD5 596e6d718d5911388f615db382e973f2
BLAKE2b-256 e137f235fc3a9d42d56b1392372f30c7876253d1b3b16e849a159189d266fa8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page