mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
fix(gemini): map responseModalities to uppercase IMAGE/TEXT
This commit is contained in:
@@ -703,7 +703,7 @@ func fixGeminiCLIImageAspectRatio(modelName string, rawJSON []byte) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rawJSON, _ = sjson.SetRawBytes(rawJSON, "request.contents.0.parts", []byte(newPartsJson))
|
rawJSON, _ = sjson.SetRawBytes(rawJSON, "request.contents.0.parts", []byte(newPartsJson))
|
||||||
rawJSON, _ = sjson.SetRawBytes(rawJSON, "request.generationConfig.responseModalities", []byte(`["Image", "Text"]`))
|
rawJSON, _ = sjson.SetRawBytes(rawJSON, "request.generationConfig.responseModalities", []byte(`["IMAGE", "TEXT"]`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rawJSON, _ = sjson.DeleteBytes(rawJSON, "request.generationConfig.imageConfig")
|
rawJSON, _ = sjson.DeleteBytes(rawJSON, "request.generationConfig.imageConfig")
|
||||||
|
|||||||
@@ -66,15 +66,15 @@ func ConvertOpenAIRequestToGeminiCLI(modelName string, inputRawJSON []byte, _ bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Map OpenAI modalities -> Gemini CLI request.generationConfig.responseModalities
|
// Map OpenAI modalities -> Gemini CLI request.generationConfig.responseModalities
|
||||||
// e.g. "modalities": ["image", "text"] -> ["Image", "Text"]
|
// e.g. "modalities": ["image", "text"] -> ["IMAGE", "TEXT"]
|
||||||
if mods := gjson.GetBytes(rawJSON, "modalities"); mods.Exists() && mods.IsArray() {
|
if mods := gjson.GetBytes(rawJSON, "modalities"); mods.Exists() && mods.IsArray() {
|
||||||
var responseMods []string
|
var responseMods []string
|
||||||
for _, m := range mods.Array() {
|
for _, m := range mods.Array() {
|
||||||
switch strings.ToLower(m.String()) {
|
switch strings.ToLower(m.String()) {
|
||||||
case "text":
|
case "text":
|
||||||
responseMods = append(responseMods, "Text")
|
responseMods = append(responseMods, "TEXT")
|
||||||
case "image":
|
case "image":
|
||||||
responseMods = append(responseMods, "Image")
|
responseMods = append(responseMods, "IMAGE")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(responseMods) > 0 {
|
if len(responseMods) > 0 {
|
||||||
|
|||||||
@@ -66,15 +66,15 @@ func ConvertOpenAIRequestToGemini(modelName string, inputRawJSON []byte, _ bool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Map OpenAI modalities -> Gemini generationConfig.responseModalities
|
// Map OpenAI modalities -> Gemini generationConfig.responseModalities
|
||||||
// e.g. "modalities": ["image", "text"] -> ["Image", "Text"]
|
// e.g. "modalities": ["image", "text"] -> ["IMAGE", "TEXT"]
|
||||||
if mods := gjson.GetBytes(rawJSON, "modalities"); mods.Exists() && mods.IsArray() {
|
if mods := gjson.GetBytes(rawJSON, "modalities"); mods.Exists() && mods.IsArray() {
|
||||||
var responseMods []string
|
var responseMods []string
|
||||||
for _, m := range mods.Array() {
|
for _, m := range mods.Array() {
|
||||||
switch strings.ToLower(m.String()) {
|
switch strings.ToLower(m.String()) {
|
||||||
case "text":
|
case "text":
|
||||||
responseMods = append(responseMods, "Text")
|
responseMods = append(responseMods, "TEXT")
|
||||||
case "image":
|
case "image":
|
||||||
responseMods = append(responseMods, "Image")
|
responseMods = append(responseMods, "IMAGE")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(responseMods) > 0 {
|
if len(responseMods) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user