haive.agents.rag.self_reflective.agent ====================================== .. py:module:: haive.agents.rag.self_reflective.agent .. autoapi-nested-parse:: Self-Reflective Agentic RAG Agent. from typing import Any Implementation of self-reflective RAG with critique and iterative improvement. Uses reflection loops to assess and enhance answer quality. Classes ------- .. autoapisummary:: haive.agents.rag.self_reflective.agent.ImprovedAnswer haive.agents.rag.self_reflective.agent.ReflectionCritique haive.agents.rag.self_reflective.agent.ReflectionPlan haive.agents.rag.self_reflective.agent.ReflectionType haive.agents.rag.self_reflective.agent.SelfReflectiveRAGAgent haive.agents.rag.self_reflective.agent.SelfReflectiveResult Functions --------- .. autoapisummary:: haive.agents.rag.self_reflective.agent.create_self_reflective_rag_agent haive.agents.rag.self_reflective.agent.get_self_reflective_rag_io_schema Module Contents --------------- .. py:class:: ImprovedAnswer(/, **data) Bases: :py:obj:`pydantic.BaseModel` Result of answer improvement iteration. 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:: ReflectionCritique(/, **data) Bases: :py:obj:`pydantic.BaseModel` Structured critique from reflection. 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:: ReflectionPlan(/, **data) Bases: :py:obj:`pydantic.BaseModel` Plan for iterative improvement based on reflection. 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:: ReflectionType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Types of reflection analysis. Initialize self. See help(type(self)) for accurate signature. .. py:class:: SelfReflectiveRAGAgent Bases: :py:obj:`haive.agents.base.agent.Agent` Self-Reflective RAG agent with iterative improvement capabilities. This agent uses conditional edges to iterate through reflection loops. .. py:method:: build_graph() Build the self-reflective graph with conditional edges. .. py:method:: from_documents(documents, llm_config = None, max_iterations = 3, quality_threshold = 0.85, **kwargs) :classmethod: Create Self-Reflective RAG agent from documents. :param documents: Documents to index for retrieval :param llm_config: LLM configuration :param max_iterations: Maximum reflection iterations :param quality_threshold: Quality threshold to stop iterating :param \*\*kwargs: Additional arguments :returns: SelfReflectiveRAGAgent instance .. py:method:: generate_initial_answer(state) Generate initial answer. .. py:method:: improve_answer(state) Improve the answer based on reflection. .. py:method:: reflect_and_critique(state) Generate critiques and plan improvements. .. py:method:: setup_agent() Initialize engines. .. py:method:: should_continue_improving(state) Determine if improvement should continue. .. py:method:: synthesize_result(state) Create final self-reflective result. .. py:class:: SelfReflectiveResult(/, **data) Bases: :py:obj:`pydantic.BaseModel` Complete result from self-reflective RAG process. 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_self_reflective_rag_agent(documents, llm_config = None, reflection_mode = 'thorough', **kwargs) Create a Self-Reflective RAG agent. :param documents: Documents for retrieval :param llm_config: LLM configuration :param reflection_mode: Mode ("quick", "balanced", "thorough") :param \*\*kwargs: Additional arguments :returns: Configured Self-Reflective RAG agent .. py:function:: get_self_reflective_rag_io_schema() Get I/O schema for Self-Reflective RAG agents.