Skip to content

kricsleo/gpt-token

Repository files navigation

gpt-token

Calculate the number of text tokens in GPT.

Usage

npm i gpt-token
import { textTokens, messageTokens } from 'gpt-token'

// => 9
console.log(textTokens('A quick brown fox jumps over the lazy dog'))

// => 16
console.log(messageTokens([
  {
    role: 'user',
    content: 'A quick brown fox jumps over the lazy dog'
  }
]))

Thanks ❤️

License

MIT License © Krcisleo