fix(audio): 兼容百炼 OpenAI 音频输入

为阿里云百炼 OpenAI-compatible Chat 统一保留标准 input_audio,并将旧版 audio_url 转换为 input_audio,同时根据 MIME 或扩展名补齐音频格式。

补充请求资产水合测试,确认 input_audio.data 会转换为裸 Base64 且保留 format。

验证:在 apps/api 执行 env -u AI_GATEWAY_TEST_DATABASE_URL go test ./... -count=1 全部通过。
This commit is contained in:
2026-07-27 23:50:17 +08:00
parent 95776c84f6
commit 046c16fc69
4 changed files with 297 additions and 0 deletions
+5
View File
@@ -48,6 +48,11 @@ func (c OpenAIClient) Run(ctx context.Context, request Request) (Response, error
}
if endpointKind == "chat.completions" {
body = NormalizeChatCompletionRequestBody(body)
normalizedBody, normalizeErr := normalizeOpenAIChatAudioParts(body, request.Candidate)
if normalizeErr != nil {
return Response{}, normalizeErr
}
body = normalizedBody
applyOpenAIChatReasoningParams(body, request.Candidate)
body = FilterOpenAIChatRequestBody(body)
} else if request.Kind == "responses" {