Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

feat(settings): the task model is a service, configured like the LLM

Bingxi Zhao (Frank)5218e1da4982
diff --git a/deeptutor/api/routers/settings.py b/deeptutor/api/routers/settings.py
index dedae3aff..ab964b205 100644
--- a/deeptutor/api/routers/settings.py
+++ b/deeptutor/api/routers/settings.py
@@ -585,6 +585,8 @@ def _provider_choices() -> dict[str, list[dict[str, Any]]]:
)
return {
"llm": llm,
+ # Same shape, same vendors: the task service stands in for the LLM.
+ "task": llm,
"embedding": embedding,
"search": search,
"tts": tts,
diff --git a/deeptutor/services/config/model_catalog.py b/deeptutor/services/config/model_catalog.py
index 2314f979c..5c8beb182 100644
--- a/deeptutor/services/config/model_catalog.py
+++ b/deeptutor/services/config/model_catalog.py
@@ -140,18 +140,30 @@ def _search_shell() -> dict[str, Any]:
}
-# LLM work the product does on the user's behalf rather than in a turn they
-# started: naming a conversation, proposing the three lines under the home
-# composer. Both are short, frequent and latency-visible, so they are worth
-# pointing at a small fast model — but only when the user says so. An entry
-# missing (or with blank ids) means "inherit whatever the chat is using".
-LLM_TASKS: tuple[str, ...] = ("session_title", "starters")
-
+# Every service the catalog holds, in the order the settings UI lists them.
+SERVICE_NAMES: tuple[str, ...] = (
+ "llm",
+ "task",
+ "embedding",
+ "search",
+ "tts",
+ "stt",
+ "imagegen",
+ "videogen",
+)
# Services whose profiles a connection can supply credentials to. ``search``
# is excluded: its providers are a different namespace (Brave, Tavily, ...)
# that happens to overlap by name with a handful of model vendors only.
-CONNECTABLE_SERVICES: tuple[str, ...] = ("llm", "embedding", "tts", "stt", "imagegen", "videogen")
+CONNECTABLE_SERVICES: tuple[str, ...] = (
+ "llm",
+ "task",
+ "embedding",
+ "tts",
+ "stt",
+ "imagegen",
+ "videogen",
+)
# Where a connection's API base has to grow a path before a service's adapter
# can post to it. Voice/generation adapters append their own path to an API
@@ -172,13 +184,8 @@ def _default_catalog() -> dict[str, Any]:
"version": 1,
"connections": [],
"services": {
- "llm": _service_shell(),
- "embedding": _service_shell(),
- "search": _search_shell(),
- "tts": _service_shell(),
- "stt": _service_shell(),
- "imagegen": _service_shell(),
- "videogen": _service_shell(),
+ name: _search_shell() if name == "search" else _service_shell()
+ for name in SERVICE_NAMES
},
}
@@ -257,43 +264,18 @@ class ModelCatalogService:
current = self.save(catalog or self.load())
return {"catalog_path": str(self.path), "services": list(current.get("services", {}))}
- def _normalize_llm_tasks(self, catalog: dict[str, Any]) -> bool:
- """Keep task-model pointers honest: unknown targets fall back to inherit."""
+ def _drop_legacy_llm_tasks(self, catalog: dict[str, Any]) -> bool:
+ """Remove the short-lived per-task pointers under ``services.llm``.
+
+ Task models briefly lived there as two independent {profile, model}
+ references. They are one service now — configured exactly like the LLM
+ it stands in for — so the old key is dead weight.
+ """
service = catalog.get("services", {}).get("llm", {})
- if not isinstance(service, dict):
- return False
- if "tasks" not in service:
- return False
- raw = service["tasks"]
- if not isinstance(raw, dict):
- service["tasks"] = {}
+ if isinstance(service, dict) and "tasks" in service:
+ service.pop("tasks")
return True
- available = {
- str(profile.get("id")): {
- str(model.get("id")) for model in profile.get("models", []) or []
- }
- for profile in service.get("profiles", []) or []
- if isinstance(profile, dict)
- }
- changed = False
- for task in list(raw):
- if task not in LLM_TASKS:
- raw.pop(task)
- changed = True
- continue
- entry = raw[task]
- if not isinstance(entry, dict):
- raw.pop(task)
- changed = True
- continue
- profile_id = str(entry.get("profile_id") or "")
- model_id = str(entry.get("model_id") or "")
- # A profile or model deleted out from under a task pointer must not
- # strand it: an unresolvable task silently reverts to inheriting.
- if not profile_id or model_id not in available.get(profile_id, set()):
- raw.pop(task)
- changed = True
- return changed
+ return False
def _normalize_connections(self, catalog: dict[str, Any]) -> dict[str, dict[str, Any]]:
"""Fill in connection defaults and return them keyed by id."""
@@ -362,14 +344,9 @@ class ModelCatalogService:
services = catalog.setdefault("services", {})
changed = False
connections = self._normalize_connections(catalog)
- services.setdefault("llm", _service_shell())
- services.setdefault("embedding", _service_shell())
- services.setdefault("search", _search_shell())
- services.setdefault("tts", _service_shell())
- services.setdefault("stt", _service_shell())
- services.setdefault("imagegen", _service_shell())
- services.setdefault("videogen", _service_shell())
- for service_name in ("llm", "embedding", "search", "tts", "stt", "imagegen", "videogen"):
+ for name in SERVICE_NAMES:
+ services.setdefault(name, _search_shell() if name == "search" else _service_shell())
+ for service_name in SERVICE_NAMES:
service = services[service_name]
profiles = service.setdefault("profiles", [])
for profile in profiles:
@@ -439,14 +416,14 @@ class ModelCatalogService:
if profiles and service.get("active_profile_id") not in profile_ids:
service["active_profile_id"] = profiles[0]["id"]
changed = True
- if service_name in {"llm", "embedding", "tts", "stt", "imagegen", "videogen"}:
+ if service_name != "search":
active_profile = self.get_active_profile(catalog, service_name)
models = (active_profile or {}).get("models") or []
model_ids = {model.get("id") for model in models}
if models and service.get("active_model_id") not in model_ids:
service["active_model_id"] = models[0]["id"]
changed = True
- if self._normalize_llm_tasks(catalog):
+ if self._drop_legacy_llm_tasks(catalog):
changed = True
return changed
@@ -494,7 +471,7 @@ __all__ = [
"CATALOG_PATH",
"CATALOG_SECRET_MASK",
"CONNECTABLE_SERVICES",
- "LLM_TASKS",
+ "SERVICE_NAMES",
"ModelCatalogService",
"get_model_catalog_service",
"redact_catalog_secrets",
diff --git a/deeptutor/services/config/provider_runtime.py b/deeptutor/services/config/provider_runtime.py
index fdb24566e..59dc56dbc 100644
--- a/deeptutor/services/config/provider_runtime.py
+++ b/deeptutor/services/config/provider_runtime.py
@@ -728,8 +728,17 @@ def resolve_llm_runtime_config(
*,
service: ModelCatalogService | None = None,
llm_selection: dict[str, Any] | LLMSelection | None = None,
+ service_name: str = "llm",
) -> ResolvedLLMConfig:
- """Resolve active LLM config with TutorBot-style provider matching."""
+ """Resolve active LLM config with TutorBot-style provider matching.
+
+ ``service_name`` selects which catalog service supplies the profile and
+ model. It is ``llm`` for everything the user drives; the ``task`` service
+ is the same shape and stands in for it on the calls DeepTutor makes on its
+ own. The provider pool it falls back to stays the LLM one either way —
+ a task profile that names a bare model still resolves against the
+ credentials configured for chat.
+ """
catalog_service = service or get_model_catalog_service()
loaded = _with_personal_llm_profiles(_load_catalog(catalog))
# Parse the payload once: ``apply_llm_selection_to_catalog`` would otherwise
@@ -738,7 +747,7 @@ def resolve_llm_runtime_config(
selection = LLMSelection.from_payload(llm_selection)
loaded = apply_llm_selection_to_catalog(loaded, selection)
- profile, model = _active_profile_and_model(loaded, catalog_service, "llm")
+ profile, model = _active_profile_and_model(loaded, catalog_service, service_name)
resolved_model = _as_str((model or {}).get("model"))
binding_hint_raw = _as_str((profile or {}).get("binding"))
diff --git a/deeptutor/services/model_selection/tasks.py b/deeptutor/services/model_selection/tasks.py
index 41b6bfb43..d84148850 100644
--- a/deeptutor/services/model_selection/tasks.py
+++ b/deeptutor/services/model_selection/tasks.py
@@ -1,21 +1,21 @@
-"""Task models — the LLM behind work the product does on its own.
-
-Two calls happen without anyone asking for them: naming a conversation once it
-has its first exchange, and proposing the three starting points under the home
-composer. Both are short, both are frequent, and neither benefits from the
-model a learner picked for their actual reasoning — a small fast model writes a
-four-word title just as well and costs a fraction as much.
-
-So each of these is a *task* that can be pointed at its own configured model.
-Pointing is optional and that matters more than the feature: with nothing set
-(the state every existing install is in) the scope below is a no-op, and both
-call sites keep resolving exactly the LLM they resolved before — for the title
-that is the model the turn itself is running on, for the starters the active
-default. Nothing changes until someone chooses to change it.
-
-Failure inherits too. A task pointing at a deleted profile, a catalog that will
-not load, a malformed entry — none of that is worth failing a title over, so
-every error path here falls back to the ambient config rather than raising.
+"""The task model — what DeepTutor runs on when nobody asked it to run.
+
+Two calls happen without anyone requesting them: naming a conversation once it
+has its first exchange, and writing the three starting points under the home
+composer. Both are short, frequent and latency-visible, and neither benefits
+from the model a learner picked for their actual reasoning — a small fast model
+writes a four-word title just as well and costs a fraction as much.
+
+So the catalog carries a ``task`` service, shaped exactly like ``llm``:
+providers with credentials, models under them, one of each in use. Configuring
+it is the same act as configuring the LLM because it is the same kind of thing,
+and a provider can be brought over from the LLM service rather than typed again.
+
+Leaving it empty is the default and the common case. Then the scope below is a
+no-op and both calls resolve what they always did — for the title, the model
+the turn itself is running on; for the starters, the active default. Failure
+inherits too: a task profile pointing at nothing, a catalog that will not load,
+a provider that no longer works — none of that is worth failing a title over.
"""
from __future__ import annotations
@@ -25,77 +25,74 @@ from contextlib import contextmanager
import logging
from typing import Any
-from deeptutor.services.config.model_catalog import LLM_TASKS, get_model_catalog_service
+from deeptutor.services.config.model_catalog import get_model_catalog_service
from deeptutor.services.llm.config import LLMConfig
-from .llm import LLMSelection
-from .runtime import activate_llm_selection, reset_llm_selection
-
logger = logging.getLogger(__name__)
-TASK_SESSION_TITLE = "session_title"
-TASK_STARTERS = "starters"
-
+TASK_SERVICE = "task"
-def _llm_tasks(catalog: dict[str, Any]) -> dict[str, Any]:
- services = catalog.get("services")
- if not isinstance(services, dict):
- return {}
- llm = services.get("llm")
- if not isinstance(llm, dict):
- return {}
- tasks = llm.get("tasks")
- return tasks if isinstance(tasks, dict) else {}
-
-def resolve_task_selection(
- task: str,
- catalog: dict[str, Any] | None = None,
-) -> LLMSelection | None:
- """Return the model a task is pinned to, or ``None`` to inherit."""
- if task not in LLM_TASKS:
- return None
+def task_service_configured(catalog: dict[str, Any] | None = None) -> bool:
+ """Whether the task service names a model of its own."""
try:
loaded = catalog if catalog is not None else get_model_catalog_service().load()
- entry = _llm_tasks(loaded).get(task)
- if not isinstance(entry, dict):
- return None
- return LLMSelection.from_payload(
- {"profile_id": entry.get("profile_id"), "model_id": entry.get("model_id")}
+ service = loaded.get("services", {}).get(TASK_SERVICE, {})
+ if not isinstance(service, dict):
+ return False
+ profile_id = service.get("active_profile_id")
+ profile = next(
+ (
+ item
+ for item in service.get("profiles", []) or []
+ if isinstance(item, dict) and item.get("id") == profile_id
+ ),
+ None,
+ )
+ if profile is None:
+ return False
+ model_id = service.get("active_model_id")
+ return any(
+ isinstance(model, dict)
+ and model.get("id") == model_id
+ and str(model.get("model") or "").strip()
+ for model in profile.get("models", []) or []
)
except Exception:
- logger.debug("Task model lookup failed for %s — inheriting", task, exc_info=True)
- return None
+ logger.debug("Task service lookup failed — inheriting", exc_info=True)
+ return False
@contextmanager
-def task_llm_scope(task: str) -> Iterator[LLMConfig | None]:
- """Install the task's LLM for the duration of the block.
+def task_llm_scope() -> Iterator[LLMConfig | None]:
+ """Install the task model for the duration of the block.
- Yields the config that was installed, or ``None`` when the task inherits —
- which callers can log but never have to branch on.
+ Yields the config that was installed, or ``None`` when the task service is
+ empty and the call inherits — which callers can log but never have to
+ branch on.
"""
- selection = resolve_task_selection(task)
- if selection is None:
+ if not task_service_configured():
yield None
return
+
+ from deeptutor.services.config.provider_runtime import resolve_llm_runtime_config
+ from deeptutor.services.llm import config as llm_config_module
+
+ from .runtime import llm_config_from_resolved
+
try:
- config, token = activate_llm_selection(selection)
+ config = llm_config_from_resolved(resolve_llm_runtime_config(service_name=TASK_SERVICE))
+ token = llm_config_module.set_scoped_llm_config(config)
except Exception:
- # The pointer resolved but the profile behind it no longer works.
- # Inheriting is strictly better than not writing a title at all.
- logger.debug("Task model activation failed for %s — inheriting", task, exc_info=True)
+ # Configured but unusable. Inheriting is strictly better than not
+ # writing a title at all.
+ logger.debug("Task model activation failed — inheriting", exc_info=True)
yield None
return
try:
yield config
finally:
- reset_llm_selection(token)
+ llm_config_module.reset_scoped_llm_config(token)
-__all__ = [
- "TASK_SESSION_TITLE",
- "TASK_STARTERS",
- "resolve_task_selection",
- "task_llm_scope",
-]
+__all__ = ["TASK_SERVICE", "task_llm_scope", "task_service_configured"]
diff --git a/deeptutor/services/session/turn_runtime.py b/deeptutor/services/session/turn_runtime.py
index bc7379f78..598c24b2c 100644
--- a/deeptutor/services/session/turn_runtime.py
+++ b/deeptutor/services/session/turn_runtime.py
@@ -2594,10 +2594,10 @@ class TurnRuntimeManager:
Runs only when the session still carries the ``New conversation``
sentinel — once a user manually renames the chat (or this method
- has already filled in a title), it short-circuits. Uses the model
- pinned in Settings > Task models when there is one, and otherwise
- the LLM scope already active on the calling task, which is the
- user's currently selected model.
+ has already filled in a title), it short-circuits. Runs on the task
+ model when one is configured, and otherwise on the LLM scope already
+ active on the calling task, which is the user's currently selected
+ model.
"""
if not session_id:
return
@@ -2666,14 +2666,11 @@ class TurnRuntimeManager:
buf.append(c)
return "".join(buf)
- from deeptutor.services.model_selection.tasks import (
- TASK_SESSION_TITLE,
- task_llm_scope,
- )
+ from deeptutor.services.model_selection.tasks import task_llm_scope
# The scope is entered before the task is created so `wait_for`'s
- # inner task copies it; leaving it un-pinned yields a no-op.
- with task_llm_scope(TASK_SESSION_TITLE):
+ # inner task copies it; with no task model configured it is a no-op.
+ with task_llm_scope():
raw_title = await asyncio.wait_for(_collect_title(), timeout=20.0)
title = _sanitize_session_title(raw_title)
except asyncio.TimeoutError:
diff --git a/deeptutor/services/suggestions.py b/deeptutor/services/suggestions.py
index b28f859af..7251027d1 100644
--- a/deeptutor/services/suggestions.py
+++ b/deeptutor/services/suggestions.py
@@ -556,11 +556,11 @@ async def _generate(language: str, material: _Material) -> SuggestionSet:
try:
from deeptutor.services.llm import complete
- from deeptutor.services.model_selection.tasks import TASK_STARTERS, task_llm_scope
+ from deeptutor.services.model_selection.tasks import task_llm_scope
- # Pinned to its own model when Settings > Task models says so, and to
- # the active default otherwise — which is what this always did.
- with task_llm_scope(TASK_STARTERS):
+ # Runs on the task model when one is configured, and on the active
+ # default otherwise — which is what this always did.
+ with task_llm_scope():
raw = await asyncio.wait_for(
complete(
prompt=user_prompt,
diff --git a/tests/services/config/test_runtime_settings.py b/tests/services/config/test_runtime_settings.py
index 8b4fd6b2d..98a6657cb 100644
--- a/tests/services/config/test_runtime_settings.py
+++ b/tests/services/config/test_runtime_settings.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import json
from pathlib import Path
+from deeptutor.services.config.model_catalog import SERVICE_NAMES
from deeptutor.services.config.runtime_settings import (
RuntimeSettingsService,
ensure_runtime_settings_files,
@@ -235,15 +236,7 @@ def test_startup_ensure_creates_missing_runtime_jsons_with_defaults(
assert _read_json(settings_dir / "system.json")["backend_port"] == 8001
assert _read_json(settings_dir / "auth.json")["enabled"] is False
assert _read_json(settings_dir / "integrations.json")["pocketbase_url"] == ""
- assert set(_read_json(settings_dir / "model_catalog.json")["services"]) == {
- "llm",
- "embedding",
- "search",
- "tts",
- "stt",
- "imagegen",
- "videogen",
- }
+ assert set(_read_json(settings_dir / "model_catalog.json")["services"]) == set(SERVICE_NAMES)
def test_mineru_defaults_and_normalization(tmp_path: Path) -> None:
diff --git a/tests/services/test_model_catalog.py b/tests/services/test_model_catalog.py
index a471fe44e..30bbd406d 100644
--- a/tests/services/test_model_catalog.py
+++ b/tests/services/test_model_catalog.py
@@ -2,7 +2,7 @@ from concurrent.futures import ThreadPoolExecutor
import json
from pathlib import Path
-from deeptutor.services.config.model_catalog import ModelCatalogService
+from deeptutor.services.config.model_catalog import SERVICE_NAMES, ModelCatalogService
def test_load_creates_empty_catalog_without_dotenv_hydration(tmp_path: Path):
@@ -105,15 +105,9 @@ def test_load_recovers_invalid_catalog_with_defaults(tmp_path: Path):
catalog = ModelCatalogService(path=catalog_path).load()
- expected_services = {
- "llm",
- "embedding",
- "search",
- "tts",
- "stt",
- "imagegen",
- "videogen",
- }
+ # Derived rather than re-listed: a new service should not need this test
+ # edited to keep passing, only the one that describes it.
+ expected_services = set(SERVICE_NAMES)
assert set(catalog["services"]) == expected_services
saved = json.loads(catalog_path.read_text(encoding="utf-8"))
assert set(saved["services"]) == expected_services
diff --git a/tests/services/test_task_model_call_sites.py b/tests/services/test_task_model_call_sites.py
index e8c863574..64f57f47f 100644
--- a/tests/services/test_task_model_call_sites.py
+++ b/tests/services/test_task_model_call_sites.py
@@ -1,7 +1,7 @@
"""The two task call sites actually run inside the scope they claim to.
-Pinning a task model is only worth anything if the LLM call at the other end
-resolves the pinned config. Both tests assert the model *observed from inside
+Configuring a task model is only worth anything if the LLM call at the other
+end resolves it. Both tests assert the model *observed from inside
the call*: a scope wrapped around the wrong statement, or a call site that was
never wired at all, still looks correct from the outside.
"""
@@ -27,8 +27,8 @@ class _FakePathService:
return self._root / "settings" / f"{name}.json"
-def _pin(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, tasks: dict[str, Any]) -> None:
- """Point every catalog reader at a tmp catalog with *tasks* pinned.
+def _pin(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, task_model: str | None) -> None:
+ """Point every catalog reader at a tmp catalog, optionally with a task model.
Patching the path service rather than ``get_model_catalog_service`` is
deliberate: several modules import that function by value, so patching it
@@ -54,7 +54,19 @@ def _pin(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, tasks: dict[str, Any])
]
catalog["services"]["llm"]["active_profile_id"] = "llm-1"
catalog["services"]["llm"]["active_model_id"] = "model-default"
- catalog["services"]["llm"]["tasks"] = tasks
+ if task_model:
+ catalog["services"]["task"]["profiles"] = [
+ {
+ "id": "task-1",
+ "name": "OpenAI",
+ "binding": "openai",
+ "base_url": "https://api.openai.com/v1",
+ "api_key": "sk-test",
+ "models": [{"id": "task-model", "model": task_model}],
+ }
+ ]
+ catalog["services"]["task"]["active_profile_id"] = "task-1"
+ catalog["services"]["task"]["active_model_id"] = "task-model"
service.save(catalog)
# get_instance memoizes per resolved path; every reader must land on the
@@ -72,10 +84,10 @@ def _clear_llm_cache() -> Any:
clear_llm_config_cache()
-def test_starter_generation_calls_the_pinned_model(
+def test_starter_generation_calls_the_task_model(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
- _pin(tmp_path, monkeypatch, {"starters": {"profile_id": "llm-1", "model_id": "model-task"}})
+ _pin(tmp_path, monkeypatch, "gpt-5-mini")
from deeptutor.services import suggestions
import deeptutor.services.llm as llm
@@ -97,10 +109,10 @@ def test_starter_generation_calls_the_pinned_model(
assert observed == ["gpt-5-mini"]
-def test_starter_generation_inherits_when_unpinned(
+def test_starter_generation_inherits_when_unconfigured(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
- _pin(tmp_path, monkeypatch, {})
+ _pin(tmp_path, monkeypatch, None)
from deeptutor.services import suggestions
import deeptutor.services.llm as llm
@@ -169,12 +181,10 @@ def _run_title(monkeypatch: pytest.MonkeyPatch, observed: list[str]) -> _Runtime
return runtime
-def test_title_generation_calls_the_pinned_model(
+def test_title_generation_calls_the_task_model(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
- _pin(
- tmp_path, monkeypatch, {"session_title": {"profile_id": "llm-1", "model_id": "model-task"}}
- )
+ _pin(tmp_path, monkeypatch, "gpt-5-mini")
observed: list[str] = []
runtime = _run_title(monkeypatch, observed)
@@ -183,10 +193,10 @@ def test_title_generation_calls_the_pinned_model(
assert runtime.store.title == "Chain rule basics"
-def test_title_generation_inherits_the_turn_model_when_unpinned(
+def test_title_generation_inherits_the_turn_model_when_unconfigured(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
- _pin(tmp_path, monkeypatch, {})
+ _pin(tmp_path, monkeypatch, None)
from deeptutor.services.llm.config import (
LLMConfig,
diff --git a/tests/services/test_task_models.py b/tests/services/test_task_models.py
index ef738a41b..12b7f7773 100644
--- a/tests/services/test_task_models.py
+++ b/tests/services/test_task_models.py
@@ -1,4 +1,4 @@
-"""Task models: pinned when asked for, inherited in every other case."""
+"""The task service: configured like the LLM, inherited when empty."""
from __future__ import annotations
@@ -6,77 +6,130 @@ from pathlib import Path
from typing import Any
from deeptutor.services.config.model_catalog import ModelCatalogService
-from deeptutor.services.model_selection.tasks import (
- TASK_SESSION_TITLE,
- TASK_STARTERS,
- resolve_task_selection,
-)
+from deeptutor.services.model_selection.tasks import task_service_configured
-def _catalog_with_tasks(service: ModelCatalogService, tasks: dict[str, Any]) -> dict[str, Any]:
+def _catalog(service: ModelCatalogService, **task: Any) -> dict[str, Any]:
catalog = service.load()
catalog["services"]["llm"]["profiles"] = [
{
"id": "llm-1",
- "name": "OpenRouter",
- "binding": "openrouter",
- "base_url": "https://openrouter.ai/api/v1",
- "api_key": "sk-or",
- "models": [
- {"id": "model-big", "model": "anthropic/claude-opus-4"},
- {"id": "model-small", "model": "openai/gpt-5-mini"},
- ],
+ "name": "OpenAI",
+ "binding": "openai",
+ "base_url": "https://api.openai.com/v1",
+ "api_key": "sk-live",
+ "models": [{"id": "llm-model", "model": "gpt-5"}],
}
]
- catalog["services"]["llm"]["tasks"] = tasks
+ catalog["services"]["llm"]["active_profile_id"] = "llm-1"
+ catalog["services"]["llm"]["active_model_id"] = "llm-model"
+ catalog["services"]["task"].update(task)
return catalog
-def test_a_pinned_task_resolves_to_its_profile_and_model(tmp_path: Path) -> None:
+def test_the_task_service_exists_and_starts_empty(tmp_path: Path) -> None:
service = ModelCatalogService(path=tmp_path / "model_catalog.json")
- catalog = service.save(
- _catalog_with_tasks(
- service,
- {TASK_STARTERS: {"profile_id": "llm-1", "model_id": "model-small"}},
- )
- )
- selection = resolve_task_selection(TASK_STARTERS, catalog)
+ catalog = service.load()
- assert selection is not None
- assert (selection.profile_id, selection.model_id) == ("llm-1", "model-small")
+ assert catalog["services"]["task"] == {
+ "active_profile_id": None,
+ "active_model_id": None,
+ "profiles": [],
+ }
+ assert not task_service_configured(catalog)
-def test_an_unpinned_task_inherits(tmp_path: Path) -> None:
+def test_an_empty_task_service_inherits(tmp_path: Path) -> None:
service = ModelCatalogService(path=tmp_path / "model_catalog.json")
- catalog = service.save(_catalog_with_tasks(service, {}))
- assert resolve_task_selection(TASK_SESSION_TITLE, catalog) is None
+ catalog = service.save(_catalog(service))
+
+ assert not task_service_configured(catalog)
-def test_a_task_pointing_at_a_deleted_model_falls_back_to_inheriting(tmp_path: Path) -> None:
+def test_a_configured_task_service_is_used(tmp_path: Path) -> None:
service = ModelCatalogService(path=tmp_path / "model_catalog.json")
catalog = service.save(
- _catalog_with_tasks(
+ _catalog(
service,
- {TASK_SESSION_TITLE: {"profile_id": "llm-1", "model_id": "model-deleted"}},
+ profiles=[
+ {
+ "id": "task-1",
+ "name": "OpenAI",
+ "binding": "openai",
+ "base_url": "https://api.openai.com/v1",
+ "api_key": "sk-live",
+ "models": [{"id": "task-model", "model": "gpt-5-mini"}],
+ }
+ ],
+ active_profile_id="task-1",
+ active_model_id="task-model",
)
)
- # Normalization drops the dangling pointer rather than leaving a task
- # aimed at a model that no longer exists.
- assert catalog["services"]["llm"]["tasks"] == {}
- assert resolve_task_selection(TASK_SESSION_TITLE, catalog) is None
+ assert task_service_configured(catalog)
-def test_unknown_task_names_are_dropped(tmp_path: Path) -> None:
+def test_a_profile_without_a_model_id_still_inherits(tmp_path: Path) -> None:
+ """Half-configured is not configured — a blank model would resolve to nothing."""
service = ModelCatalogService(path=tmp_path / "model_catalog.json")
catalog = service.save(
- _catalog_with_tasks(
+ _catalog(
service,
- {"not_a_task": {"profile_id": "llm-1", "model_id": "model-big"}},
+ profiles=[
+ {
+ "id": "task-1",
+ "name": "OpenAI",
+ "binding": "openai",
+ "api_key": "sk-live",
+ "models": [{"id": "task-model", "model": ""}],
+ }
+ ],
+ active_profile_id="task-1",
+ active_model_id="task-model",
)
)
- assert catalog["services"]["llm"]["tasks"] == {}
- assert resolve_task_selection("not_a_task", catalog) is None
+ assert not task_service_configured(catalog)
+
+
+def test_the_task_service_resolves_its_own_model(tmp_path: Path) -> None:
+ from deeptutor.services.config.provider_runtime import resolve_llm_runtime_config
+
+ service = ModelCatalogService(path=tmp_path / "model_catalog.json")
+ catalog = service.save(
+ _catalog(
+ service,
+ profiles=[
+ {
+ "id": "task-1",
+ "name": "OpenAI",
+ "binding": "openai",
+ "base_url": "https://api.openai.com/v1",
+ "api_key": "sk-task",
+ "models": [{"id": "task-model", "model": "gpt-5-mini"}],
+ }
+ ],
+ active_profile_id="task-1",
+ active_model_id="task-model",
+ )
+ )
+
+ task = resolve_llm_runtime_config(catalog, service=service, service_name="task")
+ llm = resolve_llm_runtime_config(catalog, service=service)
+
+ assert task.model == "gpt-5-mini"
+ assert llm.model == "gpt-5"
+
+
+def test_the_short_lived_per_task_pins_are_dropped(tmp_path: Path) -> None:
+ service = ModelCatalogService(path=tmp_path / "model_catalog.json")
+ catalog = _catalog(service)
+ catalog["services"]["llm"]["tasks"] = {
+ "session_title": {"profile_id": "llm-1", "model_id": "llm-model"}
+ }
+
+ saved = service.save(catalog)
+
+ assert "tasks" not in saved["services"]["llm"]
diff --git a/web/app/(utility)/settings/task-models/page.tsx b/web/app/(utility)/settings/task-models/page.tsx
index f36f78f78..cb7b5f304 100644
--- a/web/app/(utility)/settings/task-models/page.tsx
+++ b/web/app/(utility)/settings/task-models/page.tsx
@@ -12,7 +12,7 @@ export default function TaskModelsSettingsPage() {
<SettingsPageHeader
title={t("Task models")}
description={t(
- "The model behind work DeepTutor starts on its own, rather than in a turn you asked for.",
+ "Conversation titles and home screen starting points. Configured like the LLM — pick a provider, then a model. Left empty, both use the LLM.",
)}
/>
<TaskModelsEditor />
diff --git a/web/components/settings/ConnectionsEditor.tsx b/web/components/settings/ConnectionsEditor.tsx
index 46122b361..3958aa8ed 100644
--- a/web/components/settings/ConnectionsEditor.tsx
+++ b/web/components/settings/ConnectionsEditor.tsx
@@ -42,6 +42,7 @@ import { inputClass, selectClass, selectOptionClass } from "./shared";
const SERVICE_LABEL: Record<ServiceName, { en: string; zh: string }> = {
llm: { en: "LLM", zh: "LLM" },
+ task: { en: "Task model", zh: "任务模型" },
embedding: { en: "Embedding", zh: "嵌入模型" },
search: { en: "Search", zh: "搜索" },
tts: { en: "Text-to-Speech", zh: "语音合成" },
@@ -52,6 +53,7 @@ const SERVICE_LABEL: Record<ServiceName, { en: string; zh: string }> = {
const SERVICE_HREF: Record<ServiceName, string> = {
llm: "/settings/llm",
+ task: "/settings/task-models",
embedding: "/settings/embedding",
search: "/settings/search",
tts: "/settings/tts",
diff --git a/web/components/settings/ModelCards.tsx b/web/components/settings/ModelCards.tsx
index d2183ed72..48237a0f4 100644
--- a/web/components/settings/ModelCards.tsx
+++ b/web/components/settings/ModelCards.tsx
@@ -1,6 +1,13 @@
"use client";
-import { ArrowLeft, Check, ChevronDown, Plus, Trash2 } from "lucide-react";
+import {
+ ArrowLeft,
+ Check,
+ ChevronDown,
+ ChevronRight,
+ Plus,
+ Trash2,
+} from "lucide-react";
import { useTranslation } from "react-i18next";
import ProviderIcon from "@/components/common/ProviderIcon";
@@ -116,7 +123,15 @@ export function AddCard({
);
}
-/** Shared chrome: the frame, the name row and the expand affordance. */
+/**
+ * Shared chrome: the frame, the name row and the expand affordance.
+ *
+ * A card that opens carries a chevron in its lower-right and lifts its border
+ * and tint on hover — without that it read as a panel that happened to be
+ * clickable, which is the same as not clickable. Cards that do not open (a
+ * search provider has no models under it) draw no chevron, so the two kinds
+ * are told apart before you click rather than after.
+ */
function CardShell({
expanded,
inUse,
@@ -130,13 +145,17 @@ function CardShell({
}) {
return (
<div
- className={`group relative flex min-h-[86px] flex-col justify-between gap-2 rounded-xl border p-3 transition-colors ${
+ className={`group relative flex min-h-[86px] flex-col justify-between gap-2 rounded-xl border p-3 transition-[background-color,border-color,transform] duration-150 ${
expanded
? "border-[var(--foreground)]/25 bg-[var(--accent)]/40"
: inUse
? "border-[var(--border)] bg-[var(--accent)]/25"
: "border-[var(--border)]/70"
- } ${onOpen ? "cursor-pointer hover:border-[var(--foreground)]/25 hover:bg-[var(--accent)]/30" : ""}`}
+ } ${
+ onOpen
+ ? "cursor-pointer hover:border-[var(--foreground)]/40 hover:bg-[var(--accent)]/45 active:scale-[0.995]"
+ : ""
+ }`}
onClick={onOpen}
role={onOpen ? "button" : undefined}
tabIndex={onOpen ? 0 : undefined}
@@ -152,6 +171,12 @@ function CardShell({
}
>
{children}
+ {onOpen && (
+ <ChevronRight
+ aria-hidden
+ className="pointer-events-none absolute bottom-2.5 right-2.5 h-3.5 w-3.5 text-[var(--muted-foreground)]/35 transition-all duration-150 group-hover:translate-x-0.5 group-hover:text-[var(--foreground)]/70"
+ />
+ )}
</div>
);
}
@@ -325,15 +350,17 @@ export function ProfileCard({
{endpoint || t("Provider default endpoint")}
</p>
</div>
- <UseRow
- inUse={inUse}
- onUse={onUse}
- detail={
- service === "search"
- ? undefined
- : t("{{count}} models", { count })
- }
- />
+ <div className={onOpen ? "pr-5" : ""}>
+ <UseRow
+ inUse={inUse}
+ onUse={onUse}
+ detail={
+ service === "search"
+ ? undefined
+ : t("{{count}} models", { count })
+ }
+ />
+ </div>
</CardShell>
);
}
diff --git a/web/components/settings/ServiceConfigEditor.tsx b/web/components/settings/ServiceConfigEditor.tsx
index 2a7c5001d..ee8cd6924 100644
--- a/web/components/settings/ServiceConfigEditor.tsx
+++ b/web/components/settings/ServiceConfigEditor.tsx
@@ -66,6 +66,7 @@ import {
const SERVICE_LABEL: Record<ServiceName, string> = {
llm: "LLM",
+ task: "Task model",
embedding: "Embedding",
search: "Search",
tts: "Text-to-Speech",
@@ -573,7 +574,7 @@ export function ServiceConfigEditor({ service }: { service: ServiceName }) {
</>
)}
- <div className="min-w-0 space-y-7">
+ <div className="mt-7 min-w-0 space-y-7">
{expandedProfile && !openedProfile && (
<div className="mt-4">
<div className="mb-2.5 flex items-center justify-between gap-2 border-b border-[var(--border)]/60 pb-2">
@@ -1017,16 +1018,16 @@ export function ServiceConfigEditor({ service }: { service: ServiceName }) {
</div>
</div>
) : (
- <div className="flex flex-col items-center gap-3 rounded-xl border border-dashed border-[var(--border)] px-5 py-12 text-center text-[13px] text-[var(--muted-foreground)]">
- <div>{t("No profiles configured. Add a profile to start.")}</div>
- <button
- type="button"
- onClick={() => addProfile(service)}
- className="inline-flex items-center gap-1 rounded-lg border border-[var(--border)]/50 px-2.5 py-1 text-[12px] text-[var(--muted-foreground)] transition-colors hover:border-[var(--border)] hover:text-[var(--foreground)]"
- >
- <Plus className="h-3 w-3" />
- {t("Profile")}
- </button>
+ // Zero state in the same language as the populated one: the grid with
+ // only its add card in it, so starting out looks like what comes next.
+ <div>
+ <SectionHead title={t("Providers")} />
+ <CardGrid>
+ <AddCard
+ label={t("Add provider")}
+ onClick={() => addProfile(service)}
+ />
+ </CardGrid>
</div>
)}
</div>
diff --git a/web/components/settings/SettingsContext.tsx b/web/components/settings/SettingsContext.tsx
index da9c62903..31e2bdbbc 100644
--- a/web/components/settings/SettingsContext.tsx
+++ b/web/components/settings/SettingsContext.tsx
@@ -33,6 +33,8 @@ import { setTheme as applyThemePreference } from "@/lib/theme";
export type ServiceName =
| "llm"
+ /** Same shape as `llm`; stands in for it on the calls DeepTutor makes itself. */
+ | "task"
| "embedding"
| "search"
| "tts"
@@ -98,22 +100,10 @@ export type CatalogProfile = {
models: CatalogModel[];
};
-/**
- * LLM work the product starts on its own — naming a conversation, writing the
- * three starting points under the home composer. Blank ids mean "inherit".
- */
-export type LlmTaskKey = "session_title" | "starters";
-
-export const LLM_TASK_KEYS: LlmTaskKey[] = ["session_title", "starters"];
-
-export type LlmTaskSelection = { profile_id: string; model_id: string };
-
export type CatalogService = {
active_profile_id: string | null;
active_model_id?: string | null;
profiles: CatalogProfile[];
- /** LLM only: per-task model pins. Absent entry = inherit. */
- tasks?: Partial<Record<LlmTaskKey, LlmTaskSelection>>;
};
/**
@@ -152,6 +142,7 @@ export type ConnectionTarget = {
/** Services a connection can supply, in the order the UI lists them. */
export const CONNECTABLE_SERVICES: ServiceName[] = [
"llm",
+ "task",
"embedding",
"tts",
"stt",
@@ -164,6 +155,7 @@ export type Catalog = {
connections?: CatalogConnection[];
services: {
llm: CatalogService;
+ task: CatalogService;
embedding: CatalogService;
search: CatalogService;
tts: CatalogService;
@@ -384,6 +376,7 @@ export function defaultCatalog(): Catalog {
connections: [],
services: {
llm: { active_profile_id: null, active_model_id: null, profiles: [] },
+ task: { active_profile_id: null, active_model_id: null, profiles: [] },
embedding: {
active_profile_id: null,
active_model_id: null,
@@ -623,7 +616,6 @@ type SettingsContextValue = {
>,
requests: { service: ServiceName; model: string }[],
) => { created: ServiceName[]; activated: ServiceName[] };
- setLlmTask: (task: LlmTaskKey, selection: LlmTaskSelection | null) => void;
llmContextDetection: LlmContextWindowDetection | null;
applyDetectedContextWindow: () => void;
@@ -703,6 +695,7 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
Record<ServiceName, ProviderOption[]>
>({
llm: [],
+ task: [],
embedding: [],
search: [],
tts: [],
@@ -1295,21 +1288,6 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
[connectionTargets, draft, mutateCatalog],
);
- // ─── Task models ─────────────────────────────────────────────────────────
-
- const setLlmTask = useCallback(
- (task: LlmTaskKey, selection: LlmTaskSelection | null) => {
- mutateCatalog((next) => {
- const llm = next.services.llm;
- const tasks = { ...(llm.tasks ?? {}) };
- if (selection) tasks[task] = selection;
- else delete tasks[task];
- llm.tasks = tasks;
- });
- },
- [mutateCatalog],
- );
-
const removeActiveModel = useCallback(
(service: ServiceName, profileId?: string, modelId?: string) => {
if (service === "search") return;
@@ -1889,7 +1867,6 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
removeConnection,
unlinkProfile,
linkConnectionToServices,
- setLlmTask,
llmContextDetection,
applyDetectedContextWindow,
saving,
@@ -1947,7 +1924,6 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
removeConnection,
unlinkProfile,
linkConnectionToServices,
- setLlmTask,
providers,
registerExtension,
removeActiveModel,
diff --git a/web/components/settings/TaskModelsEditor.tsx b/web/components/settings/TaskModelsEditor.tsx
index 7b6ac4e1f..d61b1a23e 100644
--- a/web/components/settings/TaskModelsEditor.tsx
+++ b/web/components/settings/TaskModelsEditor.tsx
@@ -1,95 +1,56 @@
"use client";
-import { useMemo } from "react";
+import { useMemo, useState } from "react";
import Link from "next/link";
-import { ArrowUpRight, ChevronDown } from "lucide-react";
+import { ArrowUpRight, ChevronDown, Download } from "lucide-react";
import { useTranslation } from "react-i18next";
import ProviderIcon from "@/components/common/ProviderIcon";
+import { ServiceConfigEditor } from "./ServiceConfigEditor";
import {
- LLM_TASK_KEYS,
- type LlmTaskKey,
+ getActiveModel,
+ getActiveProfile,
useSettings,
} from "./SettingsContext";
import { selectClass, selectOptionClass } from "./shared";
/**
- * Task models — the LLM behind work DeepTutor starts on its own.
+ * Task models — what DeepTutor runs on when nobody asked it to run.
*
- * Two calls happen without anyone asking: naming a conversation after its
- * first exchange, and writing the three starting points under the home
- * composer. Both are short, frequent and latency-visible, and neither needs
- * the model a learner picked for their reasoning.
+ * Naming a conversation and writing the three starting points are the two
+ * calls the product makes on its own. They were briefly two separate pins, one
+ * per call, which asked the user to make a distinction they have no reason to
+ * care about: both are short, frequent, and want the same kind of small fast
+ * model. So it is one setting.
*
- * Inheriting stays the default, and it is a real default rather than a hidden
- * one: with nothing chosen here both calls resolve exactly what they resolved
- * before this page existed.
+ * And it is configured exactly like the LLM, because it is the same kind of
+ * thing — a provider, then a model under it. The catalog gives it its own
+ * service so the whole model editor applies unchanged, and a provider already
+ * set up for chat can be brought over rather than typed again.
+ *
+ * Empty is the default and the common case: with nothing here, both calls
+ * resolve the LLM exactly as they did before this page existed.
*/
-
-const TASK_COPY: Record<
- LlmTaskKey,
- {
- label: { en: string; zh: string };
- desc: { en: string; zh: string };
- inherit: { en: string; zh: string };
- href?: string;
- hrefLabel?: { en: string; zh: string };
- }
-> = {
- session_title: {
- label: { en: "Conversation title", zh: "会话标题" },
- desc: {
- en: "Names a new conversation once it has its first question and answer.",
- zh: "新会话产生第一轮问答后,为它写一个标题。",
- },
- inherit: {
- en: "Follows the conversation's own model",
- zh: "跟随该会话使用的模型",
- },
- },
- starters: {
- label: { en: "Starting points", zh: "起始建议" },
- desc: {
- en: "The three lines offered under the home composer, drawn from recent work.",
- zh: "主页输入框下方那三行建议,来自最近的学习痕迹。",
- },
- inherit: { en: "Follows the active model", zh: "跟随当前模型" },
- href: "/settings/starters",
- hrefLabel: { en: "Material scope", zh: "素材范围" },
- },
-};
-
export function TaskModelsEditor() {
const { t, i18n } = useTranslation();
const zh = i18n.language?.toLowerCase().startsWith("zh");
- const { draft, catalogEditable, settingsError, setLlmTask } = useSettings();
+ const { draft, catalogEditable, settingsError, mutateCatalog } = useSettings();
- const options = useMemo(
- () =>
- draft.services.llm.profiles.flatMap((profile) =>
- profile.models
- .filter((model) => model.model.trim())
- .map((model) => ({
- value: `${profile.id}::${model.id}`,
- profileId: profile.id,
- modelId: model.id,
- binding: profile.binding || "",
- profileName: profile.name,
- model: model.model,
- })),
- ),
+ const [importing, setImporting] = useState(false);
+ const [importFrom, setImportFrom] = useState("");
+
+ const llmProfiles = draft.services.llm.profiles;
+ const configured = draft.services.task.profiles.length > 0;
+
+ const inherited = useMemo(
+ () => ({
+ binding: getActiveProfile(draft, "llm")?.binding ?? "",
+ model: getActiveModel(draft, "llm")?.model ?? "",
+ }),
[draft],
);
- const activeValue = useMemo(() => {
- const llm = draft.services.llm;
- return `${llm.active_profile_id ?? ""}::${llm.active_model_id ?? ""}`;
- }, [draft]);
-
if (catalogEditable !== true) {
- // Same shape the service editors use: an ordinary user reaches this page
- // from the Models grid, and an empty panel would read as a broken page
- // rather than a permission boundary.
return (
<div className="rounded-xl border border-dashed border-[var(--border)] px-5 py-10 text-center text-[13px] text-[var(--muted-foreground)]">
{settingsError
@@ -103,119 +64,131 @@ export function TaskModelsEditor() {
);
}
- const tr = (value: { en: string; zh: string }) => (zh ? value.zh : value.en);
+ /** Copy a provider over from the LLM service, credentials and all. */
+ const importProfile = (profileId: string) => {
+ const source = llmProfiles.find((item) => item.id === profileId);
+ if (!source) return;
+ const stamp = `${Date.now().toString(36)}${Math.random()
+ .toString(36)
+ .slice(2, 6)}`;
+ const profileId2 = `task-profile-${stamp}`;
+ const modelId = `task-model-${stamp}`;
+ mutateCatalog((next) => {
+ const bucket = next.services.task;
+ // Only the model in use comes across; the rest are chat's business.
+ const sourceModel =
+ source.models.find(
+ (item) => item.id === next.services.llm.active_model_id,
+ ) ?? source.models[0];
+ bucket.profiles.push({
+ ...JSON.parse(JSON.stringify(source)),
+ id: profileId2,
+ models: [
+ {
+ ...(sourceModel
+ ? JSON.parse(JSON.stringify(sourceModel))
+ : { name: "", model: "" }),
+ id: modelId,
+ },
+ ],
+ });
+ bucket.active_profile_id = profileId2;
+ bucket.active_model_id = modelId;
+ });
+ setImporting(false);
+ setImportFrom("");
+ };
return (
<div>
- {options.length === 0 ? (
- <div className="rounded-xl border border-dashed border-[var(--border)] px-4 py-5">
- <p className="text-[13px] text-[var(--foreground)]">
- {t("No language models are configured yet.")}
+ {!configured && (
+ <div className="mb-6 rounded-xl border border-[var(--border)] bg-[var(--accent)]/30 px-4 py-3">
+ <p className="text-[12.5px] leading-relaxed text-[var(--foreground)]">
+ {t("Nothing configured here, so both calls use the language model.")}
</p>
- <Link
- href="/settings/llm"
- className="mt-2 inline-flex items-center gap-1 text-[12px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"
- >
- {t("Configure one")}
- <ArrowUpRight className="h-3 w-3" />
- </Link>
+ <div className="mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11.5px] text-[var(--muted-foreground)]">
+ {inherited.model ? (
+ <>
+ <ProviderIcon provider={inherited.binding} size={12} />
+ <span className="font-mono">{inherited.model}</span>
+ </>
+ ) : (
+ <span>{t("No language model is configured yet.")}</span>
+ )}
+ <Link
+ href="/settings/llm"
+ className="inline-flex items-center gap-0.5 underline-offset-2 hover:text-[var(--foreground)] hover:underline"
+ >
+ {t("LLM")}
+ <ArrowUpRight className="h-3 w-3" />
+ </Link>
+ </div>
</div>
- ) : (
- <div className="border-t border-[var(--border)]/60">
- {LLM_TASK_KEYS.map((task, index) => {
- const copy = TASK_COPY[task];
- const pinned = draft.services.llm.tasks?.[task];
- const value = pinned
- ? `${pinned.profile_id}::${pinned.model_id}`
- : "";
- const resolved =
- options.find((option) => option.value === value) ??
- (value
- ? null
- : (options.find((option) => option.value === activeValue) ??
- null));
- return (
- <div
- key={task}
- className={`flex flex-wrap items-start gap-x-6 gap-y-3 py-3.5 ${
- index === 0 ? "" : "border-t border-[var(--border)]/50"
- }`}
- >
- <div className="min-w-0 flex-1 basis-64">
- <div className="text-[13px] font-medium text-[var(--foreground)]">
- {tr(copy.label)}
- </div>
- <p className="mt-1 text-[11.5px] leading-relaxed text-[var(--muted-foreground)]">
- {tr(copy.desc)}
- </p>
- {copy.href && copy.hrefLabel && (
- <Link
- href={copy.href}
- className="mt-1.5 inline-flex items-center gap-1 text-[11px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"
- >
- {tr(copy.hrefLabel)}
- <ArrowUpRight className="h-3 w-3" />
- </Link>
- )}
- </div>
- <div className="w-full sm:w-72">
- <div className="relative">
- <select
- className={`${selectClass} pr-9`}
- value={value}
- onChange={(event) => {
- const next = event.target.value;
- if (!next) {
- setLlmTask(task, null);
- return;
- }
- const [profileId, modelId] = next.split("::");
- setLlmTask(task, {
- profile_id: profileId,
- model_id: modelId,
- });
- }}
+ )}
+
+ {llmProfiles.length > 0 && (
+ <div className="mb-5">
+ {importing ? (
+ <div className="flex flex-wrap items-center gap-2">
+ <div className="relative min-w-0 flex-1 sm:max-w-xs">
+ <select
+ className={`${selectClass} h-8 py-0 pr-9 text-[12.5px]`}
+ value={importFrom}
+ onChange={(event) => setImportFrom(event.target.value)}
+ >
+ <option className={selectOptionClass} value="">
+ {t("Choose a provider to copy...")}
+ </option>
+ {llmProfiles.map((profile) => (
+ <option
+ className={selectOptionClass}
+ key={profile.id}
+ value={profile.id}
>
- <option className={selectOptionClass} value="">
- {tr(copy.inherit)}
- </option>
- {options.map((option) => (
- <option
- className={selectOptionClass}
- key={option.value}
- value={option.value}
- >
- {option.model} — {option.profileName}
- </option>
- ))}
- </select>
- <ChevronDown className="pointer-events-none absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--muted-foreground)]" />
- </div>
- {/* What it resolves to right now — the inherit case is the
- one users cannot otherwise see. */}
- <div className="mt-1.5 flex items-center gap-1.5 text-[11px] text-[var(--muted-foreground)]">
- {resolved ? (
- <>
- <ProviderIcon provider={resolved.binding} size={12} />
- <span className="truncate font-mono">
- {resolved.model}
- </span>
- </>
- ) : (
- <span>{t("Resolves at call time.")}</span>
- )}
- </div>
- </div>
+ {profile.name}
+ </option>
+ ))}
+ </select>
+ <ChevronDown className="pointer-events-none absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--muted-foreground)]" />
</div>
- );
- })}
+ <button
+ type="button"
+ disabled={!importFrom}
+ onClick={() => importProfile(importFrom)}
+ className="inline-flex h-8 items-center rounded-lg bg-[var(--foreground)] px-3 text-[12px] font-medium text-[var(--background)] transition-opacity hover:opacity-90 disabled:opacity-40"
+ >
+ {t("Copy over")}
+ </button>
+ <button
+ type="button"
+ onClick={() => {
+ setImporting(false);
+ setImportFrom("");
+ }}
+ className="h-8 rounded-lg px-2 text-[12px] text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"
+ >
+ {t("Cancel")}
+ </button>
+ </div>
+ ) : (
+ <button
+ type="button"
+ onClick={() => setImporting(true)}
+ className="inline-flex items-center gap-1.5 rounded-lg border border-[var(--border)]/50 px-2.5 py-1 text-[12px] text-[var(--muted-foreground)] transition-colors hover:border-[var(--border)] hover:text-[var(--foreground)]"
+ >
+ <Download className="h-3 w-3" />
+ {t("Bring a provider over from the LLM")}
+ </button>
+ )}
</div>
)}
- <p className="mt-3 text-[11.5px] leading-relaxed text-[var(--muted-foreground)]">
- {t(
- "Both calls are short and frequent, so a smaller, faster model is usually the better trade here.",
- )}
+ <ServiceConfigEditor service="task" />
+
+ <p className="mt-6 text-[11.5px] leading-relaxed text-[var(--muted-foreground)]">
+ {zh
+ ? "会话标题和主页起始建议都用这里的模型。两处调用都短小且频繁,指向一个更小更快的模型通常更划算。"
+ : "Conversation titles and the home screen's starting points both run on this. Both calls are short and frequent, so a smaller, faster model is usually the better trade."}
</p>
</div>
);
diff --git a/web/lib/settings-nav.ts b/web/lib/settings-nav.ts
index f8abde188..b2538f098 100644
--- a/web/lib/settings-nav.ts
+++ b/web/lib/settings-nav.ts
@@ -106,8 +106,8 @@ const MODEL_CHILDREN: SettingsLeaf[] = [
href: "/settings/task-models",
label: { zh: "任务模型", en: "Task models" },
blurb: {
- zh: "会话标题与起始建议使用的模型。",
- en: "The model behind conversation titles and starting points.",
+ zh: "DeepTutor 自己发起的调用使用的模型。",
+ en: "The model behind the calls DeepTutor makes on its own.",
},
icon: ListChecks,
tile: "bg-cyan-500/10 text-cyan-600 dark:text-cyan-400",
diff --git a/web/locales/en/app.json b/web/locales/en/app.json
index 0aef07cac..c8a2f2323 100644
--- a/web/locales/en/app.json
+++ b/web/locales/en/app.json
@@ -3641,5 +3641,12 @@
"{{n}} ctx": "{{n}} ctx",
"{{n}} dim": "{{n}} dim",
"No model id yet": "No model id yet",
- "Set as active": "Set as active"
+ "Set as active": "Set as active",
+ "Task model": "Task model",
+ "Nothing configured here, so both calls use the language model.": "Nothing configured here, so both calls use the language model.",
+ "No language model is configured yet.": "No language model is configured yet.",
+ "Bring a provider over from the LLM": "Bring a provider over from the LLM",
+ "Choose a provider to copy...": "Choose a provider to copy...",
+ "Copy over": "Copy over",
+ "Conversation titles and home screen starting points. Configured like the LLM — pick a provider, then a model. Left empty, both use the LLM.": "Conversation titles and home screen starting points. Configured like the LLM — pick a provider, then a model. Left empty, both use the LLM."
}
diff --git a/web/locales/zh/app.json b/web/locales/zh/app.json
index 7f992887f..1f5dae31e 100644
--- a/web/locales/zh/app.json
+++ b/web/locales/zh/app.json
@@ -3641,5 +3641,12 @@
"{{n}} ctx": "{{n}} 上下文",
"{{n}} dim": "{{n}} 维",
"No model id yet": "还没填模型 ID",
- "Set as active": "设为使用中"
+ "Set as active": "设为使用中",
+ "Task model": "任务模型",
+ "Nothing configured here, so both calls use the language model.": "这里没有配置,所以两处调用都使用语言模型。",
+ "No language model is configured yet.": "还没有配置语言模型。",
+ "Bring a provider over from the LLM": "从 LLM 引入一个供应商",
+ "Choose a provider to copy...": "选择要复制的供应商…",
+ "Copy over": "引入",
+ "Conversation titles and home screen starting points. Configured like the LLM — pick a provider, then a model. Left empty, both use the LLM.": "会话标题与主页起始建议。配置方式与 LLM 相同:先选供应商,再配模型。留空则两者都使用 LLM 的配置。"
}