Skip to content

trulens.core.feedback.selector

trulens.core.feedback.selector

Classes

Trace dataclass

Functions
to_compressed_json
to_compressed_json(default_handler: Callable = str) -> str

Convert trace events to compressed JSON format. This reduces token usage while preserving essential information.

PARAMETER DESCRIPTION
default_handler

Function to handle non-serializable objects

TYPE: Callable DEFAULT: str

RETURNS DESCRIPTION
str

Compressed JSON string representation of the trace

Selector dataclass

Functions
select_record_input staticmethod
select_record_input(
    ignore_none_values: bool = True,
) -> Selector

Returns a Selector that gets the record input.

PARAMETER DESCRIPTION
ignore_none_values

If True, skip evaluation when the input is None. Defaults to True to prevent errors on missing data.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Selector

Selector that gets the record input.

select_record_output staticmethod
select_record_output(
    ignore_none_values: bool = True,
) -> Selector

Returns a Selector that gets the record output.

PARAMETER DESCRIPTION
ignore_none_values

If True, skip evaluation when the output is None. Defaults to True to prevent errors on missing data.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Selector

Selector that gets the record output.

select_context staticmethod
select_context(
    *, collect_list: bool, ignore_none_values: bool = True
) -> Selector

Returns a Selector that tries to retrieve contexts.

PARAMETER DESCRIPTION
collect_list

Assuming the returned Selector describes a list of strings, whether to call the feedback function: 1. [if collect_list is True]: Once giving the entire list as input. 2. [if collect_list is False]: Separately for each entry in the list and aggregate the results.

TYPE: bool

ignore_none_values

If True, skip evaluation when contexts are None. Defaults to True to prevent errors on missing data.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Selector

Selector that tries to retrieve contexts.

Functions