Class: Rubino::LLM::ScenarioLoader
- Inherits:
-
Object
- Object
- Rubino::LLM::ScenarioLoader
- 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.("scenarios", __dir__)
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(scenarios_dir: nil) ⇒ ScenarioLoader
constructor
A new instance of ScenarioLoader.
-
#load(name) ⇒ Object
Returns the array of event hashes under the YAML ‘events:` key.
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.
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, (name) unless path data = YAML.safe_load_file(path, permitted_classes: [Symbol], aliases: true) || {} Array(data["events"] || data[:events]) end |