Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Truera Trulens LangChain LangGraph Environment

From Leeroopedia
Knowledge Sources
Domains Infrastructure, LLM_Frameworks
Last Updated 2026-02-14 08:00 GMT

Overview

Python 3.9+ environment with LangChain >= 1.0.0, LangGraph >= 0.4.4, and Pydantic 2 for instrumenting LangChain Runnables and LangGraph compiled agents.

Description

This environment provides the framework integration layer for wrapping LangChain Runnables (via `TruChain`) and LangGraph compiled state graphs (via `TruGraph`). `TruGraph` inherits from `TruChain` and combines both instrumentation systems via a `CombinedInstrument` class. LangChain 1.x is required; the codebase has migrated from the pre-1.0 API. Pydantic 2 is mandatory due to LangChain 1.x requirements.

Usage

Use this environment for the RAG Evaluation with LangChain and LangGraph Agent Evaluation workflows. Required whenever using `TruChain` or `TruGraph` to record and evaluate LangChain/LangGraph applications.

System Requirements

Category Requirement Notes
OS Any (OS Independent) Linux, macOS, Windows all supported
Python >= 3.9 Same as trulens-core
Network Internet access Required for LLM API calls within chains

Dependencies

LangChain App (TruChain)

  • `trulens-core` >= 2.0.0
  • `langchain` >= 1.0.0
  • `langchain-core` >= 1.0.0
  • `langchain-community` >= 0.3.0
  • `pydantic` >= 2.4.2

LangGraph App (TruGraph)

All of the above, plus:

  • `langgraph` >= 0.4.4
  • `opentelemetry-api` >= 1.23.0
  • `opentelemetry-sdk` >= 1.23.0
  • `opentelemetry-proto` >= 1.23.0

Credentials

No additional credentials beyond what the underlying LLM provider requires (e.g., `OPENAI_API_KEY` for OpenAI-backed chains).

Quick Install

# Install LangChain integration
pip install trulens-apps-langchain>=2.6.0

# Install LangGraph integration (includes LangChain dependencies)
pip install trulens-apps-langgraph>=2.6.0

Code Evidence

LangChain version constraint from `src/apps/langchain/pyproject.toml:36-39`:

langchain = ">=1.0.0"
langchain-core = ">=1.0.0"
langchain-community = ">=0.3.0"
pydantic = "^2.4.2"

LangGraph version constraint from `src/apps/langgraph/pyproject.toml:39`:

langgraph = ">=0.4.4"

Multiple ImportError handling in `src/apps/langchain/trulens/apps/langchain/tru_chain.py:119-230`:

# Multiple try/except ImportError blocks for optional LangChain components
# Lines 119, 126, 153, 219, 230

Common Errors

Error Message Cause Solution
`ImportError: langchain` LangChain not installed `pip install trulens-apps-langchain`
`ModuleNotFoundError: langgraph` LangGraph not installed `pip install trulens-apps-langgraph`
Pydantic v1 compatibility error LangChain 1.x requires Pydantic 2 Upgrade pydantic: `pip install pydantic>=2.4.2`

Compatibility Notes

  • LangChain < 1.0.0: Not supported. See `LANGCHAIN_1X_MIGRATION.md` for migration guidance from pre-1.0 APIs.
  • TruGraph inheritance: `TruGraph` inherits from `TruChain`, not directly from `App`. This means LangChain must be installed even when only using LangGraph.
  • Async streaming: Async streaming instrumentation for TruGraph has known issues and is disabled (see `tru_graph.py:1542`).

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment