Skip to content

TruLens Guardrails

trulens_eval.guardrails.base

Classes

context_filter

Provides a decorator to filter contexts based on a given feedback and threshold.

Parameters: feedback (Feedback): The feedback object to use for filtering. threshold (float): The minimum feedback value required for a context to be included.

Example

feedback = Feedback(provider.groundedness_measure_with_cot_reasons, name="Groundedness")
@context_filter(feedback, 0.5)
def retrieve(query: str) -> list:
    results = vector_store.query(
    query_texts=query,
    n_results=3
)
return [doc for sublist in results['documents'] for doc in sublist]