| 1 | package openai |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/provider" |
| 7 | ) |
| 8 | |
| 9 | // A third-party endpoint can serve a DeepSeek model under its own effort scale. |
| 10 | // Declaring supported_efforts is how the config says so, and our built-in |
| 11 | // DeepSeek vocabulary must not override that declaration (#7273) — the same |
| 12 | // rule the "low" level already followed. |
| 13 | func TestDeepSeekThinkingHonorsDeclaredEffortVocabulary(t *testing.T) { |
| 14 | p, err := New(provider.Config{ |
| 15 | Name: "proxy", |
| 16 | BaseURL: "https://proxy.example.com/v1", |
| 17 | Model: "deepseek-v4-flash", |
| 18 | APIKey: "test", |
| 19 | Extra: map[string]any{ |
| 20 | "effort": "medium", |
| 21 | "reasoning_protocol": "deepseek", |
| 22 | "supported_efforts": []string{"low", "medium", "high", "none"}, |
| 23 | }, |
| 24 | }) |
| 25 | if err != nil { |
| 26 | t.Fatalf("New with declared effort vocabulary: %v", err) |
| 27 | } |
| 28 | if got := p.(*client).buildRequest(provider.Request{}).ReasoningEffort; got != "medium" { |
| 29 | t.Fatalf("reasoning_effort = %q, want the declared level forwarded", got) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | // Without a declaration there is nothing to defer to, so an unknown level is |
| 34 | // still rejected rather than silently forwarded to the official endpoint. |
| 35 | func TestDeepSeekThinkingRejectsUndeclaredEffort(t *testing.T) { |
| 36 | _, err := New(provider.Config{ |
| 37 | Name: "official", |
| 38 | BaseURL: "https://api.deepseek.com", |
| 39 | Model: "deepseek-v4-flash", |
| 40 | APIKey: "test", |
| 41 | Extra: map[string]any{ |
| 42 | "effort": "medium", |
| 43 | "reasoning_protocol": "deepseek", |
| 44 | }, |
| 45 | }) |
| 46 | if err == nil { |
| 47 | t.Fatal("New with an undeclared effort level = nil error, want rejection") |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // A declaration that does not list the requested level is still a rejection: |
| 52 | // honoring the config means honoring what it actually says. |
| 53 | func TestDeepSeekThinkingRejectsEffortOutsideDeclaration(t *testing.T) { |
| 54 | _, err := New(provider.Config{ |
| 55 | Name: "proxy", |
| 56 | BaseURL: "https://proxy.example.com/v1", |
| 57 | Model: "deepseek-v4-flash", |
| 58 | APIKey: "test", |
| 59 | Extra: map[string]any{ |
| 60 | "effort": "medium", |
| 61 | "reasoning_protocol": "deepseek", |
| 62 | "supported_efforts": []string{"low", "high"}, |
| 63 | }, |
| 64 | }) |
| 65 | if err == nil { |
| 66 | t.Fatal("New with an effort outside the declaration = nil error, want rejection") |
| 67 | } |
| 68 | } |
| 69 |