get_num_tokens#

langchain_community.callbacks.infino_callback.get_num_tokens(string: str, openai_model_name: str) int[source]#

Calculate num tokens for OpenAI with tiktoken package.

Official documentation: openai/openai-cookbook

/examples/How_to_count_tokens_with_tiktoken.ipynb

Parameters:
  • string (str)

  • openai_model_name (str)

Return type:

int