mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
feat(translator): Pass through imageConfig
This commit is contained in:
@@ -79,6 +79,12 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo
|
|||||||
out, _ = sjson.SetBytes(out, "request.generationConfig.topK", tkr.Num)
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
// messages -> systemInstruction + contents
|
// messages -> systemInstruction + contents
|
||||||
messages := gjson.GetBytes(rawJSON, "messages")
|
messages := gjson.GetBytes(rawJSON, "messages")
|
||||||
if messages.IsArray() {
|
if messages.IsArray() {
|
||||||
|
|||||||
@@ -79,6 +79,12 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
|
|||||||
out, _ = sjson.SetBytes(out, "generationConfig.topK", tkr.Num)
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
// messages -> systemInstruction + contents
|
// messages -> systemInstruction + contents
|
||||||
messages := gjson.GetBytes(rawJSON, "messages")
|
messages := gjson.GetBytes(rawJSON, "messages")
|
||||||
if messages.IsArray() {
|
if messages.IsArray() {
|
||||||
|
|||||||
@@ -262,5 +262,11 @@ 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)
|
||||||
|
}
|
||||||
|
|
||||||
return []byte(out)
|
return []byte(out)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user