haive.agents.rag.models¶
RAG Agent Models.
This module contains all Pydantic models used by RAG agents for structured data validation and type safety. These models represent different outputs and intermediate results from various RAG patterns.
Example
>>> from haive.agents.rag.models import HyDEResult
>>> result = HyDEResult(
... hypothetical_doc="Generated document content...",
... refined_query="Refined query text",
... confidence=0.85
... )
- Typical usage:
Import specific models for agent implementations
Use for structured output from LLM engines
Validate intermediate results in RAG pipelines
Type hints for function parameters and returns
Classes¶
Result from a single retrieval branch. |
|
Enhanced response with reasoning and memory integration. |
|
Fusion ranking result from multi-query RAG. |
|
Hypothetical Document Enhanced (HyDE) result. |
|
Memory analysis result for context-aware processing. |
|
Memory entry for memory-aware RAG systems. |
|
Types of memory for memory-aware RAG. |
|
Final merged result from multiple branches or strategies. |
|
Query classification result for routing decisions. |
|
Query planning result for complex query decomposition. |
|
Types of queries for branched RAG routing. |
|
Types of RAG modules for modular composition. |
|
ReAct pattern step types. |
|
Result from a single ReAct pattern step. |
|
Speculative reasoning result with hypothesis verification. |
|
Step-back reasoning result for abstract thinking. |
|
Strategy selection decision for agentic routing. |
|
Result from executing a single sub-query. |
Module Contents¶
- class haive.agents.rag.models.BranchResult(/, **data)¶
Bases:
pydantic.BaseModelResult from a single retrieval branch.
Contains results from executing a specific branch in branched RAG, where multiple retrieval strategies are executed in parallel.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.EnhancedResponse(/, **data)¶
Bases:
pydantic.BaseModelEnhanced response with reasoning and memory integration.
Contains a comprehensive response that includes the main answer, reasoning chain, memory context, and metadata.
- Parameters:
data (Any)
- reasoning_chain¶
ReAct reasoning steps taken.
- Type:
List[ReActStepResult]
- memory_used¶
Memories used in generating response.
- Type:
List[MemoryEntry]
- new_memories¶
New memories to store from this interaction.
- Type:
List[MemoryEntry]
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.
- class haive.agents.rag.models.FusionResult(/, **data)¶
Bases:
pydantic.BaseModelFusion ranking result from multi-query RAG.
Contains documents ranked using reciprocal rank fusion or similar techniques for combining multiple retrieval results.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.HyDEResult(/, **data)¶
Bases:
pydantic.BaseModelHypothetical Document Enhanced (HyDE) result.
Contains the generated hypothetical document and refined query used in the HyDE RAG pattern for improved retrieval performance.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.MemoryAnalysis(/, **data)¶
Bases:
pydantic.BaseModelMemory analysis result for context-aware processing.
Contains analysis of relevant memories and identified knowledge gaps for enhanced context-aware response generation.
- Parameters:
data (Any)
- relevant_memories¶
Relevant memories found.
- Type:
List[MemoryEntry]
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.
- class haive.agents.rag.models.MemoryEntry(/, **data)¶
Bases:
pydantic.BaseModelMemory entry for memory-aware RAG systems.
Represents a single memory entry with content, type, and metadata for use in conversation-aware RAG agents.
- Parameters:
data (Any)
- memory_type¶
Type of memory (short-term, long-term, etc.).
- Type:
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.
- class haive.agents.rag.models.MemoryType¶
-
Types of memory for memory-aware RAG.
- SHORT_TERM¶
Short-term conversational memory.
- LONG_TERM¶
Long-term knowledge memory.
- EPISODIC¶
Episodic interaction memory.
- SEMANTIC¶
Semantic knowledge memory.
Initialize self. See help(type(self)) for accurate signature.
- class haive.agents.rag.models.MergedResult(/, **data)¶
Bases:
pydantic.BaseModelFinal merged result from multiple branches or strategies.
Contains the final synthesized result after combining outputs from multiple RAG branches or strategies.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.QueryClassification(/, **data)¶
Bases:
pydantic.BaseModelQuery classification result for routing decisions.
Contains classification results used for routing queries to appropriate RAG strategies or processing branches.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.QueryPlan(/, **data)¶
Bases:
pydantic.BaseModelQuery planning result for complex query decomposition.
Contains a plan for executing a complex query, including sub-queries and execution strategy.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.QueryType¶
-
Types of queries for branched RAG routing.
- FACTUAL¶
Factual information queries.
- ANALYTICAL¶
Analysis and reasoning queries.
- CREATIVE¶
Creative and ideation queries.
- PROCEDURAL¶
Step-by-step procedure queries.
Initialize self. See help(type(self)) for accurate signature.
- class haive.agents.rag.models.RAGModuleType¶
-
Types of RAG modules for modular composition.
- QUERY_EXPANSION¶
Query expansion and refinement module.
- DOCUMENT_FILTERING¶
Document relevance filtering module.
- CONTEXT_RANKING¶
Context relevance ranking module.
- ANSWER_GENERATION¶
Answer generation module.
- ANSWER_VERIFICATION¶
Answer quality verification module.
- RESPONSE_SYNTHESIS¶
Final response synthesis module.
Initialize self. See help(type(self)) for accurate signature.
- class haive.agents.rag.models.ReActStep¶
-
ReAct pattern step types.
- THOUGHT¶
Reasoning and planning step.
- ACTION¶
Action execution step.
- OBSERVATION¶
Observation and analysis step.
- REFLECTION¶
Reflection and evaluation step.
Initialize self. See help(type(self)) for accurate signature.
- class haive.agents.rag.models.ReActStepResult(/, **data)¶
Bases:
pydantic.BaseModelResult from a single ReAct pattern step.
Contains the output and metadata from executing a step in the ReAct (Reasoning + Acting) pattern.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.SpeculativeResult(/, **data)¶
Bases:
pydantic.BaseModelSpeculative reasoning result with hypothesis verification.
Contains hypotheses generated and verified during speculative RAG, where multiple potential answers are explored and validated.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.StepBackResult(/, **data)¶
Bases:
pydantic.BaseModelStep-back reasoning result for abstract thinking.
Contains results from step-back prompting where the agent first reasons about high-level concepts before specific answers.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.StrategyDecision(/, **data)¶
Bases:
pydantic.BaseModelStrategy selection decision for agentic routing.
Contains the decision made by an agentic router about which RAG strategy to use for a given query.
- Parameters:
data (Any)
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.
- class haive.agents.rag.models.SubQueryResult(/, **data)¶
Bases:
pydantic.BaseModelResult from executing a single sub-query.
Contains the result of executing one sub-query in a query planning pipeline.
- Parameters:
data (Any)
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.