mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-15 17:25:26 -04:00
fix(llm): omit temperature for Kimi K2.5 and K2.6 (#3960)
This commit is contained in:
@@ -29,7 +29,12 @@ def test_normal_models_allow_temperature(model):
|
||||
assert llm_core._restricts_temperature(model) is False
|
||||
|
||||
|
||||
def _capture_openai_payload(monkeypatch, model, temperature):
|
||||
def _capture_openai_payload(
|
||||
monkeypatch,
|
||||
model,
|
||||
temperature,
|
||||
url="https://api.openai.com/v1/chat/completions",
|
||||
):
|
||||
"""Run a synchronous OpenAI-compatible call and return the posted JSON body."""
|
||||
llm_core._response_cache.clear()
|
||||
seen = {}
|
||||
@@ -45,7 +50,7 @@ def _capture_openai_payload(monkeypatch, model, temperature):
|
||||
|
||||
monkeypatch.setattr(llm_core.httpx, "post", fake_post)
|
||||
result = llm_core.llm_call(
|
||||
"https://api.openai.com/v1/chat/completions",
|
||||
url,
|
||||
model,
|
||||
[{"role": "user", "content": "Say OK"}],
|
||||
temperature=temperature,
|
||||
@@ -131,3 +136,61 @@ def test_anthropic_payload_clamps_negative():
|
||||
def test_anthropic_payload_none_temperature_does_not_crash():
|
||||
payload = _anthropic_payload(None)
|
||||
assert payload["temperature"] is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model",
|
||||
[
|
||||
"kimi-k2.5",
|
||||
"kimi-k2.6",
|
||||
"moonshot/kimi-k2.6",
|
||||
"kimi-k2.6-preview",
|
||||
],
|
||||
)
|
||||
def test_moonshot_k2_5_plus_uses_fixed_temperature(model):
|
||||
assert llm_core._moonshot_rejects_custom_temperature("moonshot", model)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"provider,model",
|
||||
[
|
||||
("openai", "kimi-k2.6"),
|
||||
("moonshot", "kimi-k2-0905-preview"),
|
||||
("moonshot", "kimi-k2-thinking"),
|
||||
("moonshot", "kimi-k2.50"),
|
||||
("moonshot", None),
|
||||
],
|
||||
)
|
||||
def test_other_models_keep_temperature(provider, model):
|
||||
assert not llm_core._moonshot_rejects_custom_temperature(provider, model)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"url",
|
||||
[
|
||||
"https://api.moonshot.ai/v1/chat/completions",
|
||||
"https://api.moonshot.cn/v1/chat/completions",
|
||||
],
|
||||
)
|
||||
def test_moonshot_provider_detection(url):
|
||||
assert llm_core._detect_provider(url) == "moonshot"
|
||||
|
||||
|
||||
def test_moonshot_k2_6_payload_omits_temperature(monkeypatch):
|
||||
payload = _capture_openai_payload(
|
||||
monkeypatch,
|
||||
"kimi-k2.6",
|
||||
0.7,
|
||||
url="https://api.moonshot.ai/v1/chat/completions",
|
||||
)
|
||||
assert "temperature" not in payload
|
||||
|
||||
|
||||
def test_self_hosted_kimi_k2_6_payload_keeps_temperature(monkeypatch):
|
||||
payload = _capture_openai_payload(
|
||||
monkeypatch,
|
||||
"kimi-k2.6",
|
||||
0.7,
|
||||
url="http://localhost:8000/v1/chat/completions",
|
||||
)
|
||||
assert payload["temperature"] == 0.7
|
||||
|
||||
Reference in New Issue
Block a user