haive.agents.rag.speculative.agent¶

Speculative RAG Agents.

from typing import Any Implementation of speculative RAG with parallel hypothesis generation and verification. Uses structured output models for hypothesis planning and iterative refinement.

Classes¶

Hypothesis

Individual hypothesis with structured metadata.

HypothesisConfidence

Confidence levels for hypotheses.

HypothesisGeneratorAgent

Agent that generates multiple hypotheses for speculative reasoning.

ParallelVerificationAgent

Agent that performs parallel hypothesis verification.

SpeculativeExecutionPlan

Plan for executing speculative retrieval and verification.

SpeculativeRAGAgent

Complete Speculative RAG agent with parallel hypothesis processing.

SpeculativeResult

Results from speculative RAG processing.

VerificationStatus

Status of hypothesis verification.

Functions¶

create_speculative_rag_agent(documents[, llm_config, ...])

Create a Speculative RAG agent.

get_speculative_rag_io_schema()

Get I/O schema for Speculative RAG agents.

Module Contents¶

class haive.agents.rag.speculative.agent.Hypothesis(/, **data)¶

Bases: pydantic.BaseModel

Individual hypothesis with structured metadata.

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 haive.agents.rag.speculative.agent.HypothesisConfidence¶

Bases: str, enum.Enum

Confidence levels for hypotheses.

Initialize self. See help(type(self)) for accurate signature.

class haive.agents.rag.speculative.agent.HypothesisGeneratorAgent¶

Bases: haive.agents.base.agent.Agent

Agent that generates multiple hypotheses for speculative reasoning.

build_graph()¶

Build hypothesis generation graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class haive.agents.rag.speculative.agent.ParallelVerificationAgent¶

Bases: haive.agents.base.agent.Agent

Agent that performs parallel hypothesis verification.

build_graph()¶

Build parallel verification graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

model_post_init(__context)¶

Initialize the mixin with state tracking attributes after Pydantic validation.

Parameters:

__context (Any)

Return type:

None

class haive.agents.rag.speculative.agent.SpeculativeExecutionPlan(/, **data)¶

Bases: pydantic.BaseModel

Plan for executing speculative retrieval and verification.

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 haive.agents.rag.speculative.agent.SpeculativeRAGAgent¶

Bases: haive.agents.multi.base.SequentialAgent

Complete Speculative RAG agent with parallel hypothesis processing.

classmethod from_documents(documents, llm_config=None, num_hypotheses=5, verification_depth='thorough', **kwargs)¶

Create Speculative RAG agent from documents.

Parameters:
  • documents (list[langchain_core.documents.Document]) – Documents to index

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

  • num_hypotheses (int) – Number of hypotheses to generate

  • verification_depth (str) – Depth of verification process

  • **kwargs – Additional arguments

Returns:

SpeculativeRAGAgent instance

class haive.agents.rag.speculative.agent.SpeculativeResult(/, **data)¶

Bases: pydantic.BaseModel

Results from speculative RAG processing.

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 haive.agents.rag.speculative.agent.VerificationStatus¶

Bases: str, enum.Enum

Status of hypothesis verification.

Initialize self. See help(type(self)) for accurate signature.

haive.agents.rag.speculative.agent.create_speculative_rag_agent(documents, llm_config=None, speculation_mode='balanced', **kwargs)¶

Create a Speculative RAG agent.

Parameters:
  • documents (list[langchain_core.documents.Document]) – Documents for retrieval

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

  • speculation_mode (str) – Mode (“conservative”, “balanced”, “aggressive”)

  • **kwargs – Additional arguments

Returns:

Configured Speculative RAG agent

Return type:

SpeculativeRAGAgent

haive.agents.rag.speculative.agent.get_speculative_rag_io_schema()¶

Get I/O schema for Speculative RAG agents.

Return type:

dict[str, list[str]]