Deterministic local LM for examples, tests, and offline workflows.
Implements the Imp.LM behaviour by calling a supplied handler instead of a
provider, so program structure can be exercised offline.
Options, given to new/1 or per call, and merged with the per-call options
winning:
:handler— a two-argument function(messages, opts)returning the LM output. Defaults to a handler that keys off the prompt text. A handler that is not a two-argument function raisesArgumentError.:n— number of completions.1, the default, returns one output; an integer above 1 calls the handler that many times and returns a list. Any other value raisesArgumentError.
new/1 also takes :model, a name for the model this client stands in
for. It is each request's model unless the call names another, the handler
sees it as :model in its options, and trainers read it as the model they
train.
Summary
Functions
Calls the handler. lm is a struct from new/1, whose options the call's
options override, or the module itself, which has none of its own.
Builds a configured static LM struct.
lm = Imp.LM.Static.new(handler: fn _messages, _opts -> %{answer: "ok"} end)
Imp.configure(lm: lm)