MCPcopy Create free account
hub / github.com/cosdata/cosdata / validate_token_length

Function validate_token_length

tests/modal_remote_vllm/remote_cache_dense.py:120–125  ·  view source on GitHub ↗

Validate that text doesn't exceed token limit when encoded.

(text: str, max_len: int = 512)

Source from the content-addressed store, hash-verified

118
119
120def validate_token_length(text: str, max_len: int = 512) -> bool:
121 """
122 Validate that text doesn't exceed token limit when encoded.
123 """
124 tokens = safe_tokenize(text, add_special_tokens=True)
125 return len(tokens) <= max_len
126
127
128def load_queries_robust(dataset: str, save_dir: str) -> dict:

Callers 2

embedMethod · 0.85
cache_datasetFunction · 0.85

Calls 1

safe_tokenizeFunction · 0.85

Tested by

no test coverage detected