orka.agents.validation_and_structuring_agent module

Validation and Structuring Agent

This module provides the ValidationAndStructuringAgent class, which is responsible for validating answers and structuring them into a memory format. The agent ensures answers are correct and contextually coherent, then extracts key information into a structured memory object.

Classes

ValidationAndStructuringAgent

Agent that validates answers and structures them into memory objects.

class orka.agents.validation_and_structuring_agent.ValidationAndStructuringAgent(params: Dict[str, Any] = None)[source]

Bases: BaseAgent

Agent that validates answers and structures them into memory objects.

This agent performs two main functions: 1. Validates if an answer is correct and contextually coherent 2. Structures valid answers into a memory object format

The agent uses an LLM (Language Model) to perform validation and structuring. It returns a dictionary containing: - valid: Boolean indicating if the answer is valid - reason: Explanation of the validation decision - memory_object: Structured memory object if valid, None otherwise

Parameters

paramsDict[str, Any], optional

Configuration parameters for the agent, including: - prompt: The base prompt for the LLM - queue: Optional queue for async operations - agent_id: Unique identifier for the agent - store_structure: Optional template for memory object structure

Attributes

llm_agentOpenAIAnswerBuilder

The LLM agent used for validation and structuring

__init__(params: Dict[str, Any] = None)[source]

Initialize the agent with an OpenAIAnswerBuilder for LLM calls.

run(input_data: Dict[str, Any]) Dict[str, Any][source]

Process the input data to validate and structure the answer.

Parameters:

input_data – Dictionary containing: - question: The original question - full_context: The context used to generate the answer - latest_answer: The answer to validate and structure - store_structure: Optional structure template for memory objects

Returns:

  • valid: Boolean indicating if the answer is valid

  • reason: Explanation of validation decision

  • memory_object: Structured memory object if valid, None otherwise

Return type:

Dictionary containing

build_prompt(question: str, context: str, answer: str, store_structure: str | None = None) str[source]

Build the prompt for the validation and structuring task.

Parameters:
  • question – The original question

  • context – The context used to generate the answer

  • answer – The answer to validate and structure

  • store_structure – Optional structure template for memory objects

Returns:

The complete prompt for the LLM