mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +00:00
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:
@@ -25,8 +25,13 @@ AI hallucinations occur when language models generate content that appears plaus
|
|||||||
from crewai.tasks.hallucination_guardrail import HallucinationGuardrail
|
from crewai.tasks.hallucination_guardrail import HallucinationGuardrail
|
||||||
from crewai import LLM
|
from crewai import LLM
|
||||||
|
|
||||||
# Initialize the guardrail with reference context
|
# Basic usage - will use task's expected_output as context
|
||||||
guardrail = HallucinationGuardrail(
|
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.",
|
context="AI helps with various tasks including analysis and generation.",
|
||||||
llm=LLM(model="gpt-4o-mini")
|
llm=LLM(model="gpt-4o-mini")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user