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

Function applyCompatibleOpenAI

internal/thinking/provider/openai/apply.go:84–117  ·  view source on GitHub ↗
(body []byte, config thinking.ThinkingConfig)

Source from the content-addressed store, hash-verified

82}
83
84func 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}

Callers 1

ApplyMethod · 0.85

Calls 1

ConvertBudgetToLevelFunction · 0.92

Tested by

no test coverage detected