agents.rag.hallucination_grading.agent

Hallucination Grading Agents.

Modular agents for detecting and grading hallucinations in RAG responses. Can be plugged into any workflow with compatible I/O schemas.

Classes

AdvancedHallucinationGrade

Advanced hallucination assessment with detailed analysis.

AdvancedHallucinationGraderAgent

Advanced hallucination grading with detailed analysis.

HallucinationGrade

Single hallucination assessment.

HallucinationGraderAgent

Basic hallucination grading agent.

RealtimeHallucinationCheck

Quick hallucination check for real-time applications.

RealtimeHallucinationGraderAgent

Fast hallucination checker for real-time applications.

Functions

create_hallucination_grader([grader_type, llm_config])

Create a hallucination grader agent.

get_hallucination_grader_io_schema()

Get I/O schema for hallucination graders for compatibility checking.

Module Contents

class agents.rag.hallucination_grading.agent.AdvancedHallucinationGrade(/, **data)

Bases: pydantic.BaseModel

Advanced hallucination assessment with detailed analysis.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class agents.rag.hallucination_grading.agent.AdvancedHallucinationGraderAgent(llm_config=None, enable_context_expansion=True, **kwargs)

Bases: haive.agents.base.agent.Agent

Advanced hallucination grading with detailed analysis.

Initialize advanced hallucination grader.

Parameters:
  • llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration

  • enable_context_expansion (bool) – Whether to use additional context sources

  • **kwargs – Additional agent arguments

build_graph()

Build advanced hallucination analysis graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class agents.rag.hallucination_grading.agent.HallucinationGrade(/, **data)

Bases: pydantic.BaseModel

Single hallucination assessment.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class agents.rag.hallucination_grading.agent.HallucinationGraderAgent(llm_config=None, threshold=0.7, **kwargs)

Bases: haive.agents.base.agent.Agent

Basic hallucination grading agent.

Initialize hallucination grader.

Parameters:
  • llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration

  • threshold (float) – Confidence threshold for flagging hallucinations

  • **kwargs – Additional agent arguments

build_graph()

Build hallucination grading graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class agents.rag.hallucination_grading.agent.RealtimeHallucinationCheck(/, **data)

Bases: pydantic.BaseModel

Quick hallucination check for real-time applications.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class agents.rag.hallucination_grading.agent.RealtimeHallucinationGraderAgent(llm_config=None, safety_threshold=0.8, **kwargs)

Bases: haive.agents.base.agent.Agent

Fast hallucination checker for real-time applications.

Initialize realtime hallucination grader.

Parameters:
  • llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration

  • safety_threshold (float) – Threshold for considering response safe

  • **kwargs – Additional agent arguments

build_graph()

Build realtime hallucination check graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

agents.rag.hallucination_grading.agent.create_hallucination_grader(grader_type='basic', llm_config=None, **kwargs)

Create a hallucination grader agent.

Parameters:
  • grader_type (Literal['basic', 'advanced', 'realtime']) – Type of grader to create

  • llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration

  • **kwargs – Additional arguments

Returns:

Configured hallucination grader agent

Return type:

haive.agents.base.agent.Agent

agents.rag.hallucination_grading.agent.get_hallucination_grader_io_schema()

Get I/O schema for hallucination graders for compatibility checking.

Return type:

dict[str, list[str]]