Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When both tiktoken lookup and HuggingFace tokenizer loading fail,
get_tokenizersubstitutes the GPT-4 tokenizer. The substitution is currently logged at INFO, so experiments using WARNING-level output can miss that their token counts are estimates for a different model.Change
Promote the actual GPT-4 fallback message to WARNING, retaining the requested model and load error. Successful tokenizer resolution and fallback/caching behavior remain compatible. Add offline tests covering loading failure, missing optional transformers, cached fallback, and successful tiktoken/HuggingFace resolution.
Addresses the warning-level suggestion (1) in #340. This is a partial contribution: model-name normalization, run metadata and an opt-in strict mode are outside this PR, so the issue should remain open.
Validation
8488c564: 3 failed, 2 passed, specifically because fallback warnings are absent.tests/llm/test_tokenizer_fallback.py).git diff --check: passed.Local validation used Python 3.13.7 and pytest 9.1.1, rather than the project's Python 3.11/3.12 and locked dependencies. A temporary bootstrap imported the real production module using existing dependencies, disabled unrelated pytest plugins, and supplied an import-only empty
anthropicmodule because that SDK is unavailable locally; no Anthropic functionality was exercised. Tokenizer loaders are mocked by the committed tests to avoid downloads. This bootstrap is not part of the PR.Draft pending CI: the full locked environment, browser benchmark suite and repository-wide Black/darglint checks were not run locally because shell network access is restricted.
Prepared with AI assistance.