Entropic 2.9.4
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::LlamaCppSampler Class Reference

Sampler adapter that wraps a llama_sampler* chain. More...

#include </home/runner/work/entropic/entropic/src/inference/llama_cpp_sampler.h>

Inheritance diagram for entropic::LlamaCppSampler:
Collaboration diagram for entropic::LlamaCppSampler:

Public Member Functions

 LlamaCppSampler (llama_sampler *chain, llama_context *ctx)
 Construct with an already-built llama_sampler chain.
 
 ~LlamaCppSampler () override
 Free the underlying llama.cpp sampler chain.
 
 LlamaCppSampler (const LlamaCppSampler &)=delete
 
LlamaCppSampleroperator= (const LlamaCppSampler &)=delete
 
int32_t sample () override
 Sample one token from the current logits via the wrapped chain.
 
void reset () override
 Reset llama_sampler internal state.
 
llama_sampler * native_chain () const
 Expose the underlying chain for legacy call sites that have not yet been ported to the Sampler API.
 

Detailed Description

Sampler adapter that wraps a llama_sampler* chain.

Owns the chain (freed in destructor). Stores a non-owning llama_context* snapshot captured at factory creation time; the backend guarantees the context outlives every Sampler it vends.

Definition at line 47 of file llama_cpp_sampler.h.

Constructor & Destructor Documentation

◆ LlamaCppSampler()

entropic::LlamaCppSampler::LlamaCppSampler ( llama_sampler *  chain,
llama_context *  ctx 
)

Construct with an already-built llama_sampler chain.

Construct an LlamaCppSampler wrapping a pre-built sampler chain.

Parameters
chainOwning pointer to llama_sampler chain.
ctxNon-owning llama_context (snapshot at sampler birth).
Version
2.3.10

Definition at line 120 of file llama_cpp_sampler.cpp.

◆ ~LlamaCppSampler()

entropic::LlamaCppSampler::~LlamaCppSampler ( )
override

Free the underlying llama.cpp sampler chain.

Definition at line 128 of file llama_cpp_sampler.cpp.

Member Function Documentation

◆ native_chain()

llama_sampler * entropic::LlamaCppSampler::native_chain ( ) const
inline

Expose the underlying chain for legacy call sites that have not yet been ported to the Sampler API.

Production callers in the decode loop should use sample() directly; this accessor exists for transition-period code and for tests asserting that production wiring really produces a non-null chain.

Returns
Borrowed llama_sampler* (never null for the production Sampler; do not free).

Definition at line 88 of file llama_cpp_sampler.h.

◆ reset()

void entropic::LlamaCppSampler::reset ( )
overridevirtual

Reset llama_sampler internal state.

Reset stateful samplers (e.g.

Forwards to llama_sampler_reset so callers re-seeding a generation pick up a fresh RNG / penalty-window state.

Version
2.3.10

repeat-penalty history) on the chain.

Reimplemented from entropic::Sampler.

Definition at line 151 of file llama_cpp_sampler.cpp.

◆ sample()

int32_t entropic::LlamaCppSampler::sample ( )
overridevirtual

Sample one token from the current logits via the wrapped chain.

Returns
Sampled token id, or -1 if the chain or context is missing.

Implements entropic::Sampler.

Definition at line 141 of file llama_cpp_sampler.cpp.


The documentation for this class was generated from the following files: