Get number of tokens in a string using OpenAI's tiktoken library
num_tokens.Rd
This function uses the num_tokens_from_string function provided in OpenAI's tiktoken python library to get the number of tokens in a string.
Arguments
- text
a character string to count the number of tokens from
- encoding
a character string that specifies how text is converted into tokens. The default is "cl100k_base" (for ChatGPT models; see https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb for details)