feat: give zhipu, moonshot, anthropic and google a wire of their own
Eight segments now, and each one holds a ThinkingWire instead of two fixed fragments: off, on_base, and the key a tier gets written to. The two fragments could not say "on, at this depth", which is what every current generation model wants. Two deliberate behaviour changes fall out of it. The openai segment stops reporting its shape as unknown — reasoning_effort is OpenAI's own field, not a vendor dialect, so a compatible endpoint behind the gateway takes it. And minimax's on-tier stops carrying a hardcoded medium: that was the library picking a price for the caller, and medium is not even a tier GLM, kimi or deepseek serve. The issue #5 guards stay; their sample moves from "the openai segment" to an explicitly registered unknown one, which is what they always meant to test.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
import pytest
|
||||
from loguru import logger
|
||||
|
||||
from polygateway.providers import get_provider
|
||||
from polygateway.providers import ProviderProfile, ThinkingWire, get_provider
|
||||
from polygateway.thinking import (
|
||||
DEFAULT_CAPABILITIES,
|
||||
ThinkingCapability,
|
||||
@@ -20,6 +20,16 @@ from polygateway.thinking import (
|
||||
)
|
||||
from polygateway.types import Effort, ThinkingObservation
|
||||
|
||||
_MYSTERY = ProviderProfile(
|
||||
name="mystery",
|
||||
thinking=ThinkingWire(off=None, on_base=None, effort_key=None),
|
||||
strip_think_tags=False,
|
||||
)
|
||||
"""形态完全未知的 provider(issue #5 的守卫对象)。
|
||||
|
||||
2026-09-04 起默认表 8 段全部有形态,故未知样本改为显式构造——测的是**机制**
|
||||
(不知道怎么表达就报错并指路),不是某个段当时的配置。"""
|
||||
|
||||
|
||||
def _warnings():
|
||||
"""捕获库发出的 WARNING;loguru 不经标准 logging,pytest 的 caplog 抓不到。"""
|
||||
@@ -144,7 +154,7 @@ class TestResolveThinking:
|
||||
@pytest.mark.parametrize("enable", [True, False])
|
||||
def test_rule2_unknown_shape_raises_and_points_the_way(self, enable):
|
||||
with pytest.raises(ValueError, match="register_provider") as exc:
|
||||
resolve_thinking(get_provider("openai"), None, enable, model="kimi-k3")
|
||||
resolve_thinking(_MYSTERY, None, enable, model="kimi-k3")
|
||||
assert "extra_body" in str(exc.value)
|
||||
|
||||
def test_rule3_unregistered_model_warns_but_passes(self):
|
||||
@@ -165,7 +175,9 @@ class TestResolveThinking:
|
||||
"""关不掉 ≠ 开不了: M2.x 默认就在推理,开的方向不该被拦。"""
|
||||
cap = get_capability("MiniMax-M2.7")
|
||||
got = resolve_thinking(get_provider("minimax"), cap, True, model="MiniMax-M2.7")
|
||||
assert got == {"reasoning_effort": "medium"}
|
||||
# 2026-09-04: "开"不再硬编码 medium——那是替下游做的档位判断,且 medium 在
|
||||
# GLM/kimi/deepseek 的档位表里根本不存在。MiniMax 开启档本就无需参数
|
||||
assert got == {}
|
||||
|
||||
def test_rule5_normal_path(self):
|
||||
cap = get_capability("MiniMax-M3")
|
||||
@@ -177,7 +189,7 @@ class TestResolveThinking:
|
||||
"""第 2 步先于第 4 步: 形态未知时无从注入,能力如何无关紧要。"""
|
||||
cap = ThinkingCapability((Effort.AUTO,), "构造")
|
||||
with pytest.raises(ValueError, match="register_provider"):
|
||||
resolve_thinking(get_provider("openai"), cap, False, model="whatever")
|
||||
resolve_thinking(_MYSTERY, cap, False, model="whatever")
|
||||
|
||||
|
||||
class TestReconcileThinking:
|
||||
|
||||
Reference in New Issue
Block a user