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 agents.rag.models.BranchResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Result 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 agents.rag.models.EnhancedResponse(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Enhanced 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 agents.rag.models.FusionResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Fusion 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 agents.rag.models.HyDEResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Hypothetical 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 agents.rag.models.MemoryAnalysis(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Memory 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 agents.rag.models.MemoryEntry(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Memory 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 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 agents.rag.models.MergedResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Final 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 agents.rag.models.QueryClassification(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Query 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 agents.rag.models.QueryPlan(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Query 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 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 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 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 agents.rag.models.ReActStepResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Result 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 agents.rag.models.SpeculativeResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Speculative 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 agents.rag.models.StepBackResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Step-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 agents.rag.models.StrategyDecision(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Strategy 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 agents.rag.models.SubQueryResult(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Result 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.