(body []byte, config thinking.ThinkingConfig)
| 82 | } |
| 83 | |
| 84 | func applyCompatibleOpenAI(body []byte, config thinking.ThinkingConfig) ([]byte, error) { |
| 85 | if len(body) == 0 || !gjson.ValidBytes(body) { |
| 86 | body = []byte(`{}`) |
| 87 | } |
| 88 | |
| 89 | var effort string |
| 90 | switch config.Mode { |
| 91 | case thinking.ModeLevel: |
| 92 | if config.Level == "" { |
| 93 | return body, nil |
| 94 | } |
| 95 | effort = string(config.Level) |
| 96 | case thinking.ModeNone: |
| 97 | effort = string(thinking.LevelNone) |
| 98 | if config.Level != "" { |
| 99 | effort = string(config.Level) |
| 100 | } |
| 101 | case thinking.ModeAuto: |
| 102 | // Auto mode for user-defined models: pass through as "auto" |
| 103 | effort = string(thinking.LevelAuto) |
| 104 | case thinking.ModeBudget: |
| 105 | // Budget mode: convert budget to level using threshold mapping |
| 106 | level, ok := thinking.ConvertBudgetToLevel(config.Budget) |
| 107 | if !ok { |
| 108 | return body, nil |
| 109 | } |
| 110 | effort = level |
| 111 | default: |
| 112 | return body, nil |
| 113 | } |
| 114 | |
| 115 | result, _ := sjson.SetBytes(body, "reasoning_effort", effort) |
| 116 | return result, nil |
| 117 | } |
no test coverage detected