agents.rag.hyde.enhanced_agent_v2¶
Enhanced HyDE RAG Agent v2 with Advanced Prompt Selection and Multi-Document Generation.
This version integrates the new enhanced prompt system with: - Automatic prompt type selection based on query analysis - Multi-document generation from different perspectives - Improved separation of generation from parsing - Domain-specific prompt templates - Ensemble retrieval using multiple hypothetical documents
Classes¶
Generator that adapts its prompt based on query analysis. |
|
Analyzes queries to determine relevant domains for multi-domain generation. |
|
Enhanced HyDE RAG Agent with advanced prompt selection and multi-document generation. |
|
Enhanced retriever with better state handling and fallback mechanisms. |
|
Parses ensemble document output into individual documents. |
|
Retriever that handles multiple documents for ensemble retrieval. |
|
Configuration for Enhanced HyDE RAG Agent. |
|
Analyzes generated hypothetical documents and extracts structured information. |
|
Different modes for HyDE document generation. |
|
Retriever that handles documents from multiple domains. |
|
Agent that analyzes queries and selects appropriate prompt types. |
Functions¶
|
Create Enhanced HyDE RAG Agent v2 with specified configuration. |
|
Create HyDE agent with ensemble document generation. |
|
Create HyDE agent with multi-perspective generation. |
Module Contents¶
- class agents.rag.hyde.enhanced_agent_v2.AdaptiveHyDEGenerator(llm_config, **kwargs)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Generator that adapts its prompt based on query analysis.
Init .
- Parameters:
llm_config (haive.core.models.llm.base.LLMConfig) – [TODO: Add description]
- class agents.rag.hyde.enhanced_agent_v2.DomainAnalysisAgent(llm_config, **kwargs)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Analyzes queries to determine relevant domains for multi-domain generation.
Init .
- Parameters:
llm_config (haive.core.models.llm.base.LLMConfig) – [TODO: Add description]
- class agents.rag.hyde.enhanced_agent_v2.EnhancedHyDERAGAgentV2(/, **data)¶
Bases:
haive.agents.multi.enhanced_sequential_agent.SequentialAgent
,haive.core.common.mixins.tool_route_mixin.ToolRouteMixin
Enhanced HyDE RAG Agent with advanced prompt selection and multi-document generation.
Key Features: - Automatic prompt type selection based on query analysis - Multi-document generation from different perspectives/domains - Ensemble retrieval using multiple hypothetical documents - Proper separation of generation from parsing - Configurable generation strategies - Enhanced error handling and fallback mechanisms
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- classmethod from_documents(documents, llm_config=None, embedding_model=None, config=None, **kwargs)¶
Create Enhanced HyDE RAG Agent v2 from documents.
- Parameters:
documents (list[langchain_core.documents.Document]) – Documents to index for retrieval
llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration
embedding_model (str | None) – Optional embedding model
config (HyDEAgentConfig | None) – HyDE agent configuration
**kwargs – Additional arguments
- Returns:
Configured Enhanced HyDE RAG Agent v2
- Return type:
- setup_hyde_agent()¶
Setup HyDE agent with enhanced prompts.
- Return type:
- class agents.rag.hyde.enhanced_agent_v2.EnhancedHyDERetrieverV2¶
Bases:
haive.agents.base.agent.Agent
Enhanced retriever with better state handling and fallback mechanisms.
- build_graph()¶
Build Graph.
- Returns:
Add return description]
- Return type:
[TODO
- class agents.rag.hyde.enhanced_agent_v2.EnsembleDocumentParser(llm_config, **kwargs)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Parses ensemble document output into individual documents.
Init .
- Parameters:
llm_config (haive.core.models.llm.base.LLMConfig) – [TODO: Add description]
- class agents.rag.hyde.enhanced_agent_v2.EnsembleHyDERetriever¶
Bases:
haive.agents.base.agent.Agent
Retriever that handles multiple documents for ensemble retrieval.
- build_graph()¶
Build Graph.
- Returns:
Add return description]
- Return type:
[TODO
- class agents.rag.hyde.enhanced_agent_v2.HyDEAgentConfig(/, **data)¶
Bases:
pydantic.BaseModel
Configuration for Enhanced HyDE RAG Agent.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- class agents.rag.hyde.enhanced_agent_v2.HyDEDocumentAnalyzer(llm_config, **kwargs)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Analyzes generated hypothetical documents and extracts structured information.
Init .
- Parameters:
llm_config (haive.core.models.llm.base.LLMConfig) – [TODO: Add description]
- class agents.rag.hyde.enhanced_agent_v2.HyDEGenerationMode¶
-
Different modes for HyDE document generation.
Initialize self. See help(type(self)) for accurate signature.
- class agents.rag.hyde.enhanced_agent_v2.MultiDomainHyDERetriever¶
Bases:
haive.agents.base.agent.Agent
Retriever that handles documents from multiple domains.
- build_graph()¶
Build Graph.
- Returns:
Add return description]
- Return type:
[TODO
- class agents.rag.hyde.enhanced_agent_v2.QueryAnalysisAgent(llm_config, **kwargs)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Agent that analyzes queries and selects appropriate prompt types.
Init .
- Parameters:
llm_config (haive.core.models.llm.base.LLMConfig) – [TODO: Add description]
- agents.rag.hyde.enhanced_agent_v2.create_enhanced_hyde_v2(documents, llm_config=None, generation_mode=HyDEGenerationMode.SINGLE, auto_select_prompt=True, **kwargs)¶
Create Enhanced HyDE RAG Agent v2 with specified configuration.
- Parameters:
documents (list[langchain_core.documents.Document]) – Documents for retrieval
llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration
generation_mode (HyDEGenerationMode) – Mode for document generation
auto_select_prompt (bool) – Whether to auto-select prompt types
**kwargs – Additional configuration options
- Returns:
Configured Enhanced HyDE RAG Agent v2
- Return type:
- agents.rag.hyde.enhanced_agent_v2.create_ensemble_hyde(documents, num_docs=3, llm_config=None, **kwargs)¶
Create HyDE agent with ensemble document generation.
- Parameters:
- Returns:
Ensemble HyDE agent
- Return type:
- agents.rag.hyde.enhanced_agent_v2.create_multi_perspective_hyde(documents, perspectives, llm_config=None, **kwargs)¶
Create HyDE agent with multi-perspective generation.
- Parameters:
documents (list[langchain_core.documents.Document]) – Documents for retrieval
perspectives (list[haive.agents.rag.common.query_constructors.hyde.enhanced_prompts.HyDEPerspective]) – List of perspectives to use
llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration
**kwargs – Additional options
- Returns:
Multi-perspective HyDE agent
- Return type: