Skip to main content

Library to systematically track and evaluate LangGraph based applications.

Project description

trulens-apps-langgraph

TruLens integration for LangGraph applications. This package provides comprehensive instrumentation and evaluation capabilities for LangGraph-based multi-agent workflows.

Features

  • Automatic Detection: TruGraph automatically detects LangGraph applications
  • Combined Instrumentation: Inherits all LangChain instrumentation plus LangGraph-specific methods
  • Multi-Agent Evaluation: Comprehensive evaluation capabilities for complex workflows
  • Automatic @task Instrumentation: Automatically detects and instruments functions decorated with @task
  • Smart Attribute Extraction: Intelligently extracts information from function arguments

Installation

pip install trulens-apps-langgraph

Quick Start

from langgraph.graph import StateGraph, MessagesState, END
from langchain_core.messages import HumanMessage
from trulens.apps.langgraph import TruGraph

# Create your LangGraph application
workflow = StateGraph(MessagesState)
workflow.add_node("agent", your_agent_function)
workflow.add_edge("agent", END)
workflow.set_entry_point("agent")
graph = workflow.compile()

# Automatically instrument with TruGraph
tru_app = TruGraph(graph, app_name="MyLangGraphApp")

# Use normally - all interactions are automatically logged
with tru_app as recording:
    result = graph.invoke({"messages": [HumanMessage(content="Hello!")]})

Automatic @task Instrumentation

TruGraph automatically instruments functions decorated with LangGraph's @task decorator by monkey-patching the decorator itself. This follows TruLens instrumentation patterns and ensures seamless integration:

from langgraph.func import task

@task  # Automatically instrumented by TruGraph when TruGraph is imported
def my_agent_function(state, config):
    # Your agent logic here
    return updated_state

How it works:

  1. Decorator Monkey-Patching: TruGraph patches the @task decorator at import time
  2. Intelligent Attribute Extraction: Automatically extracts information from function arguments:
    • Handles BaseChatModel and BaseModel objects
    • Extracts data from dataclasses and Pydantic models
    • Skips non-serializable objects like LLM pools
    • Captures return values and exceptions
  3. No Code Changes Required: Works with existing @task decorated functions

This approach follows TruLens conventions and is more robust than scanning sys.modules.

Usage

See the TruLens documentation for complete usage instructions.

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

trulens_apps_langgraph-1.5.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

trulens_apps_langgraph-1.5.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file trulens_apps_langgraph-1.5.2.tar.gz.

File metadata

  • Download URL: trulens_apps_langgraph-1.5.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.9

File hashes

Hashes for trulens_apps_langgraph-1.5.2.tar.gz
Algorithm Hash digest
SHA256 79ea8662673bf6a28c4b7451bc3fef6fc467d245b67328d68c89544a64d7f4da
MD5 700f3257514c3ccdf1e5a122821598bb
BLAKE2b-256 f8e5acc805bc460eab19298f2b0ce581e1d447b7f6fa7dbf0d2e19caf4efe8e1

See more details on using hashes here.

File details

Details for the file trulens_apps_langgraph-1.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for trulens_apps_langgraph-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e9d5df4e7cb72e0edce741cca00754c9ebc9f8d140c67f4ad82a74276b6c680
MD5 1e73cd5ed155466f1c4bf5ad387bf86e
BLAKE2b-256 39a0ea7838d468f87ec9d234861afbb3fd8ffad380e1f706a0560bf03d9bf7ae

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