Module: RobotLab::Robot::TemplateRendering

Included in:
RobotLab::Robot
Defined in:
lib/robot_lab/robot/template_rendering.rb

Overview

Template loading, rendering, and front-matter extraction.

Expects the including class to provide:

@chat, @template, @build_context, @name, @name_from_constructor,
@description, @local_tools, @mcp_config

Constant Summary collapse

FRONT_MATTER_CONFIG_KEYS =

Front matter keys that map to chat configuration methods

%i[
  model temperature top_p top_k max_tokens
  presence_penalty frequency_penalty stop
].freeze
FRONT_MATTER_EXTRA_KEYS =

Front matter keys for robot identity and capabilities. Note: uses ‘robot_name` because PM::Metadata reserves `name` for the filename.

%i[tools mcp robot_name description skills].freeze

Instance Method Summary collapse

Instance Method Details

#with_template(template_id, **context) ⇒ self

Apply a prompt_manager template to the robot’s chat

Parameters:

  • template_id (Symbol, String)

    the template identifier

  • context (Hash)

    variables to pass to the template

Returns:

  • (self)


28
29
30
31
32
33
# File 'lib/robot_lab/robot/template_rendering.rb', line 28

def with_template(template_id, **context)
  @template = template_id.to_sym
  @build_context = context
  apply_template_to_chat(context)
  self
end