MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / convertAutoToMidRange

Function convertAutoToMidRange

internal/thinking/validate.go:177–211  ·  view source on GitHub ↗

convertAutoToMidRange converts ModeAuto to a mid-range value when dynamic is not allowed. This function handles the case where a model does not support dynamic/auto thinking. The auto mode is silently converted to a fixed value based on model capability: - Level-only models: convert to ModeLevel wi

(config ThinkingConfig, support *registry.ThinkingSupport, provider, model string)

Source from the content-addressed store, hash-verified

175// - Debug level when conversion occurs
176// - Fields: original_mode, clamped_to, reason
177func convertAutoToMidRange(config ThinkingConfig, support *registry.ThinkingSupport, provider, model string) ThinkingConfig {
178 // For level-only models (has Levels but no Min/Max range), use ModeLevel with medium
179 if len(support.Levels) > 0 && support.Min == 0 && support.Max == 0 {
180 config.Mode = ModeLevel
181 config.Level = LevelMedium
182 config.Budget = 0
183 log.WithFields(log.Fields{
184 "provider": provider,
185 "model": model,
186 "original_mode": "auto",
187 "clamped_to": string(LevelMedium),
188 }).Debug("thinking: mode converted, dynamic not allowed, using medium level |")
189 return config
190 }
191
192 // For budget models, use mid-range budget
193 mid := (support.Min + support.Max) / 2
194 if mid <= 0 && support.ZeroAllowed {
195 config.Mode = ModeNone
196 config.Budget = 0
197 } else if mid <= 0 {
198 config.Mode = ModeBudget
199 config.Budget = support.Min
200 } else {
201 config.Mode = ModeBudget
202 config.Budget = mid
203 }
204 log.WithFields(log.Fields{
205 "provider": provider,
206 "model": model,
207 "original_mode": "auto",
208 "clamped_to": config.Budget,
209 }).Debug("thinking: mode converted, dynamic not allowed |")
210 return config
211}
212
213// standardLevelOrder defines the canonical ordering of thinking levels from lowest to highest.
214var standardLevelOrder = []ThinkingLevel{LevelMinimal, LevelLow, LevelMedium, LevelHigh, LevelXHigh, LevelMax}

Callers 1

ValidateConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected