agents.rag.multi_agent_rag.enhanced_workflowsยถ

Enhanced Multi-Agent RAG Workflows.

Implements advanced RAG patterns like CRAG, Self-RAG, HYDE, and grading workflows using the new multi-agent base with compatibility and enhanced state management.

Classesยถ

CorrectiveRAGAgent

Corrective RAG (CRAG) with automatic requerying and web search fallback.

DocumentGradingAgent

Agent that grades retrieved documents for relevance.

HYDERAGAgent

HYDE RAG agent that generates hypothetical documents before retrieval.

RequeryDecisionAgent

Agent that decides if requerying is needed based on document grades.

SelfRAGAgent

Self-RAG agent with reflection tokens and adaptive retrieval.

Functionsยถ

create_enhanced_rag_workflow([workflow_type, documents])

Factory function to create enhanced RAG workflows.

Module Contentsยถ

class agents.rag.multi_agent_rag.enhanced_workflows.CorrectiveRAGAgent(retrieval_agent=None, grading_agent=None, requery_agent=None, answer_agent=None, documents=None, **kwargs)ยถ

Bases: haive.agents.multi.base.ConditionalAgent

Corrective RAG (CRAG) with automatic requerying and web search fallback.

Flow: 1. Initial retrieval 2. Grade documents 3. If quality is poor -> requery or web search 4. Generate answer with best available docs

Init .

Parameters:
  • retrieval_agent (haive.agents.rag.base.agent.SimpleRAGAgent | None) โ€“ [TODO: Add description]

  • grading_agent (DocumentGradingAgent | None) โ€“ [TODO: Add description]

  • requery_agent (RequeryDecisionAgent | None) โ€“ [TODO: Add description]

  • answer_agent (haive.agents.simple.agent.SimpleAgent | None) โ€“ [TODO: Add description]

  • documents (list[langchain_core.documents.Document] | None) โ€“ [TODO: Add description]

class agents.rag.multi_agent_rag.enhanced_workflows.DocumentGradingAgentยถ

Bases: haive.agents.base.agent.Agent

Agent that grades retrieved documents for relevance.

build_graph()ยถ

Build graph that grades each retrieved document.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class agents.rag.multi_agent_rag.enhanced_workflows.HYDERAGAgent(hypothesis_agent=None, retrieval_agent=None, answer_agent=None, documents=None, **kwargs)ยถ

Bases: haive.agents.multi.base.SequentialAgent

HYDE RAG agent that generates hypothetical documents before retrieval.

Init .

Parameters:
  • hypothesis_agent (haive.agents.simple.agent.SimpleAgent | None) โ€“ [TODO: Add description]

  • retrieval_agent (haive.agents.rag.base.agent.SimpleRAGAgent | None) โ€“ [TODO: Add description]

  • answer_agent (haive.agents.simple.agent.SimpleAgent | None) โ€“ [TODO: Add description]

  • documents (list[langchain_core.documents.Document] | None) โ€“ [TODO: Add description]

class agents.rag.multi_agent_rag.enhanced_workflows.RequeryDecisionAgentยถ

Bases: haive.agents.base.agent.Agent

Agent that decides if requerying is needed based on document grades.

build_graph()ยถ

Build graph that analyzes grades and decides on requerying.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class agents.rag.multi_agent_rag.enhanced_workflows.SelfRAGAgent(retrieval_decision_agent=None, retrieval_agent=None, relevance_agent=None, generation_agent=None, documents=None, **kwargs)ยถ

Bases: haive.agents.multi.base.ConditionalAgent

Self-RAG agent with reflection tokens and adaptive retrieval.

Init .

Parameters:
  • retrieval_decision_agent (haive.agents.simple.agent.SimpleAgent | None) โ€“ [TODO: Add description]

  • retrieval_agent (haive.agents.rag.base.agent.SimpleRAGAgent | None) โ€“ [TODO: Add description]

  • relevance_agent (haive.agents.simple.agent.SimpleAgent | None) โ€“ [TODO: Add description]

  • generation_agent (haive.agents.simple.agent.SimpleAgent | None) โ€“ [TODO: Add description]

  • documents (list[langchain_core.documents.Document] | None) โ€“ [TODO: Add description]

agents.rag.multi_agent_rag.enhanced_workflows.create_enhanced_rag_workflow(workflow_type='crag', documents=None, **kwargs)ยถ

Factory function to create enhanced RAG workflows.

Parameters:
  • workflow_type (str) โ€“ Type of workflow (โ€œcragโ€, โ€œhydeโ€, โ€œself_ragโ€)

  • documents (list[langchain_core.documents.Document] | None) โ€“ Documents for retrieval

  • **kwargs โ€“ Additional arguments

Returns:

Configured RAG agent

Return type:

haive.agents.base.agent.Agent