haive.agents.rag.agentic.agent ============================== .. py:module:: haive.agents.rag.agentic.agent .. autoapi-nested-parse:: Agentic RAG Agent - ReAct + Retrieval with Proper Haive Patterns. This implementation follows the LangChain/LangGraph agentic RAG tutorial but uses proper Haive base agent infrastructure: - Inherits from ReActAgent for reasoning/acting patterns - Uses ToolRouteMixin for automatic tool routing - Proper Pydantic patterns (no __init__, model validators) - Generic type safety with bounds - Multiple engines (LLM + Retriever + Grader) Classes ------- .. autoapisummary:: haive.agents.rag.agentic.agent.AgenticRAGAgent haive.agents.rag.agentic.agent.AgenticRAGState haive.agents.rag.agentic.agent.DocumentGrade haive.agents.rag.agentic.agent.QueryRewrite Functions --------- .. autoapisummary:: haive.agents.rag.agentic.agent.create_agentic_rag_agent haive.agents.rag.agentic.agent.create_memory_aware_agentic_rag Module Contents --------------- .. py:class:: AgenticRAGAgent(/, **data) Bases: :py:obj:`haive.agents.react.agent.ReactAgent`, :py:obj:`haive.core.common.mixins.tool_route_mixin.ToolRouteMixin` Agentic RAG agent combining ReAct reasoning with intelligent retrieval. This agent can: - Decide when to retrieve vs respond directly (agentic behavior) - Grade retrieved documents for relevance - Rewrite queries when documents are not relevant - Loop until relevant documents are found or max attempts reached Key features: - Proper Pydantic patterns (no __init__) - Multiple engines with proper typing - Automatic tool routing via ToolRouteMixin - Generic type safety 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:method:: from_documents(documents, llm_config, embedding_config = None, **kwargs) :classmethod: Create agentic RAG agent from documents using proper factory pattern. This follows Pydantic best practices by using a classmethod factory instead of complex __init__ logic. .. py:method:: model_post_init(__context) Set state schema after init. .. py:method:: setup_agent() Setup agentic RAG with multiple engines and tools. .. py:class:: AgenticRAGState(/, **data) Bases: :py:obj:`pydantic.BaseModel` State schema for agentic RAG with retrieval metadata. 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:: DocumentGrade(/, **data) Bases: :py:obj:`pydantic.BaseModel` Grade for document relevance. 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:: QueryRewrite(/, **data) Bases: :py:obj:`pydantic.BaseModel` Rewritten query for better retrieval. 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:function:: create_agentic_rag_agent(documents, llm_config, embedding_config = None, **kwargs) Create agentic RAG agent with sensible defaults. .. py:function:: create_memory_aware_agentic_rag(documents, llm_config, memory_config = None, **kwargs) Create agentic RAG with long-term memory capabilities.