agents.rag.factories.compatible_rag_factoryยถ

Compatible RAG Workflow Factory.

Generic factory for building composable RAG workflows based on I/O schema compatibility. Uses the enhanced multi-agent base with automatic compatibility checking, agent replacement, and workflow optimization. Allows replacing agents by compatible I/O schemas.

Key Features:
  • Automatic I/O schema compatibility analysis

  • Agent replacement based on schema compatibility

  • Workflow optimization for better field flow

  • Component-based RAG workflow building

  • Integration with search tools from haive.tools

  • Enhanced system prompts and grading

Classesยถ

CompatibleRAGFactory

Factory for building RAG workflows with I/O schema compatibility.

RAGComponent

Available RAG components for composition.

WorkflowPattern

Common workflow patterns from the architecture guide.

Functionsยถ

create_plug_and_play_component(component_type, documents)

Create any RAG component as a standalone agent.

get_component_compatibility_info(component_type)

Get I/O schema information for a component type.

Module Contentsยถ

class agents.rag.factories.compatible_rag_factory.CompatibleRAGFactory(documents, llm_config=None, enable_search_tools=False, default_embedding_model=None)ยถ

Factory for building RAG workflows with I/O schema compatibility.

Uses the enhanced multi-agent base with automatic compatibility checking, agent replacement, and workflow optimization.

Initialize factory with common dependencies.

Parameters:
  • documents (list[langchain_core.documents.Document]) โ€“ Document collection for retrieval

  • llm_config (haive.core.models.llm.base.LLMConfig | None) โ€“ LLM configuration for all components

  • enable_search_tools (bool) โ€“ Whether to integrate external search tools

  • default_embedding_model (str | None) โ€“ Default embedding model for vector stores

analyze_workflow_compatibility(workflow)ยถ

Analyze I/O compatibility of existing workflow.

Parameters:

workflow (SequentialAgent | ConditionalAgent) โ€“ Workflow to analyze

Returns:

Compatibility analysis report

Return type:

dict[str, Any]

build_graph()ยถ

Build graph with compatibility-aware callable sequence.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

classmethod create_agentic_search_workflow(documents, llm_config=None, **kwargs)ยถ

Create agentic workflow with search tool integration.

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

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

Return type:

ConditionalAgent

classmethod create_decomposed_graded_workflow(documents, llm_config=None, enable_hallucination_grading=True, **kwargs)ยถ

Create Query Decomposition โ†’ Retrieval โ†’ Grading โ†’ Hallucination Check โ†’ Answer workflow.

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

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

  • enable_hallucination_grading (bool)

Return type:

SequentialAgent

create_from_schema_compatibility(component_sequence, auto_optimize=True, **kwargs)ยถ

Create workflow by chaining components with compatible I/O schemas.

This is the core generic functionality - it analyzes I/O schemas and builds a compatible chain using the enhanced multi-agent base.

Parameters:
  • component_sequence (list[RAGComponent]) โ€“ Ordered list of components to chain

  • auto_optimize (bool) โ€“ Whether to auto-optimize agent order

  • **kwargs โ€“ Additional configuration

Returns:

SequentialAgent with compatible component chain

Return type:

SequentialAgent

classmethod create_full_pipeline_workflow(documents, llm_config=None, **kwargs)ยถ

Create comprehensive pipeline with all major components.

Pipeline: Decomposition โ†’ HyDE โ†’ Retrieval โ†’ Grading โ†’ Hallucination Check โ†’ Answer

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

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

Return type:

SequentialAgent

classmethod create_graded_hyde_workflow(documents, llm_config=None, enable_search_tools=False, **kwargs)ยถ

Create HyDE โ†’ Comprehensive Grading โ†’ Answer workflow.

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

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

  • enable_search_tools (bool)

Return type:

SequentialAgent

classmethod create_modular_rag_workflow(documents, components, llm_config=None, **kwargs)ยถ

Create custom workflow from list of components.

This is the most generic method - just pass the components you want!

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

  • components (list[RAGComponent])

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

Return type:

SequentialAgent

create_workflow(pattern, components=None, routing_conditions=None, **kwargs)ยถ

Create a workflow based on pattern and components.

Parameters:
Returns:

Configured multi-agent workflow

Return type:

SequentialAgent | ConditionalAgent | ParallelAgent

replace_agent_in_workflow(workflow, target_agent_name, replacement_component, **kwargs)ยถ

Replace an agent in existing workflow based on I/O compatibility.

Uses the enhanced multi-agent base compatibility checking.

Parameters:
  • workflow (SequentialAgent | ConditionalAgent) โ€“ Existing workflow to modify

  • target_agent_name (str) โ€“ Name of agent to replace

  • replacement_component (RAGComponent) โ€“ New component to use

  • **kwargs โ€“ Configuration for new component

Returns:

True if replacement successful

Return type:

bool

suggest_workflow_optimizations(workflow)ยถ

Suggest optimizations for workflow based on I/O compatibility.

Parameters:

workflow (SequentialAgent | ConditionalAgent) โ€“ Workflow to optimize

Returns:

Optimization suggestions

Return type:

dict[str, Any]

class agents.rag.factories.compatible_rag_factory.RAGComponentยถ

Bases: str, enum.Enum

Available RAG components for composition.

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

class agents.rag.factories.compatible_rag_factory.WorkflowPatternยถ

Bases: str, enum.Enum

Common workflow patterns from the architecture guide.

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

agents.rag.factories.compatible_rag_factory.create_plug_and_play_component(component_type, documents, llm_config=None, **kwargs)ยถ

Create any RAG component as a standalone agent.

This function allows creating any component independently for plug-and-play usage.

Parameters:
  • component_type (RAGComponent) โ€“ Type of component to create

  • documents (list[langchain_core.documents.Document]) โ€“ Documents for components that need them

  • llm_config (haive.core.models.llm.base.LLMConfig | None) โ€“ LLM configuration

  • **kwargs โ€“ Component-specific arguments

Returns:

Standalone agent that can be plugged into any workflow

Return type:

haive.agents.base.agent.Agent

Examples

# Create standalone components decomposer = create_plug_and_play_component(

RAGComponent.ADAPTIVE_DECOMPOSITION, docs

) hallucination_grader = create_plug_and_play_component(

RAGComponent.ADVANCED_HALLUCINATION_GRADING, docs

)

# Use with any workflow workflow = SequentialAgent(agents=[decomposer, retriever, hallucination_grader])

agents.rag.factories.compatible_rag_factory.get_component_compatibility_info(component_type)ยถ

Get I/O schema information for a component type.

Parameters:

component_type (RAGComponent) โ€“ Component to get info for

Returns:

Dict with โ€˜inputsโ€™ and โ€˜outputsโ€™ lists

Return type:

dict[str, list[str]]