mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-08 01:16:47 +08:00
feat(videos): add support for video_url extraction and validation in handlers
- Updated `openai_videos_handlers` to extract and set `video_url` from payloads when available. - Enhanced unit tests to validate correct `video_url` extraction and inclusion in responses.
This commit is contained in:
@@ -559,6 +559,9 @@ func buildVideosRetrieveAPIResponseFromXAI(videoID string, payload []byte, fallb
|
||||
} else if duration := gjson.GetBytes(payload, "video.duration"); duration.Exists() {
|
||||
out, _ = sjson.SetBytes(out, "seconds", duration.String())
|
||||
}
|
||||
if videoURL := strings.TrimSpace(gjson.GetBytes(payload, "video.url").String()); videoURL != "" {
|
||||
out, _ = sjson.SetBytes(out, "video_url", videoURL)
|
||||
}
|
||||
out = setOpenAIVideoErrorFromXAI(out, payload)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@@ -317,6 +317,9 @@ func TestBuildVideosRetrieveAPIResponseFromXAI(t *testing.T) {
|
||||
if got := gjson.GetBytes(out, "seconds").String(); got != "4" {
|
||||
t.Fatalf("seconds = %q, want 4", got)
|
||||
}
|
||||
if got := gjson.GetBytes(out, "video_url").String(); got != "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-08609066-e7e9-43ba-bd8d-bd29cb6221d9.mp4" {
|
||||
t.Fatalf("video_url = %q", got)
|
||||
}
|
||||
if gjson.GetBytes(out, "video").Exists() {
|
||||
t.Fatalf("video field must not be exposed in OpenAI retrieve response: %s", string(out))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user