feat(model-connections): enhance model selection facts and auto pinning logic

This commit is contained in:
Anish Sarkar 2026-06-13 02:19:27 +05:30
parent 45d27ba879
commit 15d9983669
3 changed files with 16 additions and 3 deletions

View file

@ -434,7 +434,10 @@ def initialize_llm_router():
router_settings = config.ROUTER_SETTINGS
if not all_configs:
print("Info: No global LLM configs found, Auto mode will not be available")
print(
"Info: No global LLM configs found; global Auto pool is unavailable. "
"Auto can still use enabled BYOK models."
)
return
try:

View file

@ -105,6 +105,15 @@ def _apply_model_facts(model: Model, facts: dict) -> None:
model.supports_image_generation = facts.get("supports_image_generation")
def _complete_selection_facts(conn: Connection, selection: ModelSelection) -> dict:
facts = selection.model_dump()
derived = derive_capabilities(conn, selection.model_id.strip(), selection.metadata)
for key, value in derived.items():
if facts.get(key) is None:
facts[key] = value
return facts
def _selection_to_model(conn: Connection, selection: ModelSelection) -> Model:
source = (
selection.source
@ -120,7 +129,7 @@ def _selection_to_model(conn: Connection, selection: ModelSelection) -> Model:
enabled=selection.enabled,
catalog=selection.metadata,
)
_apply_model_facts(model, selection.model_dump())
_apply_model_facts(model, _complete_selection_facts(conn, selection))
return model

View file

@ -541,12 +541,13 @@ async def resolve_or_get_pinned_llm_config_id(
premium_eligible = (
False if force_repin_free else await _is_premium_eligible(session, user_id)
)
byok_candidates = [c for c in candidates if _tier_of(c) == "byok"]
if premium_eligible:
premium_candidates = [c for c in candidates if _tier_of(c) == "premium"]
preferred_premium = [
c for c in premium_candidates if _is_preferred_premium_auto_config(c)
]
eligible = preferred_premium or premium_candidates
eligible = preferred_premium or premium_candidates or byok_candidates
else:
eligible = [c for c in candidates if _tier_of(c) != "premium"]