fix(model): DeepSeek 推理参数语义反转 + thinking 开关真发(按官方文档核对结果)
依据 DevDocs/design/04 §3.2「官方核对后的修正」9 条 + 本地 DevDocs/reference/deepseek/facts-for-cyrene.md(官方原句/URL)。 - 🔴 reasoning_effort 白名单改为官方集合 [none, low, high, max] + 别名映射(minimal→low, medium→high, xhigh→high, ultra→max);**删除就近降级**,非法值一律丢弃+WARN。此前 none(关思考) 被降级成 low(开思考) 属语义反转 - 🔴 DeepSeek thinking 开关真发顶层 {"thinking":{"type":"enabled|disabled"}}(官方默认 enabled,不传≠关);此前只打 WARN 导致 mode:off 静默无效 - DeepSeek 的 /anthropic 端点忽略 budget_tokens → 不再对其抬 max_tokens(会误导预算/日志),改为按官方用 output_config.effort - 注释纠正:penalty 属接口级 deprecated(非仅思考模式);top_p 仅思考模式生效且下限 0.95(不加该字段) - tool_choice 雷登记:思考模式下 required/指定 tool 会 400(思考默认开) - 旧模型名清理(deepseek-chat/reasoner 已于 2026-07-24 停用) - 请求体级测试 + 变异验证(把 none 改回 low / 把 thinking 改回只 WARN → 对应断言 FAIL)
This commit is contained in:
1 parent
0624d9ee36
commit
0de68bc960
11 files changed
+1076
-149
No files matched your search
@@ -175,28 +175,29 @@ func TestOpenAIChat_ReasoningEffortPassthrough(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestOpenAIChat_ReasoningEffortDowngradedForDeepSeek asserts a tier the vendor
|
||||
// does not accept (DeepSeek allows only low/high/max) is rounded down to the
|
||||
// nearest allowed tier and reported, never forwarded as-is.
|
||||
func TestOpenAIChat_ReasoningEffortDowngradedForDeepSeek(t *testing.T) {
|
||||
// TestOpenAIChat_ReasoningEffortAliasMappedForDeepSeek asserts a DeepSeek
|
||||
// compatibility alias is normalized to the tier the service applies (medium →
|
||||
// high per the official mapping table) and reported, never graded down to a
|
||||
// weaker tier of our own choosing.
|
||||
func TestOpenAIChat_ReasoningEffortAliasMappedForDeepSeek(t *testing.T) {
|
||||
t.Parallel()
|
||||
ch := make(chan capturedRequest, 1)
|
||||
srv := newCompletionServer(t, http.StatusOK, "application/json", okCompletion, ch)
|
||||
log, buf := captureLog()
|
||||
ad := NewOpenAIChat(config.LLMConfig{BaseURL: srv.URL, Model: "deepseek-chat"}, WithOpenAILogger(log))
|
||||
ad := NewOpenAIChat(config.LLMConfig{BaseURL: srv.URL, Model: "deepseek-flash"}, WithOpenAILogger(log))
|
||||
|
||||
if _, err := ad.Chat(context.Background(), Request{
|
||||
Model: "deepseek-chat",
|
||||
Model: "deepseek-flash",
|
||||
Messages: []Message{TextMessage(RoleUser, "hi")},
|
||||
ReasoningEffort: "medium",
|
||||
}, Options{}); err != nil {
|
||||
t.Fatalf("Chat error: %v", err)
|
||||
}
|
||||
if got := (<-ch).body["reasoning_effort"]; got != "low" {
|
||||
t.Fatalf("body.reasoning_effort = %v, want the downgraded low", got)
|
||||
if got := (<-ch).body["reasoning_effort"]; got != "high" {
|
||||
t.Fatalf("body.reasoning_effort = %v, want the officially mapped high", got)
|
||||
}
|
||||
rec := buf.String()
|
||||
for _, want := range []string{"level=WARN", "reasoning_effort", "deepseek", "medium", "low"} {
|
||||
for _, want := range []string{"level=WARN", "reasoning_effort", "deepseek", "medium", "high"} {
|
||||
if !strings.Contains(rec, want) {
|
||||
t.Errorf("log %q missing %q", rec, want)
|
||||
}
|
||||
@@ -346,7 +347,7 @@ func TestReasoningVendorFor_Classification(t *testing.T) {
|
||||
baseURL string
|
||||
want reasoningVendor
|
||||
}{
|
||||
{model: "deepseek-reasoner", want: vendorDeepSeek},
|
||||
{model: "deepseek-v4-pro", want: vendorDeepSeek},
|
||||
{model: "Qwen3-Max", want: vendorQwen},
|
||||
{model: "gpt-4o", want: vendorOpenAI},
|
||||
{model: "o3-mini", want: vendorOpenAI},
|
||||
|
||||
Reference in new issue
Block a user