Revert "feat(translator): Pass through imageConfig"

This commit is contained in:
hkfires
2025-10-09 16:35:08 +08:00
parent a602ae859b
commit d1933075c3
3 changed files with 4 additions and 22 deletions

View File

@@ -79,20 +79,14 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo
out, _ = sjson.SetBytes(out, "request.generationConfig.topK", tkr.Num)
}
// Image config passthrough (e.g., aspectRatio)
// If the input carries generationConfig.imageConfig, preserve it in the Gemini CLI request.
if imgCfg := gjson.GetBytes(rawJSON, "generationConfig.imageConfig"); imgCfg.Exists() && imgCfg.IsObject() {
out, _ = sjson.SetRawBytes(out, "request.generationConfig.imageConfig", []byte(imgCfg.Raw))
}
// OpenRouter-style image_config (snake_case) support
// OpenRouter-style image_config support
// If the input uses top-level image_config.aspect_ratio, map it into request.generationConfig.imageConfig.aspectRatio.
if imgCfg := gjson.GetBytes(rawJSON, "image_config"); imgCfg.Exists() && imgCfg.IsObject() {
if ar := imgCfg.Get("aspect_ratio"); ar.Exists() && ar.Type == gjson.String {
out, _ = sjson.SetBytes(out, "request.generationConfig.imageConfig.aspectRatio", ar.Str)
}
}
// messages -> systemInstruction + contents
messages := gjson.GetBytes(rawJSON, "messages")
if messages.IsArray() {

View File

@@ -79,13 +79,7 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
out, _ = sjson.SetBytes(out, "generationConfig.topK", tkr.Num)
}
// Image config passthrough (e.g., aspectRatio)
// If the input carries generationConfig.imageConfig, preserve it in the Gemini request.
if imgCfg := gjson.GetBytes(rawJSON, "generationConfig.imageConfig"); imgCfg.Exists() && imgCfg.IsObject() {
out, _ = sjson.SetRawBytes(out, "generationConfig.imageConfig", []byte(imgCfg.Raw))
}
// OpenRouter-style image_config (snake_case) support
// OpenRouter-style image_config support
// If the input uses top-level image_config.aspect_ratio, map it into generationConfig.imageConfig.aspectRatio.
if imgCfg := gjson.GetBytes(rawJSON, "image_config"); imgCfg.Exists() && imgCfg.IsObject() {
if ar := imgCfg.Get("aspect_ratio"); ar.Exists() && ar.Type == gjson.String {

View File

@@ -262,13 +262,7 @@ func ConvertOpenAIResponsesRequestToGemini(modelName string, inputRawJSON []byte
}
}
// Image config passthrough (e.g., aspectRatio)
// If the input carries generationConfig.imageConfig, preserve it in the Gemini request.
if imgCfg := root.Get("generationConfig.imageConfig"); imgCfg.Exists() && imgCfg.IsObject() {
out, _ = sjson.SetRaw(out, "generationConfig.imageConfig", imgCfg.Raw)
}
// OpenRouter-style image_config (snake_case) support at top-level
// OpenRouter-style image_config support at top-level
if imgCfg := root.Get("image_config"); imgCfg.Exists() && imgCfg.IsObject() {
if ar := imgCfg.Get("aspect_ratio"); ar.Exists() && ar.Type == gjson.String {
out, _ = sjson.Set(out, "generationConfig.imageConfig.aspectRatio", ar.String())