feat: add opt-in cross-source hedged requests for chat
This commit is contained in:
@@ -144,6 +144,32 @@ class TestChatEndToEnd:
|
||||
await client.chat([{"role": "user", "content": "hi"}], structured="json")
|
||||
|
||||
|
||||
class TestHedgeParams:
|
||||
"""对冲两个 keyword-only 参数的 client 入口校验(issue #24 H4;计划批次 H)。
|
||||
|
||||
编排行为本身见 tests/unit/test_hedge.py;这里只钉装配面: 入口即校、
|
||||
值域/交叉守卫与 settings 共用同一份 `check_hedge_assembly`。
|
||||
"""
|
||||
|
||||
def test_client_hedge_params_entry_validation(self):
|
||||
# 值域: 0/负/非有限当场 ValueError(不经 settings 那道守卫)
|
||||
with pytest.raises(ValueError, match=r"GatewayClient\(hedge_after_s"):
|
||||
_client(hedge_after_s=0)
|
||||
with pytest.raises(ValueError, match="hedge_max_extra"):
|
||||
_client(hedge_max_extra=0)
|
||||
with pytest.raises(ValueError, match="hedge_max_extra"):
|
||||
_client(hedge_max_extra=True) # bool 不是 int 档位
|
||||
# 交叉: 阈值 ≥ 源 timeout_s(10)= 对冲永不可能触发
|
||||
with pytest.raises(ValueError, match="timeout_s"):
|
||||
_client(hedge_after_s=99.0)
|
||||
# 合法值透传到 RetryMW(单源 scope 的装配 warning 是预期噪音,不断言)
|
||||
client = _client(hedge_after_s=0.05)
|
||||
assert client._hedge_after_s == 0.05
|
||||
assert client._terminal._hedge_after_s == 0.05
|
||||
# 未启用(缺省): 行为逐字等于 1.3.6
|
||||
assert _client()._terminal._hedge_after_s is None
|
||||
|
||||
|
||||
class TestGenerationMsClient:
|
||||
"""裸生成时间的 client 级口径(1.3.7 批次 C2/F)。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user