agents.rag.common.query_constructors.hyde.enhanced_prompts¶
Enhanced HyDE prompts based on LangChain best practices.
This module provides improved HyDE prompt templates that follow the principle of separating document generation from structured output parsing.
Key improvements: - Simplified generation prompts focused on content creation - Domain-specific prompt templates - Separate analysis/parsing prompts for structured output - Multi-perspective generation support - Controlled document length
Classes¶
Different perspectives for multi-angle document generation. |
|
Configuration for HyDE prompt selection. |
|
Types of HyDE prompts for different domains. |
Functions¶
|
Create a HyDE prompt based on configuration. |
|
Get an ensemble generation prompt for multiple documents. |
|
Get a generation prompt for the specified type and length. |
|
Get a perspective-based generation prompt. |
|
Automatically select appropriate prompt type based on query analysis. |
Module Contents¶
- class agents.rag.common.query_constructors.hyde.enhanced_prompts.HyDEPerspective¶
-
Different perspectives for multi-angle document generation.
Initialize self. See help(type(self)) for accurate signature.
- class agents.rag.common.query_constructors.hyde.enhanced_prompts.HyDEPromptConfig(/, **data)¶
Bases:
pydantic.BaseModel
Configuration for HyDE prompt selection.
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.common.query_constructors.hyde.enhanced_prompts.HyDEPromptType¶
-
Types of HyDE prompts for different domains.
Initialize self. See help(type(self)) for accurate signature.
- agents.rag.common.query_constructors.hyde.enhanced_prompts.create_hyde_prompt(config, query)¶
Create a HyDE prompt based on configuration.
- Parameters:
config (HyDEPromptConfig) – Prompt configuration
query (str) – User query
- Returns:
Configured ChatPromptTemplate ready for use
- Return type:
langchain_core.prompts.ChatPromptTemplate
- agents.rag.common.query_constructors.hyde.enhanced_prompts.get_ensemble_prompt(num_documents=3, target_length=1000)¶
Get an ensemble generation prompt for multiple documents.
- agents.rag.common.query_constructors.hyde.enhanced_prompts.get_generation_prompt(prompt_type=HyDEPromptType.GENERAL, target_length=1000)¶
Get a generation prompt for the specified type and length.
- Parameters:
prompt_type (HyDEPromptType) – Type of prompt to use
target_length (int) – Target character length for generated document
- Returns:
Configured ChatPromptTemplate
- Return type:
langchain_core.prompts.ChatPromptTemplate
- agents.rag.common.query_constructors.hyde.enhanced_prompts.get_perspective_prompt(perspective, target_length=1000)¶
Get a perspective-based generation prompt.
- Parameters:
perspective (HyDEPerspective) – Perspective to use for generation
target_length (int) – Target character length for generated document
- Returns:
Configured ChatPromptTemplate
- Return type:
langchain_core.prompts.ChatPromptTemplate