fix(model): add exact mapping for gpt-4.5#569
Open
yen0304 wants to merge 1 commit into
Open
Conversation
`encoding_for_model("gpt-4.5")` raised a KeyError because only the
"gpt-4.5-" prefix existed, which requires a trailing hyphen; the bare
model name "gpt-4.5" does not start with "gpt-4.5-" and therefore
falls through to the error path.
Adds "gpt-4.5" to MODEL_TO_ENCODING (same pattern as "gpt-5", "gpt-4.1",
and "gpt-4o" which all have both an exact entry and a versioned prefix).
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.
encoding_for_model("gpt-4.5")raises aKeyErrortoday:Root cause:
MODEL_PREFIX_TO_ENCODINGcontains"gpt-4.5-"(note the trailing hyphen), which correctly handles versioned variants likegpt-4.5-preview. However, the bare model name"gpt-4.5"does not start with"gpt-4.5-"— the trailing hyphen is never matched — so it falls through to theKeyErrorpath.This is the same shape as the
gpt-5.1issue (#464 / PR #554). Every other dot-minor model (gpt-5,gpt-4.1,gpt-4o) has both an exact entry inMODEL_TO_ENCODINGand a versioned prefix.gpt-4.5was missing the exact entry.Fix: add
"gpt-4.5": "o200k_base"toMODEL_TO_ENCODING, consistent with all peer models.Verified locally:
This contribution was made with AI assistance.