mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 12:20:52 +08:00
fix(gemini): abort default injection on existing thinking keys
This commit is contained in:
@@ -71,12 +71,15 @@ func ApplyGeminiThinkingConfig(body []byte, budget *int, includeThoughts *bool)
|
|||||||
incl = &defaultInclude
|
incl = &defaultInclude
|
||||||
}
|
}
|
||||||
if incl != nil {
|
if incl != nil {
|
||||||
|
if !gjson.GetBytes(updated, "generationConfig.thinkingConfig.includeThoughts").Exists() &&
|
||||||
|
!gjson.GetBytes(updated, "generationConfig.thinkingConfig.include_thoughts").Exists() {
|
||||||
valuePath := "generationConfig.thinkingConfig.include_thoughts"
|
valuePath := "generationConfig.thinkingConfig.include_thoughts"
|
||||||
rewritten, err := sjson.SetBytes(updated, valuePath, *incl)
|
rewritten, err := sjson.SetBytes(updated, valuePath, *incl)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updated = rewritten
|
updated = rewritten
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return updated
|
return updated
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,12 +102,15 @@ func ApplyGeminiCLIThinkingConfig(body []byte, budget *int, includeThoughts *boo
|
|||||||
incl = &defaultInclude
|
incl = &defaultInclude
|
||||||
}
|
}
|
||||||
if incl != nil {
|
if incl != nil {
|
||||||
|
if !gjson.GetBytes(updated, "request.generationConfig.thinkingConfig.includeThoughts").Exists() &&
|
||||||
|
!gjson.GetBytes(updated, "request.generationConfig.thinkingConfig.include_thoughts").Exists() {
|
||||||
valuePath := "request.generationConfig.thinkingConfig.include_thoughts"
|
valuePath := "request.generationConfig.thinkingConfig.include_thoughts"
|
||||||
rewritten, err := sjson.SetBytes(updated, valuePath, *incl)
|
rewritten, err := sjson.SetBytes(updated, valuePath, *incl)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updated = rewritten
|
updated = rewritten
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return updated
|
return updated
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,14 +136,14 @@ func ApplyGeminiThinkingLevel(body []byte, level string, includeThoughts *bool)
|
|||||||
incl = &defaultInclude
|
incl = &defaultInclude
|
||||||
}
|
}
|
||||||
if incl != nil {
|
if incl != nil {
|
||||||
|
if !gjson.GetBytes(updated, "generationConfig.thinkingConfig.includeThoughts").Exists() &&
|
||||||
|
!gjson.GetBytes(updated, "generationConfig.thinkingConfig.include_thoughts").Exists() {
|
||||||
valuePath := "generationConfig.thinkingConfig.includeThoughts"
|
valuePath := "generationConfig.thinkingConfig.includeThoughts"
|
||||||
rewritten, err := sjson.SetBytes(updated, valuePath, *incl)
|
rewritten, err := sjson.SetBytes(updated, valuePath, *incl)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updated = rewritten
|
updated = rewritten
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if it := gjson.GetBytes(body, "generationConfig.thinkingConfig.include_thoughts"); it.Exists() {
|
|
||||||
updated, _ = sjson.DeleteBytes(updated, "generationConfig.thinkingConfig.include_thoughts")
|
|
||||||
}
|
}
|
||||||
if tb := gjson.GetBytes(body, "generationConfig.thinkingConfig.thinkingBudget"); tb.Exists() {
|
if tb := gjson.GetBytes(body, "generationConfig.thinkingConfig.thinkingBudget"); tb.Exists() {
|
||||||
updated, _ = sjson.DeleteBytes(updated, "generationConfig.thinkingConfig.thinkingBudget")
|
updated, _ = sjson.DeleteBytes(updated, "generationConfig.thinkingConfig.thinkingBudget")
|
||||||
@@ -167,14 +173,14 @@ func ApplyGeminiCLIThinkingLevel(body []byte, level string, includeThoughts *boo
|
|||||||
incl = &defaultInclude
|
incl = &defaultInclude
|
||||||
}
|
}
|
||||||
if incl != nil {
|
if incl != nil {
|
||||||
|
if !gjson.GetBytes(updated, "request.generationConfig.thinkingConfig.includeThoughts").Exists() &&
|
||||||
|
!gjson.GetBytes(updated, "request.generationConfig.thinkingConfig.include_thoughts").Exists() {
|
||||||
valuePath := "request.generationConfig.thinkingConfig.includeThoughts"
|
valuePath := "request.generationConfig.thinkingConfig.includeThoughts"
|
||||||
rewritten, err := sjson.SetBytes(updated, valuePath, *incl)
|
rewritten, err := sjson.SetBytes(updated, valuePath, *incl)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updated = rewritten
|
updated = rewritten
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if it := gjson.GetBytes(body, "request.generationConfig.thinkingConfig.include_thoughts"); it.Exists() {
|
|
||||||
updated, _ = sjson.DeleteBytes(updated, "request.generationConfig.thinkingConfig.include_thoughts")
|
|
||||||
}
|
}
|
||||||
if tb := gjson.GetBytes(body, "request.generationConfig.thinkingConfig.thinkingBudget"); tb.Exists() {
|
if tb := gjson.GetBytes(body, "request.generationConfig.thinkingConfig.thinkingBudget"); tb.Exists() {
|
||||||
updated, _ = sjson.DeleteBytes(updated, "request.generationConfig.thinkingConfig.thinkingBudget")
|
updated, _ = sjson.DeleteBytes(updated, "request.generationConfig.thinkingConfig.thinkingBudget")
|
||||||
|
|||||||
Reference in New Issue
Block a user