class
ion7.core.CSampler
Functions
CSampler.new
Create a CSampler.
raises — When the bridge call returns NULL (typically a malformed
CSampler:sample
Sample the next token AND auto-accept it. Drop-in compatible with `Sampler:sample` for the same chain semantics. Single FFI crossing per generated token (the bridge wraps sample + accept in one call).
CSampler:accept
Manually notify the sampler that `token` was accepted. Rarely needed (`sample` already auto-accepts) ; useful when you sample via another path and still want the DRY / Mirostat state updated.
CSampler:reset
Reset every internal counter (DRY history, Mirostat state, grammar automaton position).
CSampler:last
Last accepted token id, or `-1` if no token has been accepted yet on this sampler.
CSampler:seed
Effective RNG seed used by this instance.
CSampler:free
Free the sampler before GC. Idempotent. Disarms the `ffi.gc` finalizer so the GC does not double-free later.