tiktoken

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package tiktoken wraps the embedded tiktoken-go BPE codec so text can be split into model tokens with no runtime network fetch — the o200k_base vocabulary is compiled into the binary. The demo stream uses it to emit text at real token boundaries: a canned response then streams exactly like a live model turn (one SSE delta per token) instead of arbitrary fixed-width chunks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(text string) (int, error)

Count returns the number of o200k_base tokens in text without allocating the decoded token strings used by Tokenize.

func Tokenize

func Tokenize(text string) ([]string, error)

Tokenize splits text into its o200k_base model tokens as decoded strings, ready to stream one delta per token. Concatenating the returned tokens reproduces the input byte-for-byte.

Types

This section is empty.

Jump to

Keyboard shortcuts

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