diff --git a/oc-lfm25.py b/oc-lfm25.py index 097cd6db..cec8fd53 100755 --- a/oc-lfm25.py +++ b/oc-lfm25.py @@ -13,9 +13,13 @@ import sys def provider(base_url, key_file, ctx, out, name): - """The provider block. No variants: the checkpoint's chat template opens at every answer and reads no - level and no switch (its chat_template.jinja at the pinned revision, read 2026-11-16), so the lane reasons on - every request whatever a client asks. Text only: the model reads no image (its config, Lfm2MoeForCausalLM).""" + """The provider block. No variants, and no "reasoning": the checkpoint's chat template opens at every + answer and reads no level and no switch (its chat_template.jinja at the pinned revision, read 2026-11-16), so the + lane reasons on every request whatever a client asks, and opencode must offer no level to pick. opencode 1.19.5 + builds a model's variants from its "reasoning" capability, false when the config leaves it out (provider.ts), and + gives none to a model without it (ProviderTransform.variants); with it, it offers low, medium and high on + @ai-sdk/openai-compatible, three levels this template does not read. Text only: the model reads no image (its + config, Lfm2MoeForCausalLM).""" return { "npm": "@ai-sdk/openai-compatible", "name": "Liquid AI LFM2.5 24B-A2B (DGX Spark)", diff --git a/pi-gen.py b/pi-gen.py index dddd2837..c1ab0325 100755 --- a/pi-gen.py +++ b/pi-gen.py @@ -22,7 +22,8 @@ modelThinkingLevels "off" for the Qwen models (unset sends no effort field: the installed template's default, lean, or xhigh on a box installed with LEAN_DEFAULT=0 and on the Qwen3.8 Flash-Next FP4-Local lane installed with FLASH_LOCAL_EFFORT=xhigh) and "high" for Kolibri-1, the two Nemotron lanes and Ornith 1.5 122B, which are -sent their effort (EFFORT_FIELD), +sent their effort (EFFORT_FIELD); the Liquid AI LFM2.5 24B-A2B lane, whose template reasons on every +request and reads no level, is offered "high" alone and sent none (FIXED_LEVEL), keepRecentTokens from the artifact's compaction block and per-lane reserveTokens = the lane's output cap. omp gets the same values re-serialized: the same models array, thinking block @@ -166,6 +167,17 @@ EFFORT_FIELD = {"kolibri": ({"off": "none", "minimal": "low", "xhigh": "high"}, "nemotron": ({"off": "none", "minimal": "low", "xhigh": "high"}, "high"), "nemotron-super": ({"off": "none", "minimal": "low", "xhigh": "high"}, "high"), "ornith-122b": ({"off": "none"}, "high")} +# The lanes whose template reasons on every request and reads no level and no switch: the one level a client may show +# is the one the model holds, and no field is sent, since the template reads none. The Liquid AI LFM2.5 24B-A2B lane's +# chat_template.jinja (at the pinned revision, read 2026-11-16) ends every generation prompt with "", and the +# variables it reads are add_generation_prompt, bos_token, messages, tools and preserve_thinking (which keeps the +# thoughts of past turns, and turns nothing off): no enable_thinking, no reasoning_effort, nothing that cuts the +# reasoning. Kept as it was, pi offered all its levels on it, off first, and started there (pi's "off" for an +# unknown model). pi hides a level its model maps to null (getSupportedThinkingLevels, pi 1.2.0; thinkingLevelMap +# since 0.72.0), so every level but this one is mapped to null; omp gets the one effort too, as its default, though +# omp 18.4.9 offers off and auto beside a reasoning model's efforts whatever its file says (cycleThinkingLevel). +FIXED_LEVEL = {"lfm25": "high"} +PI_LEVELS = ("off", "minimal", "low", "medium", "high", "xhigh", "max") def model_meta(mid, m): @@ -204,6 +216,10 @@ def build(artifact): level_map, thinking[f"{prov}/{mid}"] = EFFORT_FIELD[prov] meta["compat"]["supportsReasoningEffort"] = True meta["thinkingLevelMap"] = dict(level_map) + if prov in FIXED_LEVEL: + thinking[f"{prov}/{mid}"] = FIXED_LEVEL[prov] + meta["compat"]["supportsReasoningEffort"] = False + meta["thinkingLevelMap"] = {lvl: None for lvl in PI_LEVELS if lvl != FIXED_LEVEL[prov]} overrides[f"{prov}/{mid}"] = {"reserveTokens": meta["maxTokens"]} tiers = list((models[mid] or {}).get("variants") or {}) if tiers: @@ -322,6 +338,9 @@ def omp_convert(models_doc, settings, efforts, defaults=None): # validation error). e = {k: v for k, v in m.items() if k not in ("inputLimits", "compat", "thinkingLevelMap")} thinking, compat = omp_thinking(efforts.get(f"{prov}/{m['id']}", []), (defaults or {}).get(prov)) + if prov in FIXED_LEVEL: + # its one effort, as its default; no qwenTemplateReasoningEffort, so no field is sent + thinking = {"mode": "effort", "efforts": [FIXED_LEVEL[prov]], "defaultLevel": FIXED_LEVEL[prov]} if thinking: e["thinking"] = thinking if compat: diff --git a/tests/test_lfm25_lane.py b/tests/test_lfm25_lane.py index c651e4a8..c752debf 100644 --- a/tests/test_lfm25_lane.py +++ b/tests/test_lfm25_lane.py @@ -345,7 +345,10 @@ class ItsClients(unittest.TestCase): self.assertEqual(list(block["models"]), [SERVED]) model = block["models"][SERVED] self.assertEqual(model["limit"], {"context": 74000, "input": 74000, "output": 32000}) - self.assertNotIn("variants", model, "its template reads no level: none to offer") + # opencode 1.19.5 offers no level for a model with neither: its template reads none, and "reasoning" alone + # would make opencode offer low, medium and high (ProviderTransform.variants on @ai-sdk/openai-compatible) + for key in ("variants", "reasoning", "reasoning_options"): + self.assertNotIn(key, model, "its template reads no level: none to offer") self.assertNotIn("modalities", model, "it reads no image") self.assertEqual(block["options"]["apiKey"], "{file:/k}") diff --git a/tests/test_pi_gen.py b/tests/test_pi_gen.py index 55956ae8..3c98f701 100644 --- a/tests/test_pi_gen.py +++ b/tests/test_pi_gen.py @@ -348,6 +348,40 @@ class PiGen(unittest.TestCase): self.assertEqual(entry["input"], ["text", "image"]) self.assertEqual(settings["modelThinkingLevels"]["ornith-122b/ornith-1.5-122b"], "high") + def test_lfm25_offers_the_one_level_its_template_holds_and_sends_none(self): + """The Liquid AI LFM2.5 24B-A2B lane's template reasons on every request and reads no level and no switch (its + chat_template.jinja at the pinned revision): pi offered all its levels on it, off first, and started there.""" + prov = json.loads(subprocess.run([sys.executable, str(REPO / "oc-lfm25.py"), "http://127.0.0.1:30001/v1", + "/keys/api-key", "74000", "32000", "LFM2.5 (local, 131K)"], + capture_output=True, text=True, check=True).stdout) + art = json.loads(json.dumps(ARTIFACT)) + art["provider"].update(prov["provider"]) + art["model"] = "lfm25/lfm2.5-24b-a2b" + with open(self.art, "w") as f: + f.write(json.dumps(art)) + self.gen() + models, settings = self.read_pi() + entry = models["providers"]["lfm25"]["models"][0] + self.assertTrue(entry["reasoning"]) + # pi 1.2.0's getSupportedThinkingLevels, ported: a level mapped to null is hidden, xhigh and max need a mapping + levels = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] + tlm = entry.get("thinkingLevelMap") or {} + shown = [lvl for lvl in levels if not (lvl in tlm and tlm[lvl] is None) + and (lvl not in ("xhigh", "max") or lvl in tlm)] + self.assertEqual(shown, ["high"]) + self.assertEqual(settings["modelThinkingLevels"]["lfm25/lfm2.5-24b-a2b"], "high") + # no field sent: pi's OpenAI dialect sends reasoning_effort only with supportsReasoningEffort, which it + # otherwise detects as true for a provider it does not know + self.assertIs(entry["compat"]["supportsReasoningEffort"], False) + # the other lanes as before + self.assertEqual(settings["modelThinkingLevels"]["qwen38/qwen3.8-27b"], "off") + self.assertNotIn("thinkingLevelMap", models["providers"]["qwen38"]["models"][0]) + omp_models, _ = self.read_omp() + omp_entry = omp_models["providers"]["lfm25"]["models"][0] + self.assertEqual(omp_entry["thinking"], {"mode": "effort", "efforts": ["high"], "defaultLevel": "high"}) + self.assertNotIn("qwenTemplateReasoningEffort", omp_entry["compat"]) + self.assertNotIn("thinkingLevelMap", omp_entry) + def test_idempotent(self): self.gen() again = self.gen()