feat: support Kimi K3
This commit is contained in:
committed by
Xubin Ren
parent
b76d54aae1
commit
8c68c6fe1e
@@ -1540,6 +1540,43 @@ def test_kimi_k25_no_extra_body_when_reasoning_effort_none() -> None:
|
||||
assert "extra_body" not in kw
|
||||
|
||||
|
||||
def test_kimi_k3_uses_native_defaults() -> None:
|
||||
"""K3 omits fixed sampling params and uses the non-deprecated token limit field."""
|
||||
kw = _build_kwargs_for("moonshot", "kimi-k3", reasoning_effort=None)
|
||||
|
||||
assert "temperature" not in kw
|
||||
assert "max_tokens" not in kw
|
||||
assert kw["max_completion_tokens"] == 1024
|
||||
assert "reasoning_effort" not in kw
|
||||
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")
|
||||
|
||||
assert kw["reasoning_effort"] == "max"
|
||||
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")
|
||||
|
||||
assert kw["reasoning_effort"] == "max"
|
||||
assert "extra_body" not in kw
|
||||
|
||||
|
||||
def test_kimi_k3_omits_disabled_reasoning_effort() -> None:
|
||||
"""K3 cannot disable reasoning, so disabled effort falls back to its default."""
|
||||
kw = _build_kwargs_for("moonshot", "kimi-k3", reasoning_effort="none")
|
||||
|
||||
assert "reasoning_effort" not in kw
|
||||
assert "temperature" not in kw
|
||||
assert "extra_body" not in kw
|
||||
|
||||
|
||||
def test_kimi_k25_thinking_enabled_with_openrouter_prefix() -> None:
|
||||
"""OpenRouter-style model names like moonshotai/kimi-k2.5 must trigger thinking.
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ from nanobot.webui.settings_api import (
|
||||
_docs_version,
|
||||
_model_catalog_kind,
|
||||
_oauth_provider_status,
|
||||
_reasoning_effort_values_for,
|
||||
create_model_configuration,
|
||||
login_oauth_provider,
|
||||
provider_models_payload,
|
||||
@@ -40,6 +41,10 @@ def test_docs_version_uses_released_versions_and_falls_back_for_dev() -> None:
|
||||
assert _docs_version("0.2.3+editable") == "latest"
|
||||
|
||||
|
||||
def test_kimi_k3_only_offers_supported_reasoning_effort_values() -> None:
|
||||
assert _reasoning_effort_values_for("moonshot", "kimi-k3") == ["", "max"]
|
||||
|
||||
|
||||
def test_settings_payload_includes_versioned_docs(
|
||||
tmp_path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
@@ -357,13 +362,13 @@ def test_update_model_configuration_accepts_context_window_options(
|
||||
payload = update_model_configuration(
|
||||
{
|
||||
"name": ["codex"],
|
||||
"context_window_tokens": ["262144"],
|
||||
"context_window_tokens": ["1048576"],
|
||||
}
|
||||
)
|
||||
|
||||
assert payload["agent"]["context_window_tokens"] == 262144
|
||||
assert payload["agent"]["context_window_tokens"] == 1048576
|
||||
saved = load_config(config_path)
|
||||
assert saved.model_presets["codex"].context_window_tokens == 262144
|
||||
assert saved.model_presets["codex"].context_window_tokens == 1048576
|
||||
|
||||
|
||||
def test_update_context_window_rejects_unknown_values(
|
||||
@@ -376,7 +381,7 @@ def test_update_context_window_rejects_unknown_values(
|
||||
|
||||
with pytest.raises(
|
||||
WebUISettingsError,
|
||||
match="context_window_tokens must be 65536, 200000, or 262144",
|
||||
match="context_window_tokens must be 65536, 200000, 262144, or 1048576",
|
||||
):
|
||||
update_agent_settings({"context_window_tokens": ["128000"]})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user