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

Function applyCompatibleKimi

internal/thinking/provider/kimi/apply.go:98–131  ·  view source on GitHub ↗

applyCompatibleKimi applies thinking config for user-defined Kimi models.

(body []byte, config thinking.ThinkingConfig)

Source from the content-addressed store, hash-verified

96
97// applyCompatibleKimi applies thinking config for user-defined Kimi models.
98func applyCompatibleKimi(body []byte, config thinking.ThinkingConfig) ([]byte, error) {
99 if len(body) == 0 || !gjson.ValidBytes(body) {
100 body = []byte(`{}`)
101 }
102
103 var effort string
104 switch config.Mode {
105 case thinking.ModeLevel:
106 if config.Level == "" {
107 return body, nil
108 }
109 effort = string(config.Level)
110 case thinking.ModeNone:
111 if config.Level == "" || config.Level == thinking.LevelNone {
112 return applyDisabledThinking(body)
113 }
114 if config.Level != "" {
115 effort = string(config.Level)
116 }
117 case thinking.ModeAuto:
118 effort = string(thinking.LevelAuto)
119 case thinking.ModeBudget:
120 // Convert budget to level
121 level, ok := thinking.ConvertBudgetToLevel(config.Budget)
122 if !ok {
123 return body, nil
124 }
125 effort = level
126 default:
127 return body, nil
128 }
129
130 return applyReasoningEffort(body, effort)
131}
132
133func applyReasoningEffort(body []byte, effort string) ([]byte, error) {
134 result, errDeleteThinking := sjson.DeleteBytes(body, "thinking")

Callers 1

ApplyMethod · 0.85

Calls 3

ConvertBudgetToLevelFunction · 0.92
applyDisabledThinkingFunction · 0.85
applyReasoningEffortFunction · 0.85

Tested by

no test coverage detected