Skip to content

feat: add CompactifAI model pricing and capabilities - #43457

Closed
favouradesiyan wants to merge 2 commits into
BerriAI:mainfrom
favouradesiyan:feat-compactifai-model-pricing
Closed

favouradesiyan wants to merge 2 commits into
BerriAI:mainfrom
favouradesiyan:feat-compactifai-model-pricing

Conversation

@favouradesiyan

@favouradesiyan favouradesiyan commented Sep 27, 2026 •

Copy link
Copy Markdown

TLDR

Problem this solves:

  • CompactifAI's catalog lacks published pricing and model capabilities

How it solves it:

  • Add three models with published prices and capabilities
  • Register their models for provider discovery and wildcard grants

User Flow

Before: developers cannot calculate catalog-based costs for these CompactifAI models

  1. Select compactifai/glm-5-3, compactifai/glm-5-2, or compactifai/quasar-438b
  2. Calculate cost from the model's prompt and completion usage
  3. The model has no built-in pricing entry

After: developers can calculate costs using the published CompactifAI prices

  1. Select the same CompactifAI model
  2. Calculate cost from the model's prompt and completion usage
  3. The result uses the model's published input and output rates

Pre-Submission checklist

  • I have added meaningful tests
  • The test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR only solves one specific problem
  • Greptile confidence is at least 4/5 before maintainer review

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 passed

The 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 formatting

The 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

  • Context limits are omitted because public documentation does not specify them

Low

  • Live provider requests have not been validated
  • CLA and required hosted reviews remain pending

Final Attestation

  • Real-provider QA and required hosted checks complete

@CLAassistant

CLAassistant commented Sep 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codspeed

codspeed Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing favouradesiyan:feat-compactifai-model-pricing (4fae3fa) with main (254c2f6)

Open in CodSpeed

@codecov

codecov Bot commented Sep 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@favouradesiyan
favouradesiyan marked this pull request as ready for review September 27, 2026 19:00
@favouradesiyan
favouradesiyan requested a review from a team September 27, 2026 19:00
@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Adds a new model provider with pricing data.

The PR appears safe to merge, though the discovery-refresh behavior and independent price verification merit follow-up.

Findings

  1. P2 Removed models remain discoverable ▶
  2. P2 Incorrect prices pass this test ▶

Summary

Adds catalog pricing and capability metadata for three CompactifAI chat models, registers them for provider discovery, and tests catalog-based cost calculation.

  • Provider discovery can retain removed CompactifAI models after a cost-map refresh.
  • The pricing test does not independently verify the published rates.

Reviews (1) · Last reviewed commit: "feat: add CompactifAI model pricing and ..."

Comment thread litellm/__init__.py
Comment on lines +842 to +843
elif value.get("litellm_provider") == "compactifai":
compactifai_models.add(key)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +53 to +57
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Absorbed into the rolling registry PR #46886 with your co-author credit, adding cached input prices and the other listed models. Closing as superseded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants