orka.loader module

YAML Configuration Loader

The YAML Loader is responsible for loading, parsing, and validating configuration files for OrKa workflows. It serves as the bridge between the declarative YAML specifications and the runtime orchestration system.

Configuration Structure

OrKa configuration files consist of two main sections:

Orchestrator Section

Global settings for the orchestration engine:

  • id - Unique identifier for the workflow

  • strategy - Execution strategy (e.g., sequential, parallel)

  • queue - Initial execution queue for agents

  • agents - List of agent IDs in execution order

Agents Section

List of agent definitions, each containing:

  • id - Unique identifier for the agent

  • type - Agent type (e.g., llm, search, memory)

  • prompt - Template string for agent input

  • config - Type-specific configuration options

  • Additional agent-specific fields

Example Configuration

orchestrator:
  id: knowledge_qa
  strategy: sequential
  queue: orka:knowledge_qa
  agents: [retriever, answerer]

agents:
  - id: retriever
    type: memory
    config:
      operation: read
    namespace: knowledge_base
    prompt: "Retrieve information about {{ input }}"

  - id: answerer
    type: openai-answer
    prompt: "Answer the question based on this context: {{ previous_outputs.retriever }}"

Validation Features

The YAMLLoader validates configuration to ensure:

  • All required sections are present

  • Data types are correct

  • Agent references are valid

  • Template syntax is properly formatted

This validation happens before the Orchestrator initializes the workflow, preventing runtime errors from malformed configurations.

Usage Example

from orka.loader import YAMLLoader

# Load and validate configuration
loader = YAMLLoader("workflow.yml")
loader.validate()

# Access configuration sections
orchestrator_config = loader.get_orchestrator()
agents_config = loader.get_agents()
class orka.loader.YAMLLoader(path: str)[source]

Bases: object

A loader for YAML configuration files. Loads and validates the configuration for the OrKa orchestrator.

__init__(path: str) None[source]

Initialize the YAML loader with the path to the configuration file.

Parameters:

path – Path to the YAML configuration file.

get_orchestrator() Dict[str, Any][source]

Get the orchestrator configuration section.

Returns:

The orchestrator configuration.

get_agents() List[Dict[str, Any]][source]

Get the agents configuration section.

Returns:

The list of agent configurations.

validate() bool[source]

Validate the configuration file. Checks for required sections and correct data types.

Returns:

True if the configuration is valid.

Raises:

ValueError – If the configuration is invalid.