truera/trulens: TruLens 2.7.0
Authors/Creators
- David Kurokawa
- Josh Reini1
- Piotr Mardziel
- Josh Reini2
- rshih32
- Daniel Huang2
- corey hu3
- Nikhil Vytla
- shayaks
- Piotr Mardziel
- Klas Leino
- Garett Tok Ern Liang
- corey hu4
- Daniel
- Garett Tok Ern Liang
- Aaron
- Prudhvi Dharmana
- Allison Jia
- Stan Rudenko2
- Divya Gopinath
- Anupam5
- Lariel Fernandes6
- DavidKurokawa
- Debu Sinha7
- Jisoo
- Nicolò Boschi8
- Ingrid Stevens
- Filip Graliński
- 1. @TruEra
- 2. Snowflake
- 3. @snowflakedb
- 4. @facebookresearch
- 5. @stripe
- 6. @dash0hq
- 7. Databricks
- 8. @vectorize-io
Description
New Unified Metric API
We're introducing the Metric class as the new primary API for evaluation metrics in TruLens. This unified interface replaces both Feedback and MetricConfig with a cleaner, more explicit design.
Why This Matters
- Clearer, more readable code: Replace chained
.on_*()methods with an explicitselectors={}dictionary—no more guessing which argument maps to which selector - Single unified class: No need to choose between
FeedbackandMetricConfigfor different use cases - Better OTel integration: Native support for selecting data from OpenTelemetry spans
As a bonus, the same Metric code is now portable to Snowflake environments without modification.
Quick Example
Before (Feedback):
f_groundedness = (
Feedback(provider.groundedness_measure_with_cot_reasons, name="Groundedness")
.on_context(collect_list=True)
.on_output()
)
After (Metric):
f_groundedness = Metric(
implementation=provider.groundedness_measure_with_cot_reasons,
name="Groundedness",
selectors={
"source": Selector.select_context(collect_list=True),
"statement": Selector.select_record_output(),
},
)
The selectors dict makes it explicit which function parameter receives which data.
Migrating from MetricConfig
Before (MetricConfig):
from trulens.core.feedback.custom_metric import MetricConfig
config = MetricConfig(
metric_name="word_count",
metric_implementation=lambda text: len(text.split()),
selectors={"text": Selector.select_record_output()},
)
feedback = config.create_feedback_definition()
After (Metric):
from trulens.core import Metric, Selector
metric = Metric(
name="word_count",
implementation=lambda text: len(text.split()),
selectors={"text": Selector.select_record_output()},
)
Backward Compatibility
The existing Feedback class continues to work with a deprecation warning, giving you time to migrate:
# Still works, but deprecated
from trulens.core import Feedback
f = Feedback(provider.relevance).on_input().on_output()
See the migration guide for detailed instructions on updating your code.
Bug Fixes
- fix: correct typo 'occurences' to 'occurrences' by @thecaptain789 in https://github.com/truera/trulens/pull/2349
- Drop pkg_resources dependency from trulens-core by @debu-sinha in https://github.com/truera/trulens/pull/2351
- fix: add circular-reference-safe repr to SerialModel (#1862) by @sfc-gh-jreini in https://github.com/truera/trulens/pull/2356
- Forward litellm routing params (
api_base,api_key, etc.) to completion calls by @sfc-gh-jreini in https://github.com/truera/trulens/pull/2357 - fix: guard against None model_name in OpenAI endpoint (#1700) by @sfc-gh-jreini in https://github.com/truera/trulens/pull/2358
Docs
- New Example and Docs Updates for usage in MLFlow by @sfc-gh-jreini in https://github.com/truera/trulens/pull/2359
New Contributors
- @thecaptain789 made their first contribution in https://github.com/truera/trulens/pull/2349
Full Changelog: https://github.com/truera/trulens/compare/trulens-2.6.0...trulens-2.7.0
Files
truera/trulens-trulens-2.7.0.zip
Files
(37.5 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:484f8bcfa0aafa6d126fcf5479845717
|
37.5 MB | Preview Download |
Additional details
Related works
- Is supplement to
- Software: https://github.com/truera/trulens/tree/trulens-2.7.0 (URL)
Software
- Repository URL
- https://github.com/truera/trulens