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.

fix(models): read the Ollama library's icon-led badges

rubenluetke10-beepf734cfe706d0
diff --git a/jarvis/brain/ollama_library.py b/jarvis/brain/ollama_library.py
index 8705e0c488..f6080dd7c0 100644
--- a/jarvis/brain/ollama_library.py
+++ b/jarvis/brain/ollama_library.py
@@ -224,14 +224,24 @@ def parse_search_html(page: str) -> list[dict[str, Any]]:
description = text
break
- spans = [_text(m.group(1)) for m in re.finditer(r"<span\b[^>]*>([^<]*)</span>", block)]
+ # Since 2026-10 a badge puts an icon before its label ("<svg>…</svg>Vision")
+ # and capitalises it; dropping the icons reads both layouts as text spans.
+ plain = re.sub(r"<svg\b.*?</svg>", "", block, flags=re.DOTALL)
+ spans = [_text(m.group(1)) for m in re.finditer(r"<span\b[^>]*>([^<]*)</span>", plain)]
spans = [s for s in spans if s]
- capabilities = [badge for badge in _CAPABILITY_BADGES if badge in spans]
+ # Every text node, not only whole spans: "Cloud" now sits beside a tooltip.
+ texts = (_text(m.group(1)) for m in re.finditer(r">([^<>]+)<", plain))
+ lowered = {t.lower() for t in texts if t}
+ capabilities = [badge for badge in _CAPABILITY_BADGES if badge in lowered]
sizes = [s for s in spans if re.fullmatch(r"\d+(?:\.\d+)?[bm]", s)]
pulls_match = re.search(
- r">\s*([\d.,]+[KMB]?)\s*</span>\s*<span[^>]*>(?:&nbsp;|\s)*Pulls", block
+ r">\s*([\d.,]+[KMB]?)\s*</span>\s*<span[^>]*>(?:&nbsp;|\s)*Pulls", plain
+ ) or re.search(
+ r'<span\b[^>]*title="[^"]*downloads"[^>]*>\s*<span\b[^>]*>\s*([\d.,]+[KMB]?)\s*</span>',
+ plain,
)
+ # The current search page prints no update time any more; "" then.
updated = next((s for s in spans if s.endswith(" ago") or s == "yesterday"), "")
entries.append(
@@ -239,7 +249,7 @@ def parse_search_html(page: str) -> list[dict[str, Any]]:
"name": name,
"description": description,
"capabilities": capabilities,
- "cloud": "cloud" in spans,
+ "cloud": "cloud" in lowered,
"sizes": sizes,
"pulls": pulls_match.group(1) if pulls_match else "",
"updated": updated,
diff --git a/tests/integration/test_ollama_library_live.py b/tests/integration/test_ollama_library_live.py
index 6b56b33fe9..0f9d1c66fc 100644
--- a/tests/integration/test_ollama_library_live.py
+++ b/tests/integration/test_ollama_library_live.py
@@ -57,13 +57,15 @@ def test_the_live_tags_page_still_parses() -> None:
def test_the_live_newest_sort_is_honoured() -> None:
- """``?o=newest`` must change the ORDER: the first rows are days or weeks
- old, never the years-old names that top the popular listing."""
- models = parse_search_html(_fetch("https://ollama.com/search?o=newest"))
- assert len(models) >= 5, "The live newest listing parsed almost empty."
- head = [m["updated"] for m in models[:5]]
- assert all(u and "year" not in u for u in head), head
- assert any(("day" in u or "week" in u or u == "yesterday") for u in head), head
+ """``?o=newest`` must change the ORDER against the popular listing.
+
+ The search page stopped printing an update time in 2026-10, so the order
+ itself is the evidence that the sort parameter still reaches the site.
+ """
+ newest = parse_search_html(_fetch("https://ollama.com/search?o=newest"))
+ popular = parse_search_html(_fetch("https://ollama.com/search"))
+ assert len(newest) >= 5, "The live newest listing parsed almost empty."
+ assert [m["name"] for m in newest[:5]] != [m["name"] for m in popular[:5]]
def test_the_live_capability_filter_is_honoured() -> None:
diff --git a/tests/unit/brain/test_ollama_library.py b/tests/unit/brain/test_ollama_library.py
index cc98413606..cc0cd35864 100644
--- a/tests/unit/brain/test_ollama_library.py
+++ b/tests/unit/brain/test_ollama_library.py
@@ -77,6 +77,40 @@ def test_search_parser_answers_empty_on_garbage() -> None:
assert library.parse_search_html("<html><body>maintenance</body></html>") == []
+# A trimmed entry in the 2026-10 layout: icon-led, capitalised badges, a
+# download count in a titled span, and no update time.
+_ICON_LAYOUT = """
+<ul><li class="border-b"><a href="/library/embeddinggemma-2" class="group">
+<h2 title="embeddinggemma-2"><span>embeddinggemma-2</span></h2>
+<p class="mt-1" title="An embedding model.">An embedding model.</p>
+<div><span><span role="tooltip">Runs on your computer</span>
+<svg viewBox="0 0 24 24"><path d="M9 17"/></svg>
+<span class="font-medium">270m</span><span aria-hidden="true">&middot;</span>
+<span class="font-medium">440m</span></span>
+<div><span class="badge"><svg><path d="M2 12"/></svg>Vision</span>
+<span class="badge"><svg><path d="M1"/></svg>Embedding</span></div></div>
+<span title="5,695 downloads"><svg><path d="M3"/></svg><span>5,695</span></span>
+</a></li>
+<li><a href="/library/glm-5" class="group"><h2><span>glm-5</span></h2><p>A cloud model.</p>
+<div><span><span role="tooltip">Runs on Ollama&#39;s cloud</span>
+<svg><path d="M4"/></svg>Cloud</span>
+<div><span><svg><path d="M5"/></svg>Tools</span>
+<span><svg><path d="M6"/></svg>Thinking</span></div></div></a></li></ul>
+"""
+
+
+def test_search_parser_reads_the_icon_badge_layout() -> None:
+ local, cloud = library.parse_search_html(_ICON_LAYOUT)
+ assert local["name"] == "embeddinggemma-2"
+ assert local["capabilities"] == ["vision", "embedding"]
+ assert local["sizes"] == ["270m", "440m"]
+ assert local["pulls"] == "5,695"
+ assert local["cloud"] is False
+ assert local["updated"] == ""
+ assert cloud["capabilities"] == ["tools", "thinking"]
+ assert cloud["cloud"] is True
+
+
# ── tags parser ──────────────────────────────────────────────────────────