agents.rag.hyde.enhanced_agent

Enhanced HyDE RAG Agent using Structured Output Pattern.

from typing import Any, Dict This demonstrates the new pattern where any agent can be enhanced with structured output by appending a SimpleAgent. This approach is more modular and follows the principle of separation of concerns.

Classes

EnhancedHyDERAGAgent

Enhanced HyDE RAG Agent using the structured output enhancement pattern.

EnhancedHyDERetriever

Enhanced retriever that handles both enhancement pattern and traditional outputs.

Functions

adaptive_retrieval(query, documents)

Perform adaptive retrieval on documents.

build_graph()

Build custom graph for enhanced HyDE workflows.

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

Create an Enhanced HyDE RAG agent.

create_hyde_enhancer()

Stub function for create_hyde_enhancer.

demonstrate_enhancement_vs_traditional()

Demonstrate the difference between enhancement and traditional patterns.

Module Contents

class agents.rag.hyde.enhanced_agent.EnhancedHyDERAGAgent

Bases: haive.agents.multi.enhanced_sequential_agent.SequentialAgent

Enhanced HyDE RAG Agent using the structured output enhancement pattern.

This agent demonstrates the new modular approach where: 1. Base agents handle core functionality (generation, retrieval) 2. Enhancement agents add structured output processing 3. The pattern is reusable across different RAG types

Benefits: - Separation of concerns between generation and structure - Reusable enhancement pattern - Easier testing and debugging - Better maintainability

classmethod from_documents(documents, llm_config=None, embedding_model=None, use_enhancement_pattern=True, **kwargs)

Create Enhanced HyDE RAG from documents.

Parameters:
  • documents (list[langchain_core.documents.Document]) – Documents to index

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

  • embedding_model (str | None) – Optional embedding model for vector store

  • use_enhancement_pattern (bool) – Whether to use the new enhancement pattern

  • **kwargs – Additional arguments

Returns:

EnhancedHyDERAGAgent instance

class agents.rag.hyde.enhanced_agent.EnhancedHyDERetriever(documents, embedding_model=None, **kwargs)

Bases: haive.agents.base.agent.Agent

Enhanced retriever that handles both enhancement pattern and traditional outputs.

Init .

Parameters:
  • documents (list[langchain_core.documents.Document]) – [TODO: Add description]

  • embedding_model (str | None) – [TODO: Add description]

build_graph()

Build graph that adapts to both enhancement and traditional patterns.

Return type:

Any

agents.rag.hyde.enhanced_agent.adaptive_retrieval(query, documents)

Perform adaptive retrieval on documents.

Parameters:
  • query (str)

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

Return type:

list[langchain_core.documents.Document]

agents.rag.hyde.enhanced_agent.build_graph()

Build custom graph for enhanced HyDE workflows.

Return type:

Any

agents.rag.hyde.enhanced_agent.create_enhanced_hyde_agent(documents, llm_config=None, use_enhancement_pattern=True, **kwargs)

Create an Enhanced HyDE RAG agent.

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

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

  • use_enhancement_pattern (bool) – Whether to use the new enhancement pattern

  • **kwargs – Additional arguments

Returns:

Configured Enhanced HyDE RAG agent

Return type:

EnhancedHyDERAGAgent

agents.rag.hyde.enhanced_agent.create_hyde_enhancer()

Stub function for create_hyde_enhancer.

agents.rag.hyde.enhanced_agent.demonstrate_enhancement_vs_traditional()

Demonstrate the difference between enhancement and traditional patterns.

Return type:

dict[str, Any]