feat(antigravity): add video_url content part support to OpenAI request conversion

Closes: #5056
This commit is contained in:
Luis Pater
2026-08-19 02:18:39 +08:00
parent 4ac37ed3cd
commit 497673bf6b
2 changed files with 42 additions and 0 deletions

View File

@@ -201,6 +201,14 @@ func ConvertOpenAIRequestToAntigravity(modelName string, inputRawJSON []byte, _
partItems = append(partItems, part)
}
}
case "video_url":
videoURL := item.Get("video_url.url").String()
if len(videoURL) > 5 {
pieces := strings.SplitN(videoURL[5:], ";", 2)
if len(pieces) == 2 && len(pieces[1]) > 7 {
partItems = append(partItems, antigravityOpenAIInlineDataPart(pieces[0], pieces[1][7:], false))
}
}
case "file":
filename := item.Get("file.filename").String()
fileData := item.Get("file.file_data").String()

View File

@@ -421,3 +421,37 @@ func assertNoResponseSchemaAliases(t *testing.T, out []byte) {
}
}
}
func TestConvertOpenAIRequestToAntigravityTranslatesVideoURL(t *testing.T) {
inputJSON := []byte(`{
"model": "gemini-3.7-flash-high",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Name the colours in order"},
{"type": "video_url", "video_url": {"url": "data:video/mp4;base64,AAAAIGZ0eXBtcDQy"}}
]
}]
}`)
out := ConvertOpenAIRequestToAntigravity("gemini-3.7-flash-high", inputJSON, false)
parts := gjson.GetBytes(out, "request.contents.0.parts").Array()
if len(parts) != 2 {
t.Fatalf("parts length = %d, want 2. Output: %s", len(parts), out)
}
if got := parts[0].Get("text").String(); got != "Name the colours in order" {
t.Fatalf("parts[0].text = %q, want 'Name the colours in order'", got)
}
inlineData := parts[1].Get("inlineData")
if !inlineData.Exists() {
t.Fatalf("parts[1].inlineData missing. Output: %s", out)
}
if got := inlineData.Get("mimeType").String(); got != "video/mp4" {
t.Fatalf("inlineData.mimeType = %q, want video/mp4. Output: %s", got, out)
}
if got := inlineData.Get("data").String(); got != "AAAAIGZ0eXBtcDQy" {
t.Fatalf("inlineData.data = %q, want AAAAIGZ0eXBtcDQy. Output: %s", got, out)
}
}