Spaces:
Paused
Paused
Download helpers/provider.py from akiko19191/BackendOLD: direct link, hf CLI and curl.
- Browser
- Download file 442 Bytes
-
https://huggingface.co/spaces/akiko19191/BackendOLD/resolve/main/helpers/provider.py
- Command line
-
hf download hf://spaces/akiko19191/BackendOLD/helpers/provider.py
-
curl -L -o provider.py https://huggingface.co/spaces/akiko19191/BackendOLD/resolve/main/helpers/provider.py
442 Bytes
| 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 | |