agents.rag.self_reflective.agent¶
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¶
Result of answer improvement iteration. |
|
Structured critique from reflection. |
|
Plan for iterative improvement based on reflection. |
|
Types of reflection analysis. |
|
Self-Reflective RAG agent with iterative improvement capabilities. |
|
Complete result from self-reflective RAG process. |
Functions¶
|
Create a Self-Reflective RAG agent. |
Get I/O schema for Self-Reflective RAG agents. |
Module Contents¶
- class agents.rag.self_reflective.agent.ImprovedAnswer(/, **data)¶
Bases:
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.
- Parameters:
data (Any)
- class agents.rag.self_reflective.agent.ReflectionCritique(/, **data)¶
Bases:
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.
- Parameters:
data (Any)
- class agents.rag.self_reflective.agent.ReflectionPlan(/, **data)¶
Bases:
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.
- Parameters:
data (Any)
- class agents.rag.self_reflective.agent.ReflectionType¶
-
Types of reflection analysis.
Initialize self. See help(type(self)) for accurate signature.
- class agents.rag.self_reflective.agent.SelfReflectiveRAGAgent¶
Bases:
haive.agents.base.agent.Agent
Self-Reflective RAG agent with iterative improvement capabilities.
This agent uses conditional edges to iterate through reflection loops.
- build_graph()¶
Build the self-reflective graph with conditional edges.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- classmethod from_documents(documents, llm_config=None, max_iterations=3, quality_threshold=0.85, **kwargs)¶
Create Self-Reflective RAG agent from documents.
- Parameters:
documents (list[langchain_core.documents.Document]) – Documents to index for retrieval
llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration
max_iterations (int) – Maximum reflection iterations
quality_threshold (float) – Quality threshold to stop iterating
**kwargs – Additional arguments
- Returns:
SelfReflectiveRAGAgent instance
- generate_initial_answer(state)¶
Generate initial answer.
- improve_answer(state)¶
Improve the answer based on reflection.
- reflect_and_critique(state)¶
Generate critiques and plan improvements.
- setup_agent()¶
Initialize engines.
- Return type:
None
- should_continue_improving(state)¶
Determine if improvement should continue.
- class agents.rag.self_reflective.agent.SelfReflectiveResult(/, **data)¶
Bases:
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.
- Parameters:
data (Any)
- agents.rag.self_reflective.agent.create_self_reflective_rag_agent(documents, llm_config=None, reflection_mode='thorough', **kwargs)¶
Create a Self-Reflective RAG agent.
- Parameters:
- Returns:
Configured Self-Reflective RAG agent
- Return type: