Skip to content

trulens.dashboard.display

trulens.dashboard.display

Classes

Functions

get_icon

get_icon(fdef: FeedbackDefinition, result: float) -> str

Get the icon for a given feedback definition and result.

PARAMETER DESCRIPTION
result

The result of the feedback.

TYPE: float

RETURNS DESCRIPTION
str

The icon for the feedback

TYPE: str

get_feedback_result

get_feedback_result(
    tru_record: Record,
    feedback_name: str,
    timeout: int = 60,
) -> DataFrame

Retrieve the feedback results including metadata (such as reasons) for a given feedback name from a TruLens record.

PARAMETER DESCRIPTION
tru_record

The record containing feedback and future results.

TYPE: Record

feedback_name

The name of the feedback to retrieve results for.

TYPE: str

RETURNS DESCRIPTION
DataFrame

pd.DataFrame: A DataFrame containing the feedback results. If no feedback results are found, an empty DataFrame is returned.

highlight

highlight(
    row: Series,
    selected_feedback: str,
    feedback_directions: Dict[str, bool],
    default_direction: str,
) -> List[str]

Apply background color to the rows of a DataFrame based on the selected feedback.

PARAMETER DESCRIPTION
row

A row of the DataFrame to be highlighted.

TYPE: Series

selected_feedback

The selected feedback to determine the background color.

TYPE: str

feedback_directions

A dictionary mapping feedback names to their directions.

TYPE: dict

default_direction

The default direction for feedback.

TYPE: str

RETURNS DESCRIPTION
list

A list of CSS styles representing the background color for each cell in the row.

TYPE: List[str]

expand_groundedness_df

expand_groundedness_df(df: DataFrame) -> DataFrame

Expand the groundedness DataFrame by splitting the reasons column into separate rows and columns.

PARAMETER DESCRIPTION
df

The groundedness DataFrame.

TYPE: DataFrame

RETURNS DESCRIPTION
DataFrame

pd.DataFrame: The expanded DataFrame.