Repository navigation
fix: count literal special-token strings in TiktokenCounter - #12879
burakeyler wants to merge 1 commit into
Conversation
|
@burakeyler is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
|
Signed-off-by: Burak Eyler <burakeyler@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Hi @burakeyler, thanks for your interest in contributing to Haystack! 🙏 This is an automated message to help us keep the review queue healthy. |
|
Hi @burakeyler, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
|
Hi @burakeyler, just a friendly reminder: this PR is still in draft because the Contributor License Agreement (CLA) hasn't been signed yet. We'd love to review your contribution! Please sign the CLA via the link in the |
|
Thank you for your efforts! We're closing this PR because it duplicates #13009, which makes the same one-line fix to |
Related Issues
Fixes #12869
Proposed Changes
TiktokenCounter.count()calledEncoding.encode(), which defaults todisallowed_special="all"and therefore raisesValueErrorwhenever a message or tool schema merely mentions a string like<|endoftext|>. Sinceallowed_specialdefaults to the empty set, no special tokens could ever be produced anyway, so the strict check only turned ordinary user text into a crash.Switched to
encode_ordinary(), the same fix applied to the document splitters in #12853, so special-token strings are counted as literal text.How did you test it?
_FakeEncoderin the unit tests to theencode_ordinaryentry point.<|endoftext|>with the realo200k_baseencoding; it raises onmainand passes here.pytest test/token_counters/test_tiktoken_counter.py→ 13 passed.Checklist
🤖 Generated with Claude Code