haive.agents.rag.models ======================= .. py:module:: haive.agents.rag.models .. autoapi-nested-parse:: 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. .. rubric:: 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 ------- .. autoapisummary:: haive.agents.rag.models.BranchResult haive.agents.rag.models.EnhancedResponse haive.agents.rag.models.FusionResult haive.agents.rag.models.HyDEResult haive.agents.rag.models.MemoryAnalysis haive.agents.rag.models.MemoryEntry haive.agents.rag.models.MemoryType haive.agents.rag.models.MergedResult haive.agents.rag.models.QueryClassification haive.agents.rag.models.QueryPlan haive.agents.rag.models.QueryType haive.agents.rag.models.RAGModuleType haive.agents.rag.models.ReActStep haive.agents.rag.models.ReActStepResult haive.agents.rag.models.SpeculativeResult haive.agents.rag.models.StepBackResult haive.agents.rag.models.StrategyDecision haive.agents.rag.models.SubQueryResult Module Contents --------------- .. py:class:: BranchResult(/, **data) Bases: :py:obj:`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. .. attribute:: branch_type Type of branch executed. :type: str .. attribute:: retrieved_docs Documents retrieved by this branch. :type: List[str] .. attribute:: branch_answer Answer generated by this branch. :type: str .. attribute:: relevance_score Relevance score for this branch (0.0 to 1.0). :type: float 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. .. py:class:: EnhancedResponse(/, **data) Bases: :py:obj:`pydantic.BaseModel` Enhanced response with reasoning and memory integration. Contains a comprehensive response that includes the main answer, reasoning chain, memory context, and metadata. .. attribute:: answer Main answer to the query. :type: str .. attribute:: reasoning_chain ReAct reasoning steps taken. :type: List[ReActStepResult] .. attribute:: memory_used Memories used in generating response. :type: List[MemoryEntry] .. attribute:: new_memories New memories to store from this interaction. :type: List[MemoryEntry] .. attribute:: confidence Response confidence (0.0 to 1.0). :type: float 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. .. py:class:: FusionResult(/, **data) Bases: :py:obj:`pydantic.BaseModel` Fusion ranking result from multi-query RAG. Contains documents ranked using reciprocal rank fusion or similar techniques for combining multiple retrieval results. .. attribute:: fused_documents Documents ranked by fusion algorithm. :type: List[str] .. attribute:: fusion_scores Corresponding fusion scores. :type: List[float] .. attribute:: ranking_method Method used for ranking (e.g., "reciprocal_rank_fusion"). :type: str 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. .. py:class:: HyDEResult(/, **data) Bases: :py:obj:`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. .. attribute:: hypothetical_doc Generated hypothetical document that would answer the query. :type: str .. attribute:: refined_query Query refined based on the hypothetical document. :type: str .. attribute:: confidence Confidence score in the hypothesis (0.0 to 1.0). :type: float 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. .. py:class:: MemoryAnalysis(/, **data) Bases: :py:obj:`pydantic.BaseModel` Memory analysis result for context-aware processing. Contains analysis of relevant memories and identified knowledge gaps for enhanced context-aware response generation. .. attribute:: relevant_memories Relevant memories found. :type: List[MemoryEntry] .. attribute:: memory_gaps Identified knowledge gaps. :type: List[str] .. attribute:: temporal_context Temporal context of memories. :type: str .. attribute:: confidence Overall memory confidence (0.0 to 1.0). :type: float 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. .. py:class:: MemoryEntry(/, **data) Bases: :py:obj:`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. .. attribute:: content Memory content or summary. :type: str .. attribute:: memory_type Type of memory (short-term, long-term, etc.). :type: MemoryType .. attribute:: timestamp When this memory was created. :type: str .. attribute:: relevance_score Relevance to current query (0.0 to 1.0). :type: float .. attribute:: context_tags Tags for categorizing memory content. :type: List[str] 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. .. py:class:: MemoryType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Types of memory for memory-aware RAG. .. attribute:: SHORT_TERM Short-term conversational memory. .. attribute:: LONG_TERM Long-term knowledge memory. .. attribute:: EPISODIC Episodic interaction memory. .. attribute:: SEMANTIC Semantic knowledge memory. Initialize self. See help(type(self)) for accurate signature. .. py:class:: MergedResult(/, **data) Bases: :py:obj:`pydantic.BaseModel` Final merged result from multiple branches or strategies. Contains the final synthesized result after combining outputs from multiple RAG branches or strategies. .. attribute:: primary_answer Primary synthesized answer. :type: str .. attribute:: supporting_evidence Supporting evidence from branches. :type: List[str] .. attribute:: confidence_score Overall confidence (0.0 to 1.0). :type: float .. attribute:: sources_used Sources used in the final answer. :type: List[str] 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. .. py:class:: QueryClassification(/, **data) Bases: :py:obj:`pydantic.BaseModel` Query classification result for routing decisions. Contains classification results used for routing queries to appropriate RAG strategies or processing branches. .. attribute:: primary_type Primary query type. :type: QueryType .. attribute:: secondary_type Secondary type if applicable. :type: Optional[QueryType] .. attribute:: complexity Query complexity level. :type: str .. attribute:: confidence Classification confidence (0.0 to 1.0). :type: float 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. .. py:class:: QueryPlan(/, **data) Bases: :py:obj:`pydantic.BaseModel` Query planning result for complex query decomposition. Contains a plan for executing a complex query, including sub-queries and execution strategy. .. attribute:: sub_queries Sub-queries to execute. :type: List[str] .. attribute:: execution_strategy How to execute them. :type: str .. attribute:: synthesis_approach How to combine results. :type: str 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. .. py:class:: QueryType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Types of queries for branched RAG routing. .. attribute:: FACTUAL Factual information queries. .. attribute:: ANALYTICAL Analysis and reasoning queries. .. attribute:: CREATIVE Creative and ideation queries. .. attribute:: PROCEDURAL Step-by-step procedure queries. Initialize self. See help(type(self)) for accurate signature. .. py:class:: RAGModuleType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Types of RAG modules for modular composition. .. attribute:: QUERY_EXPANSION Query expansion and refinement module. .. attribute:: DOCUMENT_FILTERING Document relevance filtering module. .. attribute:: CONTEXT_RANKING Context relevance ranking module. .. attribute:: ANSWER_GENERATION Answer generation module. .. attribute:: ANSWER_VERIFICATION Answer quality verification module. .. attribute:: RESPONSE_SYNTHESIS Final response synthesis module. Initialize self. See help(type(self)) for accurate signature. .. py:class:: ReActStep Bases: :py:obj:`str`, :py:obj:`enum.Enum` ReAct pattern step types. .. attribute:: THOUGHT Reasoning and planning step. .. attribute:: ACTION Action execution step. .. attribute:: OBSERVATION Observation and analysis step. .. attribute:: REFLECTION Reflection and evaluation step. Initialize self. See help(type(self)) for accurate signature. .. py:class:: ReActStepResult(/, **data) Bases: :py:obj:`pydantic.BaseModel` Result from a single ReAct pattern step. Contains the output and metadata from executing a step in the ReAct (Reasoning + Acting) pattern. .. attribute:: step_type Type of step executed. :type: ReActStep .. attribute:: content Content or result of the step. :type: str .. attribute:: confidence Confidence in this step (0.0 to 1.0). :type: float .. attribute:: next_action Next action to take, if any. :type: Optional[str] 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. .. py:class:: SpeculativeResult(/, **data) Bases: :py:obj:`pydantic.BaseModel` Speculative reasoning result with hypothesis verification. Contains hypotheses generated and verified during speculative RAG, where multiple potential answers are explored and validated. .. attribute:: hypotheses Generated hypotheses for the query. :type: List[str] .. attribute:: verified_hypotheses Hypotheses verified against evidence. :type: List[str] .. attribute:: final_answer Answer based on verified hypotheses. :type: str 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. .. py:class:: StepBackResult(/, **data) Bases: :py:obj:`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. .. attribute:: abstract_question High-level abstract question derived from the query. :type: str .. attribute:: abstract_answer Answer to the abstract question. :type: str .. attribute:: specific_answer Specific answer to the original query. :type: str 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. .. py:class:: StrategyDecision(/, **data) Bases: :py:obj:`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. .. attribute:: strategy Selected RAG strategy name. :type: str .. attribute:: confidence Confidence in strategy selection (0.0 to 1.0). :type: float .. attribute:: reasoning Explanation for why this strategy was chosen. :type: str 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. .. py:class:: SubQueryResult(/, **data) Bases: :py:obj:`pydantic.BaseModel` Result from executing a single sub-query. Contains the result of executing one sub-query in a query planning pipeline. .. attribute:: query The sub-query that was executed. :type: str .. attribute:: answer Answer to the sub-query. :type: str .. attribute:: confidence Confidence in this result (0.0 to 1.0). :type: float 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.