Class: LumenLLM::Runner
- Inherits:
-
Object
- Object
- LumenLLM::Runner
- Defined in:
- lib/lumen_llm/runner.rb
Instance Method Summary collapse
-
#initialize(template:, input:, store: nil, provider_registry: nil) ⇒ Runner
constructor
A new instance of Runner.
- #run(force: false) ⇒ Object
Constructor Details
#initialize(template:, input:, store: nil, provider_registry: nil) ⇒ Runner
Returns a new instance of Runner.
6 7 8 9 10 11 |
# File 'lib/lumen_llm/runner.rb', line 6 def initialize(template:, input:, store: nil, provider_registry: nil) @template = template @input = input @store = store || LumenLLM.configuration.store || Stores::NullStore.new @provider_registry = provider_registry || LumenLLM.configuration.provider_registry || LumenLLM.provider_registry end |
Instance Method Details
#run(force: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lumen_llm/runner.rb', line 13 def run(force: false) cache_key = "lumen:#{@template.key}:#{Digest::SHA1.hexdigest(@input.to_json)}" raw = if force log("[LumenLLM::Runner] FORCE REFRESH: #{cache_key}") generate else @store.cache(cache_key, :ttl => LumenLLM.configuration.cache_ttl) { generate } end Parser.extract( provider: @template.provider, raw: raw, output_type: @template.output_type ) end |