MCPcopy
hub / github.com/llmware-ai/llmware / token_counter

Method token_counter

llmware/models.py:3340–3348  ·  view source on GitHub ↗

Not Used for ONNXGenerativeModel class - Quick approximate token counter - uses default tokenizer so may have minor differences from the model's actual tokenization.

(self, text_sample)

Source from the content-addressed store, hash-verified

3338 return self.api_key
3339
3340 def token_counter(self, text_sample):
3341
3342 """ Not Used for ONNXGenerativeModel class - Quick approximate token counter -
3343 uses default tokenizer so may have minor differences from the model's actual tokenization. """
3344
3345 tokenizer = Utilities().get_default_tokenizer()
3346 toks = tokenizer.encode(text_sample).ids
3347
3348 return len(toks)
3349
3350 def prompt_engineer(self, query, context, inference_dict):
3351

Callers

nothing calls this directly

Calls 3

UtilitiesClass · 0.90
get_default_tokenizerMethod · 0.80
encodeMethod · 0.80

Tested by

no test coverage detected