refactor: make internal/models the single source of truth for models - #19
Merged
Merged
Conversation
Move pricing, model IDs, aliases and defaults out of internal/benchmark and internal/tokens into a new internal/models package. ResolveModel, flag help, and the unknown-model error are now derived from one registry, and DefaultCountTokensModel references it instead of duplicating an ID string. No behavior change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HX8KccseqQb2rUserM2BDT
Reference models.Pricing and models.DefaultCountTokens.ID directly instead of re-exporting them, and trim redundant comments. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HX8KccseqQb2rUserM2BDT
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HX8KccseqQb2rUserM2BDT
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.
Summary
internal/modelsholding every model's API ID, per-token pricing, aliases and the default models (DefaultBenchmark,DefaultCountTokens) in one registry.--modelhelp text and the unknown-model error are now generated from the registry instead of hand-written lists.ResolveModel,ModelConfigand the per-modelPricingXxx/TokenCountModelXxxconstants frominternal/benchmark;cost.goandrender.gousemodels.Pricingdirectly.internal/tokensusesmodels.DefaultCountTokens.IDinstead of its own hard-coded model ID string.internal/models, and add checks for duplicate names/IDs, duplicate family aliases, registered defaults and cache-read ratios.Behavior
No behavior change. Aliases, default model (
opus), pricing and the count_tokens default are unchanged from main.Adding a model later
Declare it in
internal/models/models.go, add it toregistry, and updateFamily/ the defaults if it becomes the newest in its family.docs/benchmark.mdis the only place still updated by hand.Test plan
gofmtcleango vet ./...go test ./...🤖 Generated with Claude Code
https://claude.ai/code/session_01HX8KccseqQb2rUserM2BDT
Generated by Claude Code