haive.agents.rag.self_route.agent¶

Self-Route RAG Agents.

from typing import Any Implementation of self-routing RAG with dynamic strategy selection and iterative planning. Uses structured output models for complex routing decisions and preprocessing.

Classes¶

IterativePlan

Iterative processing plan with loop structure.

IterativePlannerAgent

Agent that creates iterative processing plans.

QueryAnalysis

Structured analysis of query for routing decisions.

QueryAnalyzerAgent

Agent that performs structured query analysis for routing.

QueryComplexity

Query complexity levels for routing decisions.

RoutingDecision

Final routing decision with execution plan.

RoutingDecisionAgent

Agent that makes final routing decisions.

RoutingStrategy

Available routing strategies.

SelfRouteRAGAgent

Complete Self-Route RAG agent with structured analysis and iterative planning.

Functions¶

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

Create a Self-Route RAG agent.

get_self_route_rag_io_schema()

Get I/O schema for Self-Route RAG agents.

Module Contents¶

class haive.agents.rag.self_route.agent.IterativePlan(/, **data)¶

Bases: pydantic.BaseModel

Iterative processing plan with loop structure.

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.self_route.agent.IterativePlannerAgent¶

Bases: haive.agents.base.agent.Agent

Agent that creates iterative processing plans.

build_graph()¶

Build iterative planning graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class haive.agents.rag.self_route.agent.QueryAnalysis(/, **data)¶

Bases: pydantic.BaseModel

Structured analysis of query for routing decisions.

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.self_route.agent.QueryAnalyzerAgent¶

Bases: haive.agents.base.agent.Agent

Agent that performs structured query analysis for routing.

build_graph()¶

Build query analysis graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class haive.agents.rag.self_route.agent.QueryComplexity¶

Bases: str, enum.Enum

Query complexity levels for routing decisions.

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

class haive.agents.rag.self_route.agent.RoutingDecision(/, **data)¶

Bases: pydantic.BaseModel

Final routing decision with execution plan.

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.self_route.agent.RoutingDecisionAgent¶

Bases: haive.agents.base.agent.Agent

Agent that makes final routing decisions.

build_graph()¶

Build routing decision graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class haive.agents.rag.self_route.agent.RoutingStrategy¶

Bases: str, enum.Enum

Available routing strategies.

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

class haive.agents.rag.self_route.agent.SelfRouteRAGAgent¶

Bases: haive.agents.multi.base.SequentialAgent

Complete Self-Route RAG agent with structured analysis and iterative planning.

classmethod from_documents(documents, llm_config=None, analysis_depth='comprehensive', max_iterations=3, enable_fallback=True, **kwargs)¶

Create Self-Route 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

  • analysis_depth (str) – Depth of query analysis

  • max_iterations (int) – Maximum iterations for planning

  • enable_fallback (bool) – Whether to enable fallback routing

  • **kwargs – Additional arguments

Returns:

SelfRouteRAGAgent instance

haive.agents.rag.self_route.agent.create_self_route_rag_agent(documents, llm_config=None, routing_mode='adaptive', **kwargs)¶

Create a Self-Route RAG agent.

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

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

  • routing_mode (str) – Routing mode (“conservative”, “adaptive”, “aggressive”)

  • **kwargs – Additional arguments

Returns:

Configured Self-Route RAG agent

Return type:

SelfRouteRAGAgent

haive.agents.rag.self_route.agent.get_self_route_rag_io_schema()¶

Get I/O schema for Self-Route RAG agents.

Return type:

dict[str, list[str]]