跳到主要内容

token_count_utils

剩余令牌

def token_left(input: Union[str, List, Dict],
model="gpt-3.5-turbo-0613") -> int

计算OpenAI模型剩余的token数量。

参数:

  • input - (str, list, dict): 模型的输入。
  • model - (str): 模型名称。

返回:

  • int - 模型可以用于完成的剩余令牌数量。

count_token

def count_token(input: Union[str, List, Dict],
model: str = "gpt-3.5-turbo-0613") -> int

计算OpenAI模型使用的token数量。

参数:

  • input - (str, list, dict): 模型的输入。
  • model - (str): 模型名称。

返回:

  • int - 输入中的令牌数量。

num_tokens_from_functions

def num_tokens_from_functions(functions, model="gpt-3.5-turbo-0613") -> int

返回由函数列表使用的token数量。

参数:

  • functions - (list): 将传递给模型的函数描述列表。
  • model - (str): 模型名称。

返回:

  • int - 函数描述中的标记数量。