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/config.yml)

  • 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/config.yml)

defaults:
  ruby_llm:
    anthropic_api_key: <%= ENV['ANTHROPIC_API_KEY'] %>

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerLogger

Returns the logger instance.

Returns:

  • (Logger)

    the configured logger or default



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

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.



54
55
56
57
# File 'lib/robot_lab/config.rb', line 54

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.



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/robot_lab/config.rb', line 63

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