agents.rag.simple.enhanced_v3.answer_generator_agentΒΆ

Specialized Answer Generator Agent for SimpleRAG V3.

This module provides a specialized answer generation agent that extends SimpleAgent with enhanced features for generating answers from retrieved documents.

ClassesΒΆ

SimpleAnswerAgent

Specialized answer generation agent for SimpleRAG V3.

Module ContentsΒΆ

class agents.rag.simple.enhanced_v3.answer_generator_agent.SimpleAnswerAgent(/, **data)ΒΆ

Bases: haive.agents.simple.agent.SimpleAgent

Specialized answer generation agent for SimpleRAG V3.

This agent extends SimpleAgent with RAG-specific features: - Document-aware prompt templates - Context formatting and processing - Source citation and attribution - Answer quality scoring - Enhanced metadata collection

Designed to work as the second agent in Enhanced MultiAgent V3 sequential pattern: RetrieverAgent β†’ SimpleAnswerAgent

The agent expects input from RetrieverAgent containing: - documents: List of retrieved documents - query: Original user query - metadata: Retrieval metadata

Examples

Basic usage:

answer_agent = SimpleAnswerAgent(
    name="answer_generator",
    engine=AugLLMConfig(temperature=0.7),
    max_context_length=4000
)

With structured output:

class QAResponse(BaseModel):
    answer: str
    sources: List[str]
    confidence: float

answer_agent = SimpleAnswerAgent(
    name="structured_answer",
    engine=AugLLMConfig(),
    structured_output_model=QAResponse
)

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)

async arun(input_data, debug=False, **kwargs)ΒΆ

Enhanced answer generation with document processing.

Parameters:
  • input_data (str | dict[str, Any]) – Input from RetrieverAgent or direct query

  • debug (bool) – Enable debug output

  • **kwargs – Additional generation parameters

Returns:

Generated answer (format depends on structured_output_model)

Return type:

dict[str, Any] | str

get_generation_summary()ΒΆ

Get summary of answer generator configuration.

Return type:

dict[str, Any]