Repository navigation
v0.0.1
What's New
First release. tokin ships as a library: the chat-template layer a token-in/token-out gateway needs. The /v1/chat/completions server is not in this release.
Features
ChatTemplaterenders a conversation with the model's own Hugging Face chat template, and renders just the increment a new turn adds, so a served prompt is extended rather than rebuilt (#15, #18)ChatTemplate.parsereads the sampled text back into an OpenAI assistant message: reasoning inreasoning_content, tool calls parsed in the family's grammar (#26, #27)- Families for the Qwen mainline, 2.5 through 3.8, and GLM 4.5 through 5.3 (#20, #23, #24)
- Tool-call grammars: Hermes JSON, Qwen
<function=…>XML, GLM<arg_key>pairs; XML argument values are typed by the tool schema (#27) - Tool results are checked against their calls and put in call order before rendering (#29)
get_chat_templatefinds a family by name, by checkpoint id, or bymodule:Classfor a family defined outside the package (#22)Rollout,Turn,Session: the token-level record of a conversation, prompt ids and sampled ids kept apart (#5, #6)
Tests
- Every family is verified against its real tokenizers: 50 checkpoints, 954 cases, including the increment-is-a-suffix property and the parse round-trip (#21)
Documentation
Maintenance
Full Changelog: https://github.com/camel-ai/tokin/commits/v0.0.1