haive.agents.rag.flare.agent¶

FLARE (Forward-Looking Active REtrieval) RAG Agents.

from typing import Any Implementation of FLARE RAG with forward-looking retrieval and iterative generation. Uses structured output models for planning and managing active retrieval decisions.

Classes¶

ActiveRetrievalAgent

Agent that performs active retrieval based on FLARE plans.

ConfidenceLevel

Confidence levels for generation.

FLAREPlan

Forward-looking plan for active retrieval.

FLAREPlannerAgent

Agent that creates FLARE plans for iterative generation and active retrieval.

FLARERAGAgent

Complete FLARE RAG agent with forward-looking active retrieval.

FLAREResult

Results from FLARE processing.

RetrievalDecision

Decisions for active retrieval.

Functions¶

create_active_retrieval_callable(documents[, ...])

Create callable function for active retrieval.

create_flare_planner_callable(llm_config)

Create callable function for FLARE planning.

create_flare_rag_agent(documents[, llm_config, flare_mode])

Create a FLARE RAG agent.

get_flare_rag_io_schema()

Get I/O schema for FLARE RAG agents.

Module Contents¶

class haive.agents.rag.flare.agent.ActiveRetrievalAgent¶

Bases: haive.agents.base.agent.Agent

Agent that performs active retrieval based on FLARE plans.

build_graph()¶

Build active retrieval graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class haive.agents.rag.flare.agent.ConfidenceLevel¶

Bases: str, enum.Enum

Confidence levels for generation.

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

class haive.agents.rag.flare.agent.FLAREPlan(/, **data)¶

Bases: pydantic.BaseModel

Forward-looking plan for active retrieval.

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.flare.agent.FLAREPlannerAgent¶

Bases: haive.agents.base.agent.Agent

Agent that creates FLARE plans for iterative generation and active retrieval.

build_graph()¶

Build FLARE planning graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class haive.agents.rag.flare.agent.FLARERAGAgent¶

Bases: haive.agents.multi.base.SequentialAgent

Complete FLARE RAG agent with forward-looking active retrieval.

classmethod from_documents(documents, llm_config=None, max_iterations=5, confidence_threshold=0.7, **kwargs)¶

Create FLARE 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

  • max_iterations (int) – Maximum FLARE iterations

  • confidence_threshold (float) – Confidence threshold for retrieval

  • **kwargs – Additional arguments

Returns:

FLARERAGAgent instance

class haive.agents.rag.flare.agent.FLAREResult(/, **data)¶

Bases: pydantic.BaseModel

Results from FLARE 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.flare.agent.RetrievalDecision¶

Bases: str, enum.Enum

Decisions for active retrieval.

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

haive.agents.rag.flare.agent.create_active_retrieval_callable(documents, embedding_model=None)¶

Create callable function for active retrieval.

Parameters:
  • documents (list[langchain_core.documents.Document])

  • embedding_model (str | None)

haive.agents.rag.flare.agent.create_flare_planner_callable(llm_config)¶

Create callable function for FLARE planning.

Parameters:

llm_config (haive.core.models.llm.base.LLMConfig)

haive.agents.rag.flare.agent.create_flare_rag_agent(documents, llm_config=None, flare_mode='adaptive', **kwargs)¶

Create a FLARE RAG agent.

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

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

  • flare_mode (str) – FLARE mode (“conservative”, “adaptive”, “aggressive”)

  • **kwargs – Additional arguments

Returns:

Configured FLARE RAG agent

Return type:

FLARERAGAgent

haive.agents.rag.flare.agent.get_flare_rag_io_schema()¶

Get I/O schema for FLARE RAG agents.

Return type:

dict[str, list[str]]