ClikaRT::runtime::FunctionModel
class
Header: ClikaRT/runtime/function_model.h
Inherits: ClikaRT::runtime::Model
ClikaRT::runtime::FunctionModel: a ready-made Model you build from a schema and lambdas, so a simple pipeline node needs no subclass. Declare each phase with on_run_once / on_iterate; the runtime drives the model through the base Model seam and FunctionModel dispatches the phase to your callable. The callables run caller-side and MAY raise ClikaRT::Error, contained exactly like a hand-written Model override.
runtime::FunctionModel m{schema}; m.on_run_once("run", [](runtime::PhaseContext& ctx) { ctx.outputs->set("y", ctx.inputs->get("x") * 2.0); }); auto pipe = runtime::Pipeline::create({{"node", &m, {}, in_map, out_map}}, schema);
It is header-only and caller-side: its body, and any throw from your callable, is compiled into your translation unit, never the library.
A concrete Model whose phases are served by callables instead of overrides.
Member functions
FunctionModel()
FunctionModel() =default
Declared in ClikaRT/runtime/function_model.h, line 39
FunctionModel(ModelSchema)
explicit FunctionModel(ModelSchema schema)
A model carrying schema whose phases are bound as callbacks.
Declared in ClikaRT/runtime/function_model.h, line 41
FunctionModel(FunctionModel)
FunctionModel(const FunctionModel&) =delete
Declared in ClikaRT/runtime/function_model.h, line 46
operator=(FunctionModel)
FunctionModel& operator=(const FunctionModel&) =delete
Declared in ClikaRT/runtime/function_model.h, line 47
FunctionModel(FunctionModel)
FunctionModel(FunctionModel&&) =default
Declared in ClikaRT/runtime/function_model.h, line 48
operator=(FunctionModel)
FunctionModel& operator=(FunctionModel&&) =default
Declared in ClikaRT/runtime/function_model.h, line 49
set_schema()
FunctionModel& set_schema(ModelSchema schema)
Set / replace the I/O contract.
Declared in ClikaRT/runtime/function_model.h, line 52
on_run_once()
FunctionModel& on_run_once(std::string_view name, std::function<void(PhaseContext &)> fn)
Add a RunOnce phase served by fn (a single pass; e.g. prefill/encode).
Declared in ClikaRT/runtime/function_model.h, line 58
on_iterate()
FunctionModel& on_iterate(std::string_view name, std::function<StepBatchOut(StepContext &)> fn)
Add an Iterate phase served by fn (stepped over the active batch).
Declared in ClikaRT/runtime/function_model.h, line 68
with_state()
FunctionModel& with_state(std::function<ModelState *(Stream)> factory)
Supply a per-session state factory (only for a stateful model).
Declared in ClikaRT/runtime/function_model.h, line 78
schema()
virtual const ModelSchema& schema() const override
the schema given at construction
Declared in ClikaRT/runtime/function_model.h, line 83
phases()
virtual ClikaRT::Span<const PhaseSpec> phases() const override
the phases declared so far
Declared in ClikaRT/runtime/function_model.h, line 84
make_state()
virtual ModelState* make_state(Stream stream) const override
Creates the per-session state the bound with_state factory produces (null factory = stateless).
Declared in ClikaRT/runtime/function_model.h, line 88
Phase_RunOnce()
virtual void Phase_RunOnce(const PhaseSpec& phase, PhaseContext& ctx) override
Dispatches the phase to its bound run-once callback.
Declared in ClikaRT/runtime/function_model.h, line 93
Phase_Iterate()
virtual StepBatchOut Phase_Iterate(const PhaseSpec& phase, StepContext& ctx) override
Dispatches the phase to its bound per-step callback.
Declared in ClikaRT/runtime/function_model.h, line 104