DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(voice): migrate saved DashScope batch STT model
Bingxi Zhao (Frank)e166fad25541
diff --git a/deeptutor/services/config/model_catalog.py b/deeptutor/services/config/model_catalog.pyindex 92b162d91..d707438cb 100644--- a/deeptutor/services/config/model_catalog.py+++ b/deeptutor/services/config/model_catalog.py@@ -193,6 +193,8 @@ LLM_SHAPED_SERVICES: tuple[str, ...] = ("llm", "task")# built-in tables decide"; only explicit booleans are kept.MODEL_CAPABILITY_KEYS: tuple[str, ...] = ("tools", "vision", "json_output", "reasoning")+_DASHSCOPE_VOICE_BINDINGS = {"dashscope", "aliyun", "bailian"}+def _normalize_model_capabilities(model: dict[str, Any]) -> bool:raw = model.get("capabilities")@@ -479,6 +481,18 @@ 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 = 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 d8f821c4c..48c3dab71 100644--- a/tests/services/test_model_catalog.py+++ b/tests/services/test_model_catalog.py@@ -113,6 +113,61 @@ def test_load_recovers_invalid_catalog_with_defaults(tmp_path: Path):assert set(saved["services"]) == expected_services+def test_load_migrates_only_legacy_dashscope_stt_model(tmp_path: Path):+ catalog_path = tmp_path / "model_catalog.json"+ catalog_path.write_text(+ json.dumps(+ {+ "services": {+ "stt": {+ "active_profile_id": "dashscope-profile",+ "active_model_id": "dashscope-model",+ "profiles": [+ {+ "id": "dashscope-profile",+ "binding": "bailian",+ "models": [+ {+ "id": "dashscope-model",+ "name": "paraformer-v2",+ "model": "paraformer-v2",+ },+ {+ "id": "custom-name",+ "name": "My speech model",+ "model": "paraformer-v2",+ },+ ],+ },+ {+ "id": "other-profile",+ "binding": "openai",+ "models": [+ {+ "id": "other-model",+ "name": "paraformer-v2",+ "model": "paraformer-v2",+ }+ ],+ },+ ],+ }+ }+ }+ ),+ encoding="utf-8",+ )++ loaded = ModelCatalogService(path=catalog_path).load()+ models = loaded["services"]["stt"]["profiles"]+ assert models[0]["models"][0]["model"] == "paraformer-realtime-v2"+ assert models[0]["models"][0]["name"] == "paraformer-realtime-v2"+ assert models[0]["models"][1]["model"] == "paraformer-realtime-v2"+ assert models[0]["models"][1]["name"] == "My speech model"+ assert models[1]["models"][0]["model"] == "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(