Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(api): expose the public model library on pull-capable provider cards

rubenluetke10-beepc34d606acf64
diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.py
index ea13f182c5..a8608d490f 100644
--- a/jarvis/ui/web/provider_routes.py
+++ b/jarvis/ui/web/provider_routes.py
@@ -3031,6 +3031,41 @@ async def list_pullable_models(provider_id: str) -> dict[str, Any]:
return await recommendations()
[email protected]("/providers/{provider_id}/library/search")
+async def search_model_library(provider_id: str, q: str = "") -> dict[str, Any]:
+ """Search the provider's PUBLIC model library, not just the shortlist.
+
+ The curated list answers "which model should I get?"; this answers "what
+ else is there?" — the same question that otherwise sends a user to a
+ browser and back with a name typed from memory. An empty ``q`` lists the
+ popular models, which is the useful default for someone just browsing.
+
+ Never fails the panel: an unreachable ollama.com answers ``models: []``
+ plus an English ``error`` sentence, and downloading by exact name keeps
+ working without this route entirely.
+ """
+ _require_pull_capable(provider_id)
+ from jarvis.brain.ollama_library import search_library
+
+ return await search_library(q)
+
+
[email protected]("/providers/{provider_id}/library/{model}/tags")
+async def list_model_library_tags(provider_id: str, model: str) -> dict[str, Any]:
+ """Every published tag of ``model``, sized and fit-checked for this machine.
+
+ A model name alone is not installable — ``qwen3.5`` ships from 0.8B to
+ 122B, and picking blind is how a 4 GB laptop ends up pulling 65 GB. Each
+ tag carries the library's own download size and the SAME fit verdict the
+ curated shortlist uses, so both halves of the panel mean one thing by
+ "tight".
+ """
+ _require_pull_capable(provider_id)
+ from jarvis.brain.ollama_library import library_tags
+
+ return await library_tags(model)
+
+
@router.post("/providers/{provider_id}/pull")
async def start_model_pull(provider_id: str, body: PullModelBody) -> dict[str, Any]:
"""Download a model into the local server (§3: recoverable in-app).
diff --git a/tests/integration/test_provider_routes.py b/tests/integration/test_provider_routes.py
index 0c801cdd19..67ce094238 100644
--- a/tests/integration/test_provider_routes.py
+++ b/tests/integration/test_provider_routes.py
@@ -985,3 +985,85 @@ def test_pull_on_an_unknown_provider_is_404(
with TestClient(server_with_brain.app) as client:
resp = client.get("/api/providers/nope/pullable-models")
assert resp.status_code == 404
+
+
+# ----------------------------------------------------------------------
+# /api/providers/{pid}/library/… (browse the FULL public model library)
+# ----------------------------------------------------------------------
+
+
+def fake_library(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]:
+ """Stub the library module so the routes never touch ollama.com."""
+ from jarvis.brain import ollama_library
+
+ calls: dict[str, Any] = {"searched": [], "tagged": []}
+
+ async def _search_library(query: str) -> dict[str, Any]:
+ calls["searched"].append(query)
+ return {
+ "query": query,
+ "models": [{"name": "qwen3.5", "description": "…", "installed": False}],
+ "error": None,
+ }
+
+ async def _library_tags(model: str) -> dict[str, Any]:
+ calls["tagged"].append(model)
+ return {
+ "model": model,
+ "tags": [{"tag": "4b", "id": f"{model}:4b", "size_gb": 3.4, "fit": "comfortable"}],
+ "error": None,
+ }
+
+ monkeypatch.setattr(ollama_library, "search_library", _search_library)
+ monkeypatch.setattr(ollama_library, "library_tags", _library_tags)
+ return calls
+
+
+def test_library_search_returns_models_from_the_public_catalog(
+ server_with_brain: WebServer, fake_library: dict[str, Any]
+) -> None:
+ with TestClient(server_with_brain.app) as client:
+ resp = client.get("/api/providers/ollama/library/search", params={"q": "qwen"})
+ assert resp.status_code == 200
+ assert resp.json()["models"][0]["name"] == "qwen3.5"
+ assert fake_library["searched"] == ["qwen"]
+
+
+def test_library_search_without_a_query_browses_the_popular_models(
+ server_with_brain: WebServer, fake_library: dict[str, Any]
+) -> None:
+ """Someone who does not know what to look for still gets a list."""
+ with TestClient(server_with_brain.app) as client:
+ resp = client.get("/api/providers/ollama/library/search")
+ assert resp.status_code == 200
+ assert fake_library["searched"] == [""]
+
+
+def test_library_tags_list_the_installable_sizes(
+ server_with_brain: WebServer, fake_library: dict[str, Any]
+) -> None:
+ """A bare model name is not installable — the tag carries the size."""
+ with TestClient(server_with_brain.app) as client:
+ resp = client.get("/api/providers/ollama/library/qwen3.5/tags")
+ assert resp.status_code == 200
+ assert resp.json()["tags"][0]["id"] == "qwen3.5:4b"
+ assert fake_library["tagged"] == ["qwen3.5"]
+
+
+def test_library_routes_reject_a_card_without_a_download_api(
+ server_with_brain: WebServer, fake_library: dict[str, Any]
+) -> None:
+ """Browsing a library the card could not pull from would be a dead end."""
+ with TestClient(server_with_brain.app) as client:
+ resp = client.get("/api/providers/local-openai/library/search")
+ assert resp.status_code == 400
+ assert fake_library["searched"] == []
+
+
+def test_library_search_on_an_unknown_provider_is_404(
+ server_with_brain: WebServer, fake_library: dict[str, Any]
+) -> None:
+ with TestClient(server_with_brain.app) as client:
+ resp = client.get("/api/providers/nope/library/search")
+ assert resp.status_code == 404