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ยถ
Factory for building RAG workflows with I/O schema compatibility. |
|
Available RAG components for composition. |
|
Common workflow patterns from the architecture guide. |
Functionsยถ
|
Create any RAG component as a standalone agent. |
|
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:
- 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:
- classmethod create_decomposed_graded_workflow(documents, llm_config=None, enable_hallucination_grading=True, **kwargs)ยถ
Create Query Decomposition โ Retrieval โ Grading โ Hallucination Check โ Answer workflow.
- Parameters:
- Return type:
- 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:
- 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:
- classmethod create_graded_hyde_workflow(documents, llm_config=None, enable_search_tools=False, **kwargs)ยถ
Create HyDE โ Comprehensive Grading โ Answer workflow.
- Parameters:
- Return type:
- 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:
- create_workflow(pattern, components=None, routing_conditions=None, **kwargs)ยถ
Create a workflow based on pattern and components.
- Parameters:
pattern (WorkflowPattern) โ Workflow pattern to use
components (list[RAGComponent] | None) โ Optional component overrides
routing_conditions (dict[str, collections.abc.Callable] | None) โ Conditional routing logic
**kwargs โ Additional configuration
- Returns:
Configured multi-agent workflow
- Return type:
- 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:
- 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:
- class agents.rag.factories.compatible_rag_factory.RAGComponentยถ
-
Available RAG components for composition.
Initialize self. See help(type(self)) for accurate signature.
- class agents.rag.factories.compatible_rag_factory.WorkflowPatternยถ
-
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: