Functions§
- approx_
bytes_ for_ tokens - approx_
token_ count - approx_
tokens_ from_ byte_ count - find_
uuids - Find all UUIDs in a string.
- normalize_
markdown_ hash_ location_ suffix - Convert a markdown-style
#L..location suffix into a terminal-friendly:line[:column][-line[:column]]suffix. - sanitize_
metric_ tag_ value - Sanitize a tag value to comply with metric tag validation rules: only ASCII alphanumeric, ‘.’, ‘_’, ‘-’, and ‘/’ are allowed.
- take_
bytes_ at_ char_ boundary - to_
ascii_ json_ string - Serialize JSON while escaping non-ASCII string content as
\uXXXX. - truncate_
middle_ chars - Truncate a string to
max_bytesusing a character-count marker. - truncate_
middle_ with_ token_ budget - Truncate the middle of a UTF-8 string to at most
max_tokensapproximate tokens, preserving the beginning and the end. Returns the possibly truncated string andSome(original_token_count)if truncation occurred; otherwise returns the original string andNone.