Skip to main content

Count the number of tokens in a text string or file, similar to the Unix 'wc' utility.

Project description

Token Count

Token Count is a command-line utility that counts the number of tokens in a text string, file, or directory, similar to the Unix wc utility. It uses the OpenAI tiktoken library for tokenization and is compatible with GPT-3.5-turbo or any other OpenAI model token counts.

Installation

To install Token Count, run the following command in your terminal:

pip install token-count

Usage

Token Count has three main options:

Count tokens in a text string:

token-count --text "Your text here"

Count tokens in a file:

token-count --file path/to/your/file.txt

Count tokens in a directory (recursively):

token-count --directory path/to/your/directory

You can provide any combination of these options. Token Count will print the token count for each input type.

Additionally, you can provide any OpenAI model(gpt-4) to get token count according to the model. By default it uses "gpt-3.5-turbo".

token-count --model_name "gpt-4"

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

token-count-0.1.5.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

token_count-0.1.5-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file token-count-0.1.5.tar.gz.

File metadata

  • Download URL: token-count-0.1.5.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for token-count-0.1.5.tar.gz
Algorithm Hash digest
SHA256 50a9c0826c21b84275a0d288c93470f58acd8b4b9b0d185df695aa535471652a
MD5 b85e32dc2896810f2d377dc09fc6fbc7
BLAKE2b-256 0bb060467013488cbf6a1789d3c3b9dae94b546b1c1409d4554daddf378912ae

See more details on using hashes here.

File details

Details for the file token_count-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: token_count-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for token_count-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 416227912515c2e8ebb2bc4fdb848c6a7b9cc6e9dbea6aec8b3454c297adc019
MD5 917bd6c2318e5cf26490249d5132d025
BLAKE2b-256 76a1a42fca256159a138eea49213e94d28c72a0fb3c9479620c6d3a2bc5f4e9e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page