What problem does it solve?
LLM applications can process malicious prompts, return toxic responses, or hallucinate from irrelevant retrieved context. This Skill shows how to turn TruLens feedback functions into runtime blocking guardrails that intercept unsafe inputs and outputs and filter low-relevance documents before they reach the LLM.
Core Features & Use Cases
- Input and Output Blocking: Use the @block_input and @block_output decorators with thresholds and fallback responses to stop criminal, harmful, or PII-containing content in plain Python apps.
- Context Filtering for RAG: Wrap LangChain retrievers with WithFeedbackFilterDocuments or LlamaIndex query engines with WithFeedbackFilterNodes to drop chunks scoring below a context relevance threshold.
- Testing and Monitoring: Validate guardrails with adversarial inputs and audit trigger rates and feedback scores in the TruLens dashboard.
- Use Case: A RAG chatbot filters retrieved documents below a 0.7 relevance score so the LLM only answers from highly relevant context, reducing hallucinations.
Quick Start
Add a blocking guardrail to my TruLens app that blocks criminal inputs above a 0.9 threshold and filters irrelevant retrieved context in my LangChain RAG chain.