agents.rag.factories.rag_workflow_factory

RAG Workflow Factory.

Generic factory for creating RAG workflows by composing callable functions into different agent patterns. This provides a clean, modular approach to building complex RAG systems.

Classes

ConditionalCallableAgent

Agent with conditional routing based on callable results.

GenericCallableAgent

Generic agent that executes a sequence of callable functions.

Functions

create_adaptive_rag_agent([documents, name])

Create an adaptive RAG agent with complexity-based routing.

create_corrective_rag_agent([documents, name])

Create a CRAG agent with web search fallback.

create_hyde_rag_agent([documents, name])

Create a HYDE RAG agent with hypothesis generation.

create_multi_query_rag_agent([documents, name])

Create a multi-query RAG agent with query variations.

create_rag_workflow(workflow_type[, documents, ...])

Main factory function for creating RAG workflows.

create_self_rag_agent([documents, name])

Create a Self-RAG agent with reflection tokens.

create_step_back_rag_agent([documents, name])

Create a step-back prompting RAG agent.

Module Contents

class agents.rag.factories.rag_workflow_factory.ConditionalCallableAgent(router_callable, action_callables, name='Conditional Callable Agent', **kwargs)

Bases: haive.agents.base.agent.Agent

Agent with conditional routing based on callable results.

Init .

Parameters:
build_graph()

Build graph with conditional routing.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class agents.rag.factories.rag_workflow_factory.GenericCallableAgent(callables, name='Generic Callable Agent', **kwargs)

Bases: haive.agents.base.agent.Agent

Generic agent that executes a sequence of callable functions.

Init .

Parameters:
build_graph()

Build graph with callable sequence.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

agents.rag.factories.rag_workflow_factory.create_adaptive_rag_agent(documents=None, name='Adaptive RAG Agent')

Create an adaptive RAG agent with complexity-based routing.

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

  • name (str)

Return type:

haive.agents.base.agent.Agent

agents.rag.factories.rag_workflow_factory.create_corrective_rag_agent(documents=None, name='Corrective RAG Agent')

Create a CRAG agent with web search fallback.

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

  • name (str)

Return type:

haive.agents.base.agent.Agent

agents.rag.factories.rag_workflow_factory.create_hyde_rag_agent(documents=None, name='HYDE RAG Agent')

Create a HYDE RAG agent with hypothesis generation.

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

  • name (str)

Return type:

haive.agents.base.agent.Agent

agents.rag.factories.rag_workflow_factory.create_multi_query_rag_agent(documents=None, name='Multi-Query RAG Agent')

Create a multi-query RAG agent with query variations.

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

  • name (str)

Return type:

haive.agents.base.agent.Agent

agents.rag.factories.rag_workflow_factory.create_rag_workflow(workflow_type, documents=None, custom_callables=None, **kwargs)

Main factory function for creating RAG workflows.

Parameters:
  • workflow_type (str) – Type of RAG workflow to create

  • documents (list[langchain_core.documents.Document] | None) – Documents for retrieval

  • custom_callables (dict[str, collections.abc.Callable] | None) – Custom callable functions to override defaults

  • **kwargs – Additional arguments

Returns:

Configured RAG agent

Return type:

haive.agents.base.agent.Agent

Available workflow types:
  • ‘corrective’ / ‘crag’: Corrective RAG with web search

  • ‘self_rag’: Self-RAG with reflection tokens

  • ‘adaptive’: Adaptive RAG with complexity routing

  • ‘hyde’: HYDE RAG with hypothesis generation

  • ‘step_back’: Step-back prompting RAG

  • ‘multi_query’: Multi-query RAG with variations

  • ‘simple’: Basic sequential RAG

agents.rag.factories.rag_workflow_factory.create_self_rag_agent(documents=None, name='Self-RAG Agent')

Create a Self-RAG agent with reflection tokens.

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

  • name (str)

Return type:

haive.agents.base.agent.Agent

agents.rag.factories.rag_workflow_factory.create_step_back_rag_agent(documents=None, name='Step-Back RAG Agent')

Create a step-back prompting RAG agent.

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

  • name (str)

Return type:

haive.agents.base.agent.Agent