Class: SkillBench::Migration::ProviderMigrator

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/migration/provider_migrator.rb

Overview

Migrates old provider classes to new YAML-based configuration

Class Method Summary collapse

Class Method Details

.migrate(providers, yaml_path = '.agent-eval.yml') ⇒ Object

Migrate providers to YAML config file

Parameters:

  • providers (Hash)

    Providers to migrate (name => config hash)

  • yaml_path (String) (defaults to: '.agent-eval.yml')

    Path to YAML config file (default: .agent-eval.yml)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/skill_bench/migration/provider_migrator.rb', line 13

def self.migrate(providers, yaml_path = '.agent-eval.yml')
  existing = if File.exist?(yaml_path)
               YAML.safe_load_file(yaml_path, permitted_classes: [], aliases: false) || {}
             else
               {}
             end

  existing['providers'] ||= {}

  providers.each do |name, config|
    existing['providers'][name.to_s] = config.transform_keys(&:to_s)
  end

  File.write(yaml_path, existing.to_yaml)
end