mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-04-28 13:49:56 +00:00
fix: preserve input_audio content parts when proxying to Antigravity
- Add input_audio handling in chat/completions translator (antigravity_openai_request.go) - Add input_audio handling in responses translator (gemini_openai-responses_request.go) - Map OpenAI audio formats (mp3, wav, ogg, flac, aac, webm, pcm16, g711_ulaw, g711_alaw) to correct MIME types for Gemini inlineData
This commit is contained in:
@@ -207,6 +207,33 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _
|
|||||||
} else {
|
} else {
|
||||||
log.Warnf("Unknown file name extension '%s' in user message, skip", ext)
|
log.Warnf("Unknown file name extension '%s' in user message, skip", ext)
|
||||||
}
|
}
|
||||||
|
case "input_audio":
|
||||||
|
audioData := item.Get("input_audio.data").String()
|
||||||
|
audioFormat := item.Get("input_audio.format").String()
|
||||||
|
if audioData != "" {
|
||||||
|
audioMimeMap := map[string]string{
|
||||||
|
"mp3": "audio/mpeg",
|
||||||
|
"wav": "audio/wav",
|
||||||
|
"ogg": "audio/ogg",
|
||||||
|
"flac": "audio/flac",
|
||||||
|
"aac": "audio/aac",
|
||||||
|
"webm": "audio/webm",
|
||||||
|
"pcm16": "audio/pcm",
|
||||||
|
"g711_ulaw": "audio/basic",
|
||||||
|
"g711_alaw": "audio/basic",
|
||||||
|
}
|
||||||
|
mimeType := "audio/wav"
|
||||||
|
if audioFormat != "" {
|
||||||
|
if mapped, ok := audioMimeMap[audioFormat]; ok {
|
||||||
|
mimeType = mapped
|
||||||
|
} else {
|
||||||
|
mimeType = "audio/" + audioFormat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".inlineData.mime_type", mimeType)
|
||||||
|
node, _ = sjson.SetBytes(node, "parts."+itoa(p)+".inlineData.data", audioData)
|
||||||
|
p++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,6 +237,33 @@ func ConvertOpenAIResponsesRequestToGemini(modelName string, inputRawJSON []byte
|
|||||||
partJSON, _ = sjson.Set(partJSON, "inline_data.data", data)
|
partJSON, _ = sjson.Set(partJSON, "inline_data.data", data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "input_audio":
|
||||||
|
audioData := contentItem.Get("data").String()
|
||||||
|
audioFormat := contentItem.Get("format").String()
|
||||||
|
if audioData != "" {
|
||||||
|
audioMimeMap := map[string]string{
|
||||||
|
"mp3": "audio/mpeg",
|
||||||
|
"wav": "audio/wav",
|
||||||
|
"ogg": "audio/ogg",
|
||||||
|
"flac": "audio/flac",
|
||||||
|
"aac": "audio/aac",
|
||||||
|
"webm": "audio/webm",
|
||||||
|
"pcm16": "audio/pcm",
|
||||||
|
"g711_ulaw": "audio/basic",
|
||||||
|
"g711_alaw": "audio/basic",
|
||||||
|
}
|
||||||
|
mimeType := "audio/wav"
|
||||||
|
if audioFormat != "" {
|
||||||
|
if mapped, ok := audioMimeMap[audioFormat]; ok {
|
||||||
|
mimeType = mapped
|
||||||
|
} else {
|
||||||
|
mimeType = "audio/" + audioFormat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
partJSON = `{"inline_data":{"mime_type":"","data":""}}`
|
||||||
|
partJSON, _ = sjson.Set(partJSON, "inline_data.mime_type", mimeType)
|
||||||
|
partJSON, _ = sjson.Set(partJSON, "inline_data.data", audioData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if partJSON != "" {
|
if partJSON != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user