fix(providers): preserve supported Kimi K3 reasoning efforts
This commit is contained in:
1 parent
790a970989
commit
3881ed7dd1
4 files changed
+17
-15
No files matched your search
@@ -960,15 +960,15 @@ class OpenAICompatProvider(LLMProvider):
|
||||
wire_effort = reasoning_effort
|
||||
slug = _model_slug(model_name)
|
||||
if slug == _KIMI_K3_MODEL and semantic_effort is not None:
|
||||
# K3 always reasons and currently accepts only the top-level
|
||||
# reasoning_effort="max". Preserve disabled/default semantics by
|
||||
# omitting the field; normalize older enabled presets to "max" so
|
||||
# switching from a K2.x model does not send an unsupported value.
|
||||
# K3 always reasons and accepts top-level low/high/max effort.
|
||||
# Keep disabled presets on the default and normalize other legacy
|
||||
# enabled values to "max".
|
||||
if semantic_effort in ("none", "minimal"):
|
||||
wire_effort = None
|
||||
else:
|
||||
semantic_effort = "max"
|
||||
wire_effort = "max"
|
||||
if semantic_effort not in ("low", "high", "max"):
|
||||
semantic_effort = "max"
|
||||
wire_effort = semantic_effort
|
||||
if spec and spec.name == "dashscope" and semantic_effort == "minimal":
|
||||
# DashScope accepts none/minimum/low/medium/high/xhigh; "minimal" 400s.
|
||||
wire_effort = "minimum"
|
||||
|
||||
@@ -886,7 +886,7 @@ def reasoning_effort_values_for(provider_name: str, model: str) -> list[str]:
|
||||
|
||||
model_lower = (model or "").lower()
|
||||
if model_lower.rsplit("/", 1)[-1] == "kimi-k3":
|
||||
return ["", "max"]
|
||||
return ["", "low", "high", "max"]
|
||||
|
||||
implicit = getattr(spec, "implicit_reasoning_models", ())
|
||||
if implicit and any(pattern in model_lower for pattern in implicit):
|
||||
|
||||
@@ -1936,26 +1936,28 @@ def test_kimi_k3_uses_native_defaults() -> None:
|
||||
assert "extra_body" not in kw
|
||||
|
||||
|
||||
def test_kimi_k3_uses_top_level_max_reasoning_effort() -> None:
|
||||
"""K3 uses top-level reasoning_effort=max, never the K2.x thinking body."""
|
||||
kw = _build_kwargs_for("moonshot", "kimi-k3", reasoning_effort="max")
|
||||
@pytest.mark.parametrize("effort", ["low", "high", "max"])
|
||||
def test_kimi_k3_preserves_supported_reasoning_effort(effort: str) -> None:
|
||||
"""K3 uses top-level reasoning_effort, never the K2.x thinking body."""
|
||||
kw = _build_kwargs_for("moonshot", "kimi-k3", reasoning_effort=effort)
|
||||
|
||||
assert kw["reasoning_effort"] == "max"
|
||||
assert kw["reasoning_effort"] == effort
|
||||
assert "temperature" not in kw
|
||||
assert "extra_body" not in kw
|
||||
|
||||
|
||||
def test_kimi_k3_normalizes_legacy_enabled_reasoning_effort() -> None:
|
||||
"""Switching a K2.x preset to K3 must not send unsupported effort values."""
|
||||
kw = _build_kwargs_for("moonshot", "kimi-k3", reasoning_effort="high")
|
||||
kw = _build_kwargs_for("moonshot", "kimi-k3", reasoning_effort="medium")
|
||||
|
||||
assert kw["reasoning_effort"] == "max"
|
||||
assert "extra_body" not in kw
|
||||
|
||||
|
||||
def test_kimi_k3_omits_disabled_reasoning_effort() -> None:
|
||||
@pytest.mark.parametrize("effort", ["none", "minimal"])
|
||||
def test_kimi_k3_omits_disabled_reasoning_effort(effort: str) -> None:
|
||||
"""K3 cannot disable reasoning, so disabled effort falls back to its default."""
|
||||
kw = _build_kwargs_for("moonshot", "kimi-k3", reasoning_effort="none")
|
||||
kw = _build_kwargs_for("moonshot", "kimi-k3", reasoning_effort=effort)
|
||||
|
||||
assert "reasoning_effort" not in kw
|
||||
assert "temperature" not in kw
|
||||
|
||||
@@ -76,7 +76,7 @@ def test_docs_version_uses_released_versions_and_falls_back_for_dev() -> None:
|
||||
|
||||
|
||||
def test_kimi_k3_only_offers_supported_reasoning_effort_values() -> None:
|
||||
assert _reasoning_effort_values_for("moonshot", "kimi-k3") == ["", "max"]
|
||||
assert _reasoning_effort_values_for("moonshot", "kimi-k3") == ["", "low", "high", "max"]
|
||||
|
||||
|
||||
def test_settings_payload_includes_versioned_docs(
|
||||
|
||||
Reference in new issue
Block a user