Class: LumenLLM::TemplateLoader
- Inherits:
-
Object
- Object
- LumenLLM::TemplateLoader
- Defined in:
- lib/lumen_llm/template_loader.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ TemplateLoader
constructor
A new instance of TemplateLoader.
- #load(key) ⇒ Object
Constructor Details
#initialize(path) ⇒ TemplateLoader
Returns a new instance of TemplateLoader.
9 10 11 |
# File 'lib/lumen_llm/template_loader.rb', line 9 def initialize(path) @path = path end |
Class Method Details
.load(key, path: nil) ⇒ Object
5 6 7 |
# File 'lib/lumen_llm/template_loader.rb', line 5 def self.load(key, path: nil) new(path || LumenLLM.configuration.template_path).load(key) end |
Instance Method Details
#load(key) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lumen_llm/template_loader.rb', line 13 def load(key) raise ConfigurationError, "template_path is not configured" if blank?(@path) template_file = File.join(@path.to_s, "#{key}.yml") raise TemplateNotFoundError, "Template not found: #{key}" unless File.exist?(template_file) config = YAML.load_file(template_file) Template.new( key: config["key"] || key, system_prompt: config["system_prompt"], user_prompt: config["user_prompt"], model: config["model"], provider: config["provider"] || "openrouter", output_type: config["output_type"] || "text" ) end |