mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
**fix(translator): reintroduce thoughtSignature bypass logic for model parts**
- Restored `thoughtSignature` validator bypass for model-specific parts in Gemini content processing. - Removed redundant logic from the `executor` for cleaner handling.
This commit is contained in:
@@ -669,20 +669,6 @@ func geminiToAntigravity(modelName string, payload []byte) []byte {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gjson.Get(template, "request.contents").ForEach(func(key, content gjson.Result) bool {
|
|
||||||
if content.Get("role").String() == "model" {
|
|
||||||
content.Get("parts").ForEach(func(partKey, part gjson.Result) bool {
|
|
||||||
if part.Get("functionCall").Exists() {
|
|
||||||
template, _ = sjson.Set(template, fmt.Sprintf("request.contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
|
||||||
} else if part.Get("thoughtSignature").Exists() {
|
|
||||||
template, _ = sjson.Set(template, fmt.Sprintf("request.contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
if strings.HasPrefix(modelName, "claude-sonnet-") {
|
if strings.HasPrefix(modelName, "claude-sonnet-") {
|
||||||
gjson.Get(template, "request.tools").ForEach(func(key, tool gjson.Result) bool {
|
gjson.Get(template, "request.tools").ForEach(func(key, tool gjson.Result) bool {
|
||||||
tool.Get("functionDeclarations").ForEach(func(funKey, funcDecl gjson.Result) bool {
|
tool.Get("functionDeclarations").ForEach(func(funKey, funcDecl gjson.Result) bool {
|
||||||
|
|||||||
@@ -98,6 +98,20 @@ func ConvertGeminiRequestToAntigravity(_ string, inputRawJSON []byte, _ bool) []
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gjson.GetBytes(rawJSON, "request.contents").ForEach(func(key, content gjson.Result) bool {
|
||||||
|
if content.Get("role").String() == "model" {
|
||||||
|
content.Get("parts").ForEach(func(partKey, part gjson.Result) bool {
|
||||||
|
if part.Get("functionCall").Exists() {
|
||||||
|
rawJSON, _ = sjson.SetBytes(rawJSON, fmt.Sprintf("request.contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
||||||
|
} else if part.Get("thoughtSignature").Exists() {
|
||||||
|
rawJSON, _ = sjson.SetBytes(rawJSON, fmt.Sprintf("request.contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
return common.AttachDefaultSafetySettings(rawJSON, "request.safetySettings")
|
return common.AttachDefaultSafetySettings(rawJSON, "request.safetySettings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,20 @@ func ConvertGeminiRequestToGeminiCLI(_ string, inputRawJSON []byte, _ bool) []by
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gjson.GetBytes(rawJSON, "request.contents").ForEach(func(key, content gjson.Result) bool {
|
||||||
|
if content.Get("role").String() == "model" {
|
||||||
|
content.Get("parts").ForEach(func(partKey, part gjson.Result) bool {
|
||||||
|
if part.Get("functionCall").Exists() {
|
||||||
|
rawJSON, _ = sjson.SetBytes(rawJSON, fmt.Sprintf("request.contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
||||||
|
} else if part.Get("thoughtSignature").Exists() {
|
||||||
|
rawJSON, _ = sjson.SetBytes(rawJSON, fmt.Sprintf("request.contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
return common.AttachDefaultSafetySettings(rawJSON, "request.safetySettings")
|
return common.AttachDefaultSafetySettings(rawJSON, "request.safetySettings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,5 +46,19 @@ func ConvertGeminiCLIRequestToGemini(_ string, inputRawJSON []byte, _ bool) []by
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gjson.GetBytes(rawJSON, "contents").ForEach(func(key, content gjson.Result) bool {
|
||||||
|
if content.Get("role").String() == "model" {
|
||||||
|
content.Get("parts").ForEach(func(partKey, part gjson.Result) bool {
|
||||||
|
if part.Get("functionCall").Exists() {
|
||||||
|
rawJSON, _ = sjson.SetBytes(rawJSON, fmt.Sprintf("contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
||||||
|
} else if part.Get("thoughtSignature").Exists() {
|
||||||
|
rawJSON, _ = sjson.SetBytes(rawJSON, fmt.Sprintf("contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
return common.AttachDefaultSafetySettings(rawJSON, "safetySettings")
|
return common.AttachDefaultSafetySettings(rawJSON, "safetySettings")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,20 @@ func ConvertGeminiRequestToGemini(_ string, inputRawJSON []byte, _ bool) []byte
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gjson.GetBytes(out, "contents").ForEach(func(key, content gjson.Result) bool {
|
||||||
|
if content.Get("role").String() == "model" {
|
||||||
|
content.Get("parts").ForEach(func(partKey, part gjson.Result) bool {
|
||||||
|
if part.Get("functionCall").Exists() {
|
||||||
|
out, _ = sjson.SetBytes(out, fmt.Sprintf("contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
||||||
|
} else if part.Get("thoughtSignature").Exists() {
|
||||||
|
out, _ = sjson.SetBytes(out, fmt.Sprintf("contents.%d.parts.%d.thoughtSignature", key.Int(), partKey.Int()), "skip_thought_signature_validator")
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
out = common.AttachDefaultSafetySettings(out, "safetySettings")
|
out = common.AttachDefaultSafetySettings(out, "safetySettings")
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|||||||
Reference in New Issue
Block a user