Documentation
¶
Overview ¶
Package token provides token counting utilities using tiktoken encoding.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter handles token counting for text and message arrays.
func NewCounter ¶
NewCounter creates a new token counter with cl100k_base encoding.
func (*Counter) CountMessages ¶
func (c *Counter) CountMessages(system string, messages []MessageContent) (int, error)
CountMessages counts tokens in a message array. Estimates tokens for system prompt + messages with formatting overhead.
type MessageContent ¶
MessageContent represents a single message in a conversation.
Click to show internal directories.
Click to hide internal directories.