Class: Rubino::LLM::ScenarioLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/llm/scenario_loader.rb

Overview

Loads a fake-provider scenario YAML by name and returns the parsed event list. The fake provider drives a deterministic chunk/tool-call stream from these events so the UI and tool plumbing can be exercised without burning provider tokens.

Search order:

1. <Rubino.configuration.fake_scenarios_dir>/<name>.yml
2. <gem_root>/lib/rubino/llm/scenarios/<name>.yml

The YAML file must contain a top-level ‘events:` key with an array of event hashes — see scenarios/happy-path.yml for the shape.

Defined Under Namespace

Classes: NotFound

Constant Summary collapse

DEFAULT_DIR =
File.expand_path("scenarios", __dir__)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenarios_dir: nil) ⇒ ScenarioLoader

Returns a new instance of ScenarioLoader.



27
28
29
# File 'lib/rubino/llm/scenario_loader.rb', line 27

def initialize(scenarios_dir: nil)
  @scenarios_dir = scenarios_dir || configured_dir
end

Class Method Details

.load(name, scenarios_dir: nil) ⇒ Object



23
24
25
# File 'lib/rubino/llm/scenario_loader.rb', line 23

def self.load(name, scenarios_dir: nil)
  new(scenarios_dir: scenarios_dir).load(name)
end

Instance Method Details

#load(name) ⇒ Object

Returns the array of event hashes under the YAML ‘events:` key. Raises NotFound when the scenario can’t be located under either path, citing both so the operator can fix the misconfiguration.

Raises:



34
35
36
37
38
39
40
# File 'lib/rubino/llm/scenario_loader.rb', line 34

def load(name)
  path = resolve_path(name)
  raise NotFound, build_not_found_message(name) unless path

  data = YAML.safe_load_file(path, permitted_classes: [Symbol], aliases: true) || {}
  Array(data["events"] || data[:events])
end