Module: Insika::Distill::DistillerFactory

Defined in:
lib/insika/distill.rb

Overview

Resolves WHICH model distills, and builds the ask. Profile -> platform utility_model -> nil (D4 — nil means "feature inert", never a guess). ask_factory/llm injectable (specs).

Class Method Summary collapse

Class Method Details

.build(config, utility_model: nil, ask_factory: nil, llm: nil) ⇒ Object

config: the agent's distill hash. -> Distiller | nil



195
196
197
198
199
200
201
202
# File 'lib/insika/distill.rb', line 195

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) }
  Distiller.new(ask: factory.call(model, provider), model: ref)
end

.ruby_llm_ask(model, provider, llm: nil) ⇒ Object

Temperature 0: a rejected fact must be re-proposable deterministically. ruby_llm is required lazily so nothing loads a provider gem until a distiller is actually configured (load_guard stays green).



214
215
216
217
218
219
220
221
# File 'lib/insika/distill.rb', line 214

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] — the ProposerFactory reading, one syntax for "which model" across features.



206
207
208
209
# File 'lib/insika/distill.rb', line 206

def split_ref(ref)
  prov, name = ref.to_s.split("/", 2)
  name ? [prov, name] : [nil, prov]
end