Skip to content

Derive DEFAULT_MODEL_ID from AVAILABLE_MODELS #5

@DevanshSrajput

Description

@DevanshSrajput

Context
app_helpers.py declares the default model id in two places:
as a key in the AVAILABLE_MODELS dict, and again as the
top-level constant DEFAULT_MODEL_ID = "minimax-m3-free". If
the catalogue ever changes (a model is renamed, a new default
ships), a contributor has to remember to update both. The
existing AppHelpersModuleTests already pins the invariant
"DEFAULT_MODEL_ID must be in AVAILABLE_MODELS" — this
turns the test into a structural guarantee.

What to change
In app_helpers.py, define DEFAULT_MODEL_ID as the first
Free-tier entry of AVAILABLE_MODELS:

DEFAULT_MODEL_ID = next(
    mid for mid, info in AVAILABLE_MODELS.items()
    if info.get("tier") == "Free"
)

The catalogue declaration should keep its existing order — the
first Free entry is the implicit default — so a one-line
doc-comment is enough to lock the contract.

How to verify

  • python -c "from app_helpers import DEFAULT_MODEL_ID, AVAILABLE_MODELS; assert DEFAULT_MODEL_ID in AVAILABLE_MODELS" exits 0.
  • The AppHelpersModuleTests.test_default_model_id_is_in_catalogue
    test still passes.
  • Renaming a model id in the catalogue (and not touching
    DEFAULT_MODEL_ID) still produces a coherent default.

Skill: refactor, removing duplication.
Estimated effort: S.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions