tokencount

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(model, text string) (int, error)

Count returns the number of tokens in the given text for the specified model. Falls back to cl100k_base encoding if the model is not recognized.

func CountMessages

func CountMessages(model string, messages []map[string]interface{}) (int, error)

CountMessages estimates token usage for a chat completion messages array. Uses the OpenAI token counting heuristic: each message adds overhead tokens.

Types

This section is empty.

Jump to

Keyboard shortcuts

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