gpt-token
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

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

Package Sidebar

Install

npm i gpt-token

Weekly Downloads

20

Version

0.0.5

License

MIT

Unpacked Size

7.66 kB

Total Files

6

Last publish

Collaborators

  • kricsleo