52 if (vocab_ ==
nullptr) {
return {}; }
56 static_cast<int32_t>(text.size()),
58 if (
n < 0) {
n = -
n; }
60 std::vector<int32_t>
tokens(
static_cast<size_t>(
n));
62 static_cast<int32_t>(text.size()),
65 logger->error(
"Tokenization failed for text of length {}",
87 if (vocab_ ==
nullptr) {
return {}; }
94 vocab_, token,
buf,
sizeof(
buf), 0,
false);
95 if (
n >= 0) {
return std::string(
buf,
static_cast<size_t>(
n)); }
98 std::vector<char>
large(
static_cast<size_t>(-
n));
103 ? std::string(
large.data(),
static_cast<size_t>(
n))
std::string detokenize(int32_t token) const override
Decode a single token id to its surface string.
std::vector< int32_t > tokenize(const std::string &text, bool add_special) const override
Encode text into token ids via the wrapped vocab.
LlamaCppTokenizer(const llama_vocab *vocab)
Construct with a borrowed vocab pointer.
Concrete llama.cpp tokenizer (v2.3.10 seam impl).
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Activate model on GPU (WARM → ACTIVE).
@ tokens
Gate on generated tokens since the last tool call.
@ optional
optional: every escape asks the host's path approver