Spaces:
Building
Building
File size: 442 Bytes
7a8853f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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
|