tokcount

package
v2026.701.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEncoding = tiktoken.MODEL_O200K_BASE
	DefaultModel    = "gpt-4o"
)

Variables

This section is empty.

Functions

func CountOpenAIChatCompletionParams

func CountOpenAIChatCompletionParams(p openai.ChatCompletionNewParams) int64

func CountOpenAIMessages

func CountOpenAIMessages(msgs []openai.ChatCompletionMessageParamUnion, model string) int64

func CountTools

func CountTools(tools []openai.ChatCompletionToolUnionParam, model string) int64

func EncoderForModel

func EncoderForModel(model string) (*tiktoken.Tiktoken, error)

func MessageOverhead

func MessageOverhead(model string) (tokensPerMessage, tokensPerName int)

func TextTokens

func TextTokens(text string, model string) int64

func VisionTokensForDataURL

func VisionTokensForDataURL(url string) int64

func VisionTokensForFile

func VisionTokensForFile(path string) int64

Types

This section is empty.

Jump to

Keyboard shortcuts

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