mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 12:20:52 +08:00
feat(gemini-cli): support image content in Claude request conversion
- Add logic to handle `image` content type during request translation. - Map Claude base64 image data to Gemini's `inlineData` structure. - Support automatic extraction of `media_type` and `data` for image parts.
This commit is contained in:
@@ -116,6 +116,19 @@ func ConvertClaudeRequestToCLI(modelName string, inputRawJSON []byte, _ bool) []
|
|||||||
part, _ = sjson.Set(part, "functionResponse.name", funcName)
|
part, _ = sjson.Set(part, "functionResponse.name", funcName)
|
||||||
part, _ = sjson.Set(part, "functionResponse.response.result", responseData)
|
part, _ = sjson.Set(part, "functionResponse.response.result", responseData)
|
||||||
contentJSON, _ = sjson.SetRaw(contentJSON, "parts.-1", part)
|
contentJSON, _ = sjson.SetRaw(contentJSON, "parts.-1", part)
|
||||||
|
|
||||||
|
case "image":
|
||||||
|
source := contentResult.Get("source")
|
||||||
|
if source.Get("type").String() == "base64" {
|
||||||
|
mimeType := source.Get("media_type").String()
|
||||||
|
data := source.Get("data").String()
|
||||||
|
if mimeType != "" && data != "" {
|
||||||
|
part := `{"inlineData":{"mime_type":"","data":""}}`
|
||||||
|
part, _ = sjson.Set(part, "inlineData.mime_type", mimeType)
|
||||||
|
part, _ = sjson.Set(part, "inlineData.data", data)
|
||||||
|
contentJSON, _ = sjson.SetRaw(contentJSON, "parts.-1", part)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user