docs: update hallucination guardrail examples

- Add basic usage example showing guardrail uses task's expected_output as default context
- Add explicit context example for custom reference content
This commit is contained in:
Greyson LaLonde
2025-06-05 12:34:52 -04:00
committed by João Moura
parent 30413d19be
commit b9d7d3ce7a

View File

@@ -25,8 +25,13 @@ AI hallucinations occur when language models generate content that appears plaus
from crewai.tasks.hallucination_guardrail import HallucinationGuardrail
from crewai import LLM
# Initialize the guardrail with reference context
# Basic usage - will use task's expected_output as context
guardrail = HallucinationGuardrail(
llm=LLM(model="gpt-4o-mini")
)
# With explicit reference context
context_guardrail = HallucinationGuardrail(
context="AI helps with various tasks including analysis and generation.",
llm=LLM(model="gpt-4o-mini")
)