fix: K3 plan-variant slugs (k3-256k) now get K3's effort vocabulary
kimi_supported_efforts() used exact/prefix matching and missed Kimi Coding plan variants like k3-256k, which fell back to the K2-era low/medium/high set and mistranslated efforts on a K3 wire. Replaced with the boundary-token regex from #76427 (credit @ruizanthony), which matches k3/k3-256k/kimi-k3* without matching kimi-k2.6 or mk3000.
This commit is contained in:
@@ -36,8 +36,14 @@ Rules for call sites:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import Optional, Sequence
|
||||
|
||||
#: K3 slug detector — matches ``k3`` as a delimited token (``k3``,
|
||||
#: ``k3-256k``, ``kimi-k3``, ``kimi-k3-cot``) without matching K2-era names
|
||||
#: (``kimi-k2.6``). From #76427 by @ruizanthony.
|
||||
_KIMI_K3_SLUG_RE = re.compile(r"(?:^|[^a-z0-9])k3(?:[^a-z0-9]|$)")
|
||||
|
||||
# Canonical low→high ordering used for nearest-level clamping. Superset of
|
||||
# hermes_constants.VALID_REASONING_EFFORTS ("none" included so an explicit
|
||||
# disable can be clamped too when a provider publishes it as a level).
|
||||
@@ -124,11 +130,14 @@ SOLAR_EFFORTS: tuple[str, ...] = ("low", "medium", "high")
|
||||
def kimi_supported_efforts(model: Optional[str]) -> tuple[str, ...]:
|
||||
"""Supported effort set for a Moonshot/Kimi model slug.
|
||||
|
||||
K3 is served as the bare slug ``k3`` and the ``kimi-k3*`` aliases; its
|
||||
documented set is low/high/max. Everything earlier speaks low/medium/high.
|
||||
K3 is served as the bare slug ``k3``, plan variants like ``k3-256k``,
|
||||
and the ``kimi-k3*`` aliases; its documented set is low/high/max.
|
||||
Everything earlier speaks low/medium/high. Boundary-matched so K2-era
|
||||
names (``kimi-k2.6``) never match (detection regex from #76427 by
|
||||
@ruizanthony).
|
||||
"""
|
||||
m = (model or "").strip().lower().split("/")[-1]
|
||||
if m == "k3" or m.startswith("kimi-k3"):
|
||||
if _KIMI_K3_SLUG_RE.search(m):
|
||||
return KIMI_K3_EFFORTS
|
||||
return KIMI_K2_EFFORTS
|
||||
|
||||
|
||||
@@ -112,13 +112,15 @@ class TestClampEffort:
|
||||
|
||||
class TestKimiVocabulary:
|
||||
@pytest.mark.parametrize(
|
||||
"model", ["k3", "kimi-k3", "kimi-k3-cot", "moonshotai/kimi-k3"]
|
||||
"model",
|
||||
["k3", "kimi-k3", "kimi-k3-cot", "moonshotai/kimi-k3", "k3-256k"],
|
||||
)
|
||||
def test_k3_slugs(self, model):
|
||||
assert kimi_supported_efforts(model) is KIMI_K3_EFFORTS
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model", ["kimi-k2.6", "moonshotai/kimi-k2-0905", "kimi-latest", None]
|
||||
"model",
|
||||
["kimi-k2.6", "moonshotai/kimi-k2-0905", "kimi-latest", "mk3000", None],
|
||||
)
|
||||
def test_k2_era_slugs(self, model):
|
||||
assert kimi_supported_efforts(model) is KIMI_K2_EFFORTS
|
||||
|
||||
Reference in New Issue
Block a user