Repository navigation
feat: add CompactifAI model pricing and capabilities - #43457
favouradesiyan wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
| elif value.get("litellm_provider") == "compactifai": | ||
| compactifai_models.add(key) |
There was a problem hiding this comment.
Removed models remain discoverable If a refreshed cost map removes or reassigns a CompactifAI model, this code only adds names to
compactifai_models; it never removes old ones. Provider discovery and compactifai/* wildcard expansion then continue to include the stale model. Reconcile the set with the current map during refresh.
Knowledge Base Used: Provider adapters and capabilities
There was a problem hiding this comment.
I reproduced the stale discovery behavior, but it is shared with existing providers: add_known_models(model_cost_map=...) explicitly folds additions into the provider sets, and existing callers pass partial maps. Clearing the CompactifAI set there would remove valid existing models on those calls
This PR follows that existing contract. Removal reconciliation should happen at the full catalog-adoption boundary and account for runtime registrations, rather than changing only this provider's additive population branch. I would prefer to keep this provider addition focused and handle that behavior separately unless the maintainers want it included here
There was a problem hiding this comment.
That’s a fair clarification. Given that add_known_models() intentionally accepts partial maps and merges additions into shared provider registries, clearing compactifai_models in this branch could remove valid runtime-registered models.
The stale-entry concern belongs at the full catalog-adoption boundary, where catalog-backed entries can be reconciled while preserving runtime registrations. It is not a defect specific to this provider addition, so I’m withdrawing this comment.
Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.
| model_info: Final = litellm.get_model_info(model=model, custom_llm_provider="compactifai") | ||
| input_rate: Final = model_info.get("input_cost_per_token") | ||
| output_rate: Final = model_info.get("output_cost_per_token") | ||
| assert input_rate is not None and input_rate > 0 | ||
| assert output_rate is not None and output_rate > 0 |
There was a problem hiding this comment.
Incorrect prices pass this test The expected input and output rates come from the same catalog being tested. If those prices are swapped or otherwise incorrect but still positive, every cost assertion can pass. Assert the published rates independently so the test catches pricing-entry mistakes.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
The test intentionally checks provider discovery and cost calculation against the catalog, rather than pinning external vendor rates. The repository's AGENTS.md says not to pin vendor prices as literals and to assert the invariant the code guarantees
I independently checked the catalog entries against https://docs.compactif.ai/pricing/ on 2026-09-27: GLM-5.2 and GLM-5.3 are $1.10 input / $3.50 output per million tokens; Quasar-438B is $0.60 input / $1.80 output per million tokens. Both catalog files match those rates
I agree the test would not detect an arbitrary positive pricing typo. If maintainers consider fixed-rate assertions load-bearing here, the guidance allows them with a source and verification date; I can add those if that is preferred
There was a problem hiding this comment.
That’s fair. This test is intentionally validating provider discovery and cost-calculation wiring against the catalog, while avoiding duplicated vendor-price literals; the independent catalog/source verification confirms the published rates. Given that scope and the repository guidance, fixed-rate assertions are not required here. I’m withdrawing the finding.
|
Absorbed into the rolling registry PR #46886 with your co-author credit, adding cached input prices and the other listed models. Closing as superseded |
TLDR
Problem this solves:
How it solves it:
User Flow
Before: developers cannot calculate catalog-based costs for these CompactifAI models
compactifai/glm-5-3,compactifai/glm-5-2, orcompactifai/quasar-438bAfter: developers can calculate costs using the published CompactifAI prices
Pre-Submission checklist
Validation
LITELLM_LOCAL_MODEL_COST_MAP=True PYTHON_DOTENV_DISABLED=1 .venv/bin/pytest tests/unit/test_cost_calculator.py tests/unit/test_model_prices_schema.py -q: 265 passedThe parameterized regression checks provider model discovery and cost calculation from response usage for all three models. Expected costs come from the catalog rather than duplicated vendor price literals
BASE_REF=origin/main make check: passed, including Ruff, type discipline, test-quality budgets, basedpyright budgets, import safety, and scoped formattingThe root and bundled pricing files match, and schema generation requires no schema changes
Sources
Published pricing, GLM-5.2, GLM-5.3, and Quasar-438B, checked September 27, 2026
Type
New Feature
Caveats
Medium
Low
Final Attestation