feat: DB-driven free and default model flags for verified models - #191
Open
juanmichelini wants to merge 2 commits into
Open
feat: DB-driven free and default model flags for verified models#191juanmichelini wants to merge 2 commits into
juanmichelini wants to merge 2 commits into
Conversation
Add is_free and is_default columns to the verified_models table and thread them through the admin CRUD API, the LLMModel/ModelsResponse contract, and SaaSLLMModelService so the OpenHands provider can mark models as free (Free badge) and designate one default model per provider from the database. - migration 144: is_free/is_default columns + partial unique index enforcing one default per provider; seed previously-hardcoded free set and default - VerifiedModel DTOs + service create/update accept is_free/is_default with default-clearing so only one default survives per provider - LLMModel.free + ModelsResponse.free_models mirror the verified channel - get_supported_llm_models accepts free_models/default_model - SaaSLLMModelService emits DB free models and the openhands default Co-authored-by: openhands <openhands@all-hands.dev>
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Mirror the free/verified channel: set LLMModel.default for the model matching ModelsResponse.default_model so the frontend can read the DB-driven default from the same models search endpoint used for verified/free. Co-authored-by: openhands <openhands@all-hands.dev>
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
Backend (PR 1 of 2) for surfacing Free badges and a configurable default model on the OpenHands provider, driven by the database — extending the existing
verifiedmodel mechanism rather than hardcoding in the frontend.Today the "Free" badge is hardcoded in the frontend (
format-model-name.ts→FREE_OPENHANDS_MODELS). This PR makesfree(and a per-providerdefault) ride the same DB-backed channel thatverifiedalready uses, so admins can manage them from the verified-models admin API.Changes
is_freeandis_defaultboolean columns toverified_models, plus a partial unique index enforcing at most one default per provider. Seeds the previously-hardcoded free set (glm-5.2,deepseek-v4-flash,minimax-m2.7) and the default (glm-5.2) for theopenhandsprovider so the badge is unchanged the instant the frontend switches over.verified_model_models.py):is_free/is_defaulton create/update models.verified_model_service.py): new columns onStoredVerifiedModel, mapper, and create/update accept the flags. Setting a default clears any existing default for the same provider (write-ordering guard alongside the DB index).verified_model_router.py): create/update endpoints pass the new fields through.config_models.py,utils/llm.py):LLMModel.freeandModelsResponse.free_modelsmirror theverifiedchannel;get_supported_llm_models(...)acceptsfree_modelsanddefault_model(defaults preserve existing behavior).litellm_proxy_model_router.py/SaaSLLMModelService): emits DB free models and theopenhandsdefault into the models response.Tests
enterprise/tests/unit/test_verified_model/: 44 passed (new free/default flag + default-clearing + per-provider isolation tests).tests/unit/app_server/test_llm_model_service.py: 25 passed (newfreepropagation tests in_to_llm_models).ruffclean on all touched files (root config foropenhands/, enterprise config forenterprise/).Follow-up
PR 2 (in
OpenHands/OpenHands) will replace the hardcodedFREE_OPENHANDS_MODELSwith the DB-drivenfreeflag flowing through the same channel asverified, and consume the DB-provided default on onboarding and when creating a new OpenHands model.This PR was created by an AI agent (OpenHands) on behalf of @juanmichelini.
Enterprise server image for this PR: