Module: Insika::Compaction::SummarizerFactory
- Defined in:
- lib/insika/compaction.rb
Overview
Resolves WHICH model summarizes and builds the ask. compaction.model ->
platform utility_model -> nil (nil means "feature inert", never a guess —
the DistillerFactory ladder). NOT the fallbacks chain: that one answers
"which model serves the customer turn". ask_factory/llm injectable (specs).
Class Method Summary collapse
-
.build(config, utility_model: nil, ask_factory: nil, llm: nil) ⇒ Object
config: the Settings "compaction" hash.
-
.ruby_llm_ask(model, provider, llm: nil) ⇒ Object
Temperature 0: the same slice must compact to the same boundary deterministically.
-
.split_ref(ref) ⇒ Object
"provider/model" -> [provider, model]; "model" -> [nil, model] — one syntax for "which model" across features (DistillerFactory's reading).
Class Method Details
.build(config, utility_model: nil, ask_factory: nil, llm: nil) ⇒ Object
config: the Settings "compaction" hash. -> Summarizer | nil
167 168 169 170 171 172 173 174 |
# File 'lib/insika/compaction.rb', line 167 def build(config, utility_model: nil, ask_factory: nil, llm: nil) ref = Coercion.presence(config && config["model"]) || Coercion.presence(utility_model) return nil if ref.nil? provider, model = split_ref(ref) factory = ask_factory || ->(m, p) { ruby_llm_ask(m, p, llm: llm) } Summarizer.new(ask: factory.call(model, provider), model: ref) end |
.ruby_llm_ask(model, provider, llm: nil) ⇒ Object
Temperature 0: the same slice must compact to the same boundary
deterministically. ruby_llm is required lazily so nothing loads a
provider gem until compaction is actually configured (load_guard stays green).
186 187 188 189 190 191 192 193 |
# File 'lib/insika/compaction.rb', line 186 def ruby_llm_ask(model, provider, llm: nil) require "ruby_llm" llm ||= RubyLLM lambda do |prompt| llm.chat(model: model, provider: provider, assume_model_exists: true) .with_temperature(0).ask(prompt) end end |
.split_ref(ref) ⇒ Object
"provider/model" -> [provider, model]; "model" -> [nil, model] — one syntax for "which model" across features (DistillerFactory's reading).
178 179 180 181 |
# File 'lib/insika/compaction.rb', line 178 def split_ref(ref) prov, name = ref.to_s.split("/", 2) name ? [prov, name] : [nil, prov] end |