trulens.core.metric.selector¶
trulens.core.metric.selector
¶
Classes¶
Selector
dataclass
¶
Attributes¶
is_dataset_selector
property
¶
is_dataset_selector: bool
Whether this selector reads from a tabular dataset column.
Functions¶
from_column
staticmethod
¶
from_column(
column_name: str,
*,
collect_list: bool = True,
ignore_none_values: bool = False
) -> Selector
Returns a Selector that reads its value from a dataset column.
This is used for batch/offline evaluation with
BatchEvaluator, where metrics are
run over a pre-collected dataset (a pandas DataFrame or a list of dicts)
instead of over spans produced by a live app. Batch results are
returned in-memory only and are not persisted to the dashboard; for
dashboard-visible evaluation of pre-collected data, use
Run with mode=Mode.LOG_INGESTION.
| PARAMETER | DESCRIPTION |
|---|---|
column_name
|
The name of the dataset column to read the value from.
TYPE:
|
collect_list
|
Only relevant when the column holds list values. If True (default), the whole list is passed to the metric in a single call. If False, the metric is called once per item in the list and the results are aggregated.
TYPE:
|
ignore_none_values
|
If True, skip evaluation for rows where the selected value is None (or missing).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Selector
|
A |
select_conversation
staticmethod
¶
select_conversation() -> Selector
Return a selector for ordered records in a conversation.
select_conversation_input
staticmethod
¶
select_conversation_input() -> Selector
Return a selector for ordered inputs in a conversation.
select_conversation_output
staticmethod
¶
select_conversation_output() -> Selector
Return a selector for ordered outputs in a conversation.
select_record_input
staticmethod
¶
select_record_output
staticmethod
¶
select_context
staticmethod
¶
Returns a Selector that tries to retrieve contexts.
| PARAMETER | DESCRIPTION |
|---|---|
collect_list
|
Assuming the returned
TYPE:
|
ignore_none_values
|
If True, skip evaluation when contexts are None. Defaults to True to prevent errors on missing data.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Selector
|
|