Spaces:
Building
Building
import json | |
import requests | |
import time | |
import tiktoken | |
import random | |
from helpers.prompts import * | |
TOKEN = "5182224145:AAEjkSlPqV-Q3rH8A9X8HfCDYYEQ44v_qy0" | |
chat_id = "5075390513" | |
def num_tokens_from_string(string: str, encoding_name: str = "cl100k_base") -> int: | |
"""Returns the number of tokens in a text string.""" | |
encoding = tiktoken.get_encoding(encoding_name) | |
num_tokens = len(encoding.encode(string)) | |
return num_tokens | |