Created
June 21, 2023 23:20
-
-
Save radixm46/1f85366c7d469bdc1d201269a23f8d12 to your computer and use it in GitHub Desktop.
print number of tokens from stdin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env hy | |
(import sys) | |
(import tiktoken) | |
(require hyrule [defmain]) | |
(defmain [] | |
(len (. (tiktoken.encoding_for_model "gpt-4") | |
(encode (sys.stdin.read)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment