Upgrade to TruLens v1.x

Python pattern

This pattern upgrades code to TruLens v1.x by replacing deprecated imports and class usage.


Apply with the Grit CLI
grit apply trulens_eval_migration

Migrate and use TruSession

BEFORE
from trulens_eval import Tru
tru = Tru(database_url)
tru.reset_database()
AFTER
from trulens.core.session import TruSession
from trulens.core.database.connector.default import DefaultDBConnector
connector = DefaultDBConnector(database_url)
tru = TruSession(connector=connector)
tru.reset_database()

Updates to Dashboard

BEFORE
from trulens_eval import Tru
tru = Tru()
tru.run_dashboard()
AFTER
from trulens.core.session import TruSession
from trulens.core.database.connector.default import DefaultDBConnector
connector = DefaultDBConnector()
tru = TruSession(connector=connector)
from trulens.dashboard import run_dashboard
run_dashboard(session=tru, )

Updates to Dashboard with port

BEFORE
from trulens_eval import Tru
tru = Tru()
tru.run_dashboard(port=888)
AFTER
from trulens.core.session import TruSession
from trulens.core.database.connector.default import DefaultDBConnector
connector = DefaultDBConnector()
tru = TruSession(connector=connector)
from trulens.dashboard import run_dashboard
run_dashboard(session=tru, port=888)

Migrations to TruLens Core

BEFORE
from trulens_eval import Select
from trulens_eval import Feedback
from trulens_eval.guardrails.base import context_filter
AFTER
from trulens.core.schema import Select
from trulens.core.feedback.feedback import Feedback
from trulens.core.guardrails.base import context_filter

Migrations to TruLens Apps

BEFORE
from trulens_eval import TruCustomApp
from trulens_eval import TruBasicApp
AFTER
from trulens.apps.custom import TruCustomApp
from trulens.apps.basic import TruBasicApp

Updates to working with Langchain

BEFORE
from trulens_eval import TruChain
from trulens_eval.guardrails.langchain import WithFeedbackFilterDocuments
AFTER
from trulens.apps.langchain.tru_chain import TruChain
from trulens.apps.langchain.guardrails import WithFeedbackFilterDocuments

Updates to working with Llama-Index

BEFORE
from trulens_eval import TruLlama
from trulens_eval.guardrails.llama import WithFeedbackFilterNodes
AFTER
from trulens.apps.llamaindex.tru_llama import TruLlama
from trulens.apps.llamaindex.guardrails import WithFeedbackFilterNodes

Updates to working with NeMo Guardrails

BEFORE
from trulens_eval import TruRails
AFTER
from trulens.apps.nemo.tru_rails import TruRails

Using OpenAI Provider

BEFORE
from trulens_eval import OpenAI
AFTER
from trulens.providers.openai.provider import OpenAI

Using OpenAI Provider with alias

BEFORE
from trulens_eval import OpenAI as ProviderOpenAI
AFTER
from trulens.providers.openai.provider import OpenAI as ProviderOpenAI

Using OpenAI Provider Full Import Path

BEFORE
from trulens_eval.feedback.provider.openai import OpenAI
AFTER
from trulens.providers.openai.provider import OpenAI

Using AzureOpenAI Provider

BEFORE
from trulens_eval import AzureOpenAI
AFTER
from trulens.providers.openai.provider import AzureOpenAI

Using AzureOpenAI Provider Full Import Path

BEFORE
from trulens_eval.feedback.provider.openai import AzureOpenAI
AFTER
from trulens.providers.openai.provider import AzureOpenAI

Using LiteLLM Provider

BEFORE
from trulens_eval import LiteLLM
AFTER
from trulens.providers.litellm.provider import LiteLLM

Using LiteLLM Provider Full Import Path

BEFORE
from trulens_eval.feedback.provider.litellm import LiteLLM
AFTER
from trulens.providers.litellm.provider import LiteLLM

Using Bedrock Provider

BEFORE
from trulens_eval import Bedrock
AFTER
from trulens.providers.bedrock.provider import Bedrock

Using Bedrock Provider Full Import Path

BEFORE
from trulens_eval.feedback.provider.bedrock import Bedrock
AFTER
from trulens.providers.bedrock.provider import Bedrock

Using Cortex Provider

BEFORE
from trulens_eval import Cortex
AFTER
from trulens.providers.cortex.provider import Cortex

Using Cortex Provider Full Import Path

BEFORE
from trulens_eval.feedback.provider.cortex import Cortex
AFTER
from trulens.providers.cortex.provider import Cortex

Using Langchain Provider

BEFORE
from trulens_eval import Cortex
AFTER
from trulens.providers.cortex.provider import Cortex

Using Langchain Provider Full Import Path

BEFORE
from trulens_eval.feedback.provider.langchain import Langchain
AFTER
from trulens.providers.langchain.provider import Langchain