Class: RobotLab::Config

Inherits:
MywayConfig::Base
  • Object
show all
Defined in:
lib/robot_lab/config.rb

Overview

Modern configuration class using MywayConfig for RobotLab.

Provides:

  • Nested configuration with a dedicated ruby_llm: section
  • Environment-specific settings (development, test, production)
  • XDG config file loading (~/.config/robot_lab/robot_lab.yml — the filename repeats the config_name; config.yml is never read)
  • Environment variable overrides (ROBOT_LAB_*)
  • Automatic RubyLLM configuration application

Examples:

Access configuration values

RobotLab.config.ruby_llm.model            #=> "claude-sonnet-4"
RobotLab.config.ruby_llm.request_timeout  #=> 120
RobotLab.config.development?              #=> true

Override via environment variables

# ROBOT_LAB_RUBY_LLM__MODEL=gpt-4
# ROBOT_LAB_RUBY_LLM__ANTHROPIC_API_KEY=sk-ant-...

User config file (~/.config/robot_lab/robot_lab.yml)

# Flat keys, or a section named for the current environment. A `defaults:`
# wrapper is IGNORED here — it applies only to the gem's bundled
# defaults.yml. This file is NOT run through ERB, so keep secrets in
# environment variables or in ./config/robot_lab.yml (which is).
ruby_llm:
  model: claude-sonnet-4
  request_timeout: 120

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerLogger

Returns the logger instance.

Returns:

  • (Logger)

    the configured logger or default



42
# File 'lib/robot_lab/config.rb', line 42

attr_writer :logger

Instance Method Details

#after_loadvoid

This method returns an undefined value.

Apply RubyLLM configuration after loading.

This method should be called after initialization to configure the RubyLLM gem with the values from the ruby_llm section, and to set up the template library.



58
59
60
61
# File 'lib/robot_lab/config.rb', line 58

def after_load
  apply_ruby_llm_config!
  apply_prompt_manager!
end

#apply_ruby_llm_config!void

This method returns an undefined value.

Apply all RubyLLM settings from the ruby_llm configuration section.



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/robot_lab/config.rb', line 66

def apply_ruby_llm_config!
  return unless ruby_llm

  RubyLLM.configure do |c|
    apply_provider_api_keys(c)
    apply_provider_endpoints(c)
    apply_openai_options(c)
    apply_default_models(c)
    apply_connection_settings(c)
    apply_logging_options(c)
  end
end