DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(voice): migrate linked DashScope STT model by effective provider
Bingxi Zhao (Frank)abae417fe6ba
diff --git a/deeptutor/services/config/model_catalog.py b/deeptutor/services/config/model_catalog.pyindex d707438cb..0897a2ae8 100644--- a/deeptutor/services/config/model_catalog.py+++ b/deeptutor/services/config/model_catalog.py@@ -481,18 +481,27 @@ class ModelCatalogService:model.setdefault("id", f"{service_name}-model-{uuid4().hex[:8]}")model.setdefault("name", model.get("model") or "Untitled Model")model.setdefault("model", "")- if (- service_name == "stt"- and str(profile.get("binding") or "").lower()- in _DASHSCOPE_VOICE_BINDINGS- and model["model"] == "paraformer-v2"- ):- # The old default was a batch API model, but this- # profile's adapter always uses the real-time WebSocket.- model["model"] = "paraformer-realtime-v2"- if model["name"] == "paraformer-v2":- model["name"] = "paraformer-realtime-v2"- changed = True+ if service_name == "stt" and model["model"] == "paraformer-v2":+ from .provider_links import resolve_profile_provider++ # The provider can be overridden on either the profile+ # or the model. Use the binding the runtime will use.+ try:+ effective = resolve_profile_provider(+ catalog, service_name, profile, model+ )+ except ValueError:+ effective = {} # Leave a broken reference for readiness to report.+ if (+ str(effective.get("binding") or "").strip().lower()+ in _DASHSCOPE_VOICE_BINDINGS+ ):+ # The old default was a batch API model, but this+ # adapter always uses the real-time WebSocket.+ model["model"] = "paraformer-realtime-v2"+ if model["name"] == "paraformer-v2":+ model["name"] = "paraformer-realtime-v2"+ changed = Trueif service_name in LLM_SHAPED_SERVICES and _normalize_model_capabilities(model):diff --git a/tests/services/test_model_catalog.py b/tests/services/test_model_catalog.pyindex 48c3dab71..7f2911a63 100644--- a/tests/services/test_model_catalog.py+++ b/tests/services/test_model_catalog.py@@ -168,6 +168,83 @@ def test_load_migrates_only_legacy_dashscope_stt_model(tmp_path: Path):assert json.loads(catalog_path.read_text(encoding="utf-8")) == loaded+def test_load_migrates_legacy_stt_for_effective_provider_refs(tmp_path: Path):+ catalog_path = tmp_path / "model_catalog.json"+ catalog_path.write_text(+ json.dumps(+ {+ "connections": [+ {"id": "dashscope", "provider": "dashscope"},+ {"id": "openai", "provider": "openai"},+ ],+ "services": {+ "stt": {+ "profiles": [+ {+ "id": "source",+ "binding": "dashscope",+ "models": [+ {"id": "source-model", "model": "paraformer-realtime-v2"}+ ],+ },+ {+ "id": "profile-ref",+ "binding": "custom",+ "provider_ref": {"connection_id": "dashscope"},+ "models": [{"id": "profile-model", "model": "paraformer-v2"}],+ },+ {+ "id": "model-ref",+ "binding": "openai",+ "models": [+ {+ "id": "model-ref-model",+ "model": "paraformer-v2",+ "provider_ref": {"service": "stt", "profile_id": "source"},+ }+ ],+ },+ {+ "id": "model-override",+ "binding": "dashscope",+ "provider_ref": {"connection_id": "dashscope"},+ "models": [+ {+ "id": "other-model",+ "model": "paraformer-v2",+ "provider_ref": {"connection_id": "openai"},+ }+ ],+ },+ {+ "id": "profile-override",+ "binding": "dashscope",+ "provider_ref": {"connection_id": "openai"},+ "models": [{"id": "other-profile-model", "model": "paraformer-v2"}],+ },+ ]+ }+ },+ }+ ),+ encoding="utf-8",+ )++ loaded = ModelCatalogService(path=catalog_path).load()+ models = {+ profile["id"]: profile["models"][0]["model"]+ for profile in loaded["services"]["stt"]["profiles"]+ }+ assert models == {+ "source": "paraformer-realtime-v2",+ "profile-ref": "paraformer-realtime-v2",+ "model-ref": "paraformer-realtime-v2",+ "model-override": "paraformer-v2",+ "profile-override": "paraformer-v2",+ }+ assert json.loads(catalog_path.read_text(encoding="utf-8")) == loaded++def test_load_normalizes_wire_api_to_supported_profile_backends(tmp_path: Path):catalog_path = tmp_path / "model_catalog.json"catalog_path.write_text(