Class: SkillBench::Models::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/models/config.rb

Overview

Represents the skill-bench configuration loaded from skill-bench.json

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Config

Returns a new instance of Config.

Parameters:

  • data (Hash) (defaults to: {})

    Raw configuration data

Raises:

  • (ArgumentError)

    if data is not a Hash



12
13
14
15
16
# File 'lib/skill_bench/models/config.rb', line 12

def initialize(data = {})
  raise ArgumentError, 'Config-data must be a Hash' unless data.is_a?(Hash)

  @data = data
end

Class Method Details

.load(path = 'skill-bench.json') ⇒ SkillBench::Models::Config

Load configuration from a JSON file

Parameters:

  • path (String) (defaults to: 'skill-bench.json')

    Path to config file (default: skill-bench.json)

Returns:

Raises:

  • (Errno::ENOENT)

    if config file not found



22
23
24
25
# File 'lib/skill_bench/models/config.rb', line 22

def self.load(path = 'skill-bench.json')
  raw_data = JSON.parse(File.read(path), symbolize_names: true)
  new(raw_data)
end

Instance Method Details

#max_execution_timeInteger

Returns max execution time

Returns:

  • (Integer)

    Max execution time in seconds



41
42
43
# File 'lib/skill_bench/models/config.rb', line 41

def max_execution_time
  @data[:max_execution_time] || 30
end

#provider_configHash

Returns the provider configuration

Returns:

  • (Hash)

    Provider configuration



35
36
37
# File 'lib/skill_bench/models/config.rb', line 35

def provider_config
  @data[:config] || {}
end

#provider_nameString?

Returns the configured provider name

Returns:

  • (String, nil)

    Provider name



29
30
31
# File 'lib/skill_bench/models/config.rb', line 29

def provider_name
  @data[:provider]
end

#to_providerSkillBench::Models::Provider

Builds a Provider model from the current configuration. Returns a mock provider if provider name is ‘mock’.

Returns:



49
50
51
52
53
54
55
56
57
58
# File 'lib/skill_bench/models/config.rb', line 49

def to_provider
  return nil if provider_name.nil? || provider_name == 'mock'

  Provider.new(
    name: provider_name,
    runtime: provider_name,
    llm: provider_name,
    config: provider_config
  )
end