feat(distro): add more providers to starter distro, prefix conflicting models

This commit is contained in:
Ashwin Bharambe 2025-06-03 11:43:19 -07:00
parent b380cb463f
commit 528a391c5f
8 changed files with 504 additions and 164 deletions

View file

@ -8,6 +8,7 @@ from pathlib import Path
from typing import Literal
import jinja2
import rich
import yaml
from pydantic import BaseModel, Field
@ -36,13 +37,33 @@ def get_model_registry(
available_models: dict[str, list[ProviderModelEntry]],
) -> list[ModelInput]:
models = []
# check for conflicts in model ids
all_ids = set()
ids_conflict = False
for _, entries in available_models.items():
for entry in entries:
ids = [entry.provider_model_id] + entry.aliases
for model_id in ids:
if model_id in all_ids:
ids_conflict = True
rich.print(
f"[yellow]Model id {model_id} conflicts; all model ids will be prefixed with provider id[/yellow]"
)
break
all_ids.update(ids)
if ids_conflict:
break
for provider_id, entries in available_models.items():
for entry in entries:
ids = [entry.provider_model_id] + entry.aliases
for model_id in ids:
identifier = f"{provider_id}/{model_id}" if ids_conflict and provider_id not in model_id else model_id
models.append(
ModelInput(
model_id=model_id,
model_id=identifier,
provider_model_id=entry.provider_model_id,
provider_id=provider_id,
model_type=entry.model_type,