DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(settings): expose effective vision support in llm-options (#2037)
cgycorey0cbfaca2eb64
diff --git a/deeptutor/services/model_selection/llm.py b/deeptutor/services/model_selection/llm.pyindex 9e96a9e3e..910ea3fa6 100644--- a/deeptutor/services/model_selection/llm.py+++ b/deeptutor/services/model_selection/llm.py@@ -99,6 +99,9 @@ def list_llm_options(catalog: dict[str, Any]) -> dict[str, Any]:active_model_id = str(service.get("active_model_id") or "")options: list[dict[str, Any]] = []+ # Local import: the llm package imports back into this module at load time.+ from deeptutor.services.llm.capabilities import supports_vision+for profile in service.get("profiles", []) or []:if not isinstance(profile, dict):continue@@ -156,6 +159,14 @@ def list_llm_options(catalog: dict[str, Any]) -> dict[str, Any]:for capability in ("reasoning", "vision"):if type(declared.get(capability)) is bool:option[f"declared_{capability}"] = declared[capability]+ # The settings UI filters vision models on this field. The catalog's+ # own declaration wins over the process-global override table, which+ # only refreshes on the next runtime resolution -- otherwise a+ # freshly declared model stays hidden until something else resolves+ # (#2037). Same rule as `lightrag/roles.py`.+ option["supports_vision"] = option.get(+ "declared_vision", supports_vision(model_provider, model_value)+ )options.append(option)return {diff --git a/tests/api/test_settings_router.py b/tests/api/test_settings_router.pyindex 3eb4b5e07..962720b6a 100644--- a/tests/api/test_settings_router.py+++ b/tests/api/test_settings_router.py@@ -743,6 +743,9 @@ async def test_get_llm_options_returns_redacted_catalog(monkeypatch: pytest.Monkembedding_base_url="https://emb.example/v1/embeddings",embedding_api_key="emb-key",)+ # A catalog declaration must win over the provider table: gpt-4o-mini is+ # vision-capable by default, so only a declared False can reach the API.+ catalog["services"]["llm"]["profiles"][0]["models"][0]["capabilities"] = {"vision": False}service = _FakeCatalogService(catalog)monkeypatch.setattr(settings_router, "get_model_catalog_service", lambda: service)@@ -753,6 +756,8 @@ async def test_get_llm_options_returns_redacted_catalog(monkeypatch: pytest.Monk"model_id": "llm-model-default",}assert response["options"][0]["model"] == "gpt-4o-mini"+ # The Document Parsing model dropdown filters on this field (#2037).+ assert response["options"][0]["supports_vision"] is Falseassert "api_key" not in response["options"][0]assert "base_url" not in response["options"][0]diff --git a/tests/services/model_selection/test_llm_selection.py b/tests/services/model_selection/test_llm_selection.pyindex 343f25395..4525dfd9d 100644--- a/tests/services/model_selection/test_llm_selection.py+++ b/tests/services/model_selection/test_llm_selection.py@@ -1,3 +1,6 @@+import pytest++from deeptutor.services.llm.capabilities import set_catalog_capability_overridesfrom deeptutor.services.model_selection import (LLMSelection,apply_llm_selection_to_catalog,@@ -5,6 +8,15 @@ from deeptutor.services.model_selection import ()[email protected](autouse=True)+def _clear_overrides():+ # supports_vision() reads a process-global table; pin it empty so these+ # assertions cannot inherit a leftover declaration from another test file.+ set_catalog_capability_overrides([])+ yield+ set_catalog_capability_overrides([])++def _catalog():return {"version": 1,@@ -68,6 +80,29 @@ def test_list_llm_options_is_redacted_and_marks_active_default():assert "extra_headers" not in payload["options"][0]+def test_list_llm_options_reports_effective_vision_support():+ def vision_by_model(catalog):+ return {o["model_id"]: o["supports_vision"] for o in list_llm_options(catalog)["options"]}++ # Provider defaults when the catalog declares nothing: openrouter is+ # vision-capable, ollama is per-model.+ assert vision_by_model(_catalog()) == {"m1": True, "m2": True, "m3": False}++ # A declaration in the catalog itself must decide on its own. The global+ # override table is empty here, exactly as in a process that has not+ # resolved a runtime config yet -- relying on it left the model hidden.+ declared = _catalog()+ declared["services"]["llm"]["profiles"][1]["models"][0]["capabilities"] = {"vision": True}+ assert vision_by_model(declared)["m3"] is True++ # The declaration also wins when it turns a table-true model off (openrouter+ # m1 is True above), so `option.get("declared_vision") or supports_vision(...)`+ # cannot pass the suite.+ disabled = _catalog()+ disabled["services"]["llm"]["profiles"][0]["models"][0]["capabilities"] = {"vision": False}+ assert vision_by_model(disabled)["m1"] is False++def test_apply_llm_selection_to_catalog_returns_copy_with_selected_active_ids():selected = apply_llm_selection_to_catalog(_catalog(), LLMSelection(profile_id="p2", model_id="m3")