Registry / ai-ml / trulens

trulens

JSON →
library2.8.1pypypi✓ verified 85d ago

TruLens is an open-source library for evaluating and tracking LLM applications. It provides feedback functions, telemetry, and a dashboard for monitoring performance. Version 2.8.1 supports Python >=3.10, <4.0, with active development on GitHub.

pip install trulens
INSTALL
IMPORT
SIG · TRULENS
T
trulens
ai-mlpythonv2.8.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Tru
from trulens.core import Tru
from trulens import Tru
In v2.x, Tru moved to trulens.core
Feedback
from trulens.core import Feedback
from trulens import Feedback
Feedback also moved to trulens.core
Select
from trulens.core import Select
from trulens import Select
Select moved to trulens.core

Initialize TruLens, create a feedback function with OpenAI, wrap a custom app, run it, and view leaderboard.

import os from trulens.core import Tru, Feedback from trulens.providers.openai import OpenAI tru = Tru() provider = OpenAI(api_key=os.environ.get('OPENAI_API_KEY', '')) # Define a feedback function feedback = Feedback(provider.relevance).on_input_output() # Wrap an app (example using a dummy function) from trulens.apps.custom import TruCustom def my_app(input: str) -> str: return f"Response to: {input}" tru_app = TruCustom(my_app, app_name='MyApp', feedbacks=[feedback]) # Run the app with tru_app as recording: recording.record(my_app, "Hello, world!") # Check results tru.get_leaderboard()
Debug
Known issues
breakingTruLens v2.x introduced a major restructuring. Core classes like Tru, Feedback, Select moved to 'trulens.core'. The old import 'from trulens import Tru' no longer works.
fix
Use 'from trulens.core import Tru'. Update all imports to point to trulens.core or trulens.providers.
affects: >=2.0.0
breakingThe dashboard API changed in v2.3.0. The Tru.run_dashboard() method now requires a port argument and may have different defaults.
fix
Call Tru.run_dashboard(port=8501) explicitly. Check the v2 migration guide.
affects: >=2.3.0
gotchaFeedback functions must be defined before wrapping the app. If you add feedbacks after TruCustom initialization, they will not be applied.
fix
Pass all feedbacks to TruCustom at construction or use the 'add_feedback' method before calling record.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'trulens'
TruLens not installed or installed in wrong environment.
fix
Run 'pip install trulens' and ensure you are using Python >=3.10.
AttributeError: module 'trulens' has no attribute 'Tru'
Using old import path; in v2.x, Tru is in trulens.core.
fix
Change import to 'from trulens.core import Tru'.
ValueError: Feedback function 'relevance' has no provider
Feedback function requires a provider (e.g., OpenAI) to be instantiated.
fix
Instantiate a provider: 'provider = OpenAI(api_key=...)' and pass it to Feedback constructor.
Upgrade
Version history
2.8.1latest on PyPI · released May 14, 2026
Audit
Dependencies
openaioptionalOptional provider for LLM feedback functions
langchainoptionalOptional integration with LangChain
llama-indexoptionalOptional integration with LlamaIndex
Agent activity
51 hits · last 30 days
node
46
Resources
trulens — pip install trulens · libregistry