tokencounter

command module
v0.0.0-...-624914d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tokencounter

A simple CLI to count OpenAI tokens for a set of files.

  • Supports .gitignore
  • Match mimetypes to include
  • Specify any model

[!NOTE] Uses tiktoken-go to tokenize. It may not be 100% accurate, but should be close.

# Install the CLI
go install github.com/kylecarbs/tokencounter@latest

# Compute tokens for the current directory recursively
tokencounter

# List supported models
tokencounter models

Example

Counting the number of tokens in coder/coder:

dev ~/p/c/coder (main *s =) ~/tokencount
using ignore file: .gitignore
adding files: 100
adding files: 200
adding files: 300
adding files: 400
adding files: 500
adding files: 600
adding files: 700
adding files: 800
adding files: 900
adding files: 1000
adding files: 1100
adding files: 1200
adding files: 1300
adding files: 1400
skipped "video/mp4" 7 times
skipped "image/jpeg" 3 times
skipped "image/bmp" 1 times
skipped "image/svg+xml" 243 times
skipped "application/gzip" 2 times
skipped "application/x-ndjson" 4 times
skipped "application/json" 87 times
skipped "application/x-tar" 2 times
skipped "application/zip" 1 times
skipped "image/png" 4097 times
skipped "image/gif" 2 times
skipped "video/quicktime" 2 times
skipped "application/octet-stream" 15 times
skipped "image/x-icon" 2 times
skipped "image/webp" 3 times
waiting for processing to finish
total tokens: 5631222

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL