mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 23:47:54 +08:00
lmproto: keep the thinking block's type on the wire
``omit_defaults`` dropped the block's defaulted discriminator, and a request that carried thinking was answered with 422 "thinking: missing field ``type``" — which is what the compat sent for any configured ``reasoning_effort``. The field has no default now, so it always encodes (both call sites pass it).
This commit is contained in:
@@ -11,6 +11,7 @@ from plyngent.lmproto.anthropic.model import (
|
||||
AnthropicMessagesParam,
|
||||
AnthropicMessageStop,
|
||||
AnthropicResponseText,
|
||||
AnthropicThinkingConfig,
|
||||
AnthropicUsage,
|
||||
AnthropicUserMessage,
|
||||
AnthropicWebSearchToolResultContent,
|
||||
@@ -114,6 +115,17 @@ def test_messages_param_encodes_server_tool_dicts() -> None:
|
||||
assert data["tools"] == [{"type": "web_search_20250305", "name": "web_search", "max_uses": 3}]
|
||||
|
||||
|
||||
def test_messages_param_keeps_the_thinking_type_on_the_wire() -> None:
|
||||
"""``omit_defaults`` must not drop the block's ``type`` discriminator."""
|
||||
param = AnthropicMessagesParam(
|
||||
model="deepseek-flash",
|
||||
messages=[AnthropicUserMessage(content="hi")],
|
||||
thinking=AnthropicThinkingConfig(type="enabled", budget_tokens=16384),
|
||||
)
|
||||
data = msgspec.json.decode(msgspec.json.encode(param))
|
||||
assert data["thinking"] == {"type": "enabled", "budget_tokens": 16384}
|
||||
|
||||
|
||||
async def test_client_messages_create(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
client = AnthropicClient(AnthropicConfig(api_key="sk-test", base_url="https://example/v1"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user