MCPcopy
hub / github.com/oobabooga/textgen / get_encoded_length

Function get_encoded_length

modules/text_generation.py:192–197  ·  view source on GitHub ↗
(prompt)

Source from the content-addressed store, hash-verified

190
191
192def get_encoded_length(prompt):
193 length_after_extensions = apply_extensions('tokenized_length', prompt)
194 if length_after_extensions is not None:
195 return length_after_extensions
196
197 return len(encode(prompt)[0])
198
199
200def get_token_ids(prompt):

Callers 4

count_tokensFunction · 0.90
generate_chat_promptFunction · 0.90
count_prompt_tokensFunction · 0.90
_hijack_lastFunction · 0.90

Calls 2

apply_extensionsFunction · 0.90
encodeFunction · 0.85

Tested by

no test coverage detected