fix: align video generation payloads
This commit is contained in:
@@ -6,6 +6,50 @@ import (
|
||||
"github.com/easyai/easyai-ai-gateway/apps/api/internal/store"
|
||||
)
|
||||
|
||||
func TestVideoModelTypeInferenceReadsContentArray(t *testing.T) {
|
||||
imageToVideo := modelTypeFromKind("videos.generations", map[string]any{
|
||||
"model": "demo-video",
|
||||
"content": []any{
|
||||
map[string]any{"type": "text", "text": "animate it"},
|
||||
map[string]any{"type": "image_url", "role": "first_frame", "image_url": map[string]any{"url": "https://example.com/frame.png"}},
|
||||
},
|
||||
})
|
||||
if imageToVideo != "image_to_video" {
|
||||
t.Fatalf("image content should infer image_to_video, got %s", imageToVideo)
|
||||
}
|
||||
|
||||
omniVideo := modelTypeFromKind("videos.generations", map[string]any{
|
||||
"model": "demo-video",
|
||||
"content": []any{
|
||||
map[string]any{"type": "text", "text": "edit it"},
|
||||
map[string]any{"type": "video_url", "role": "reference_video", "video_url": map[string]any{"url": "https://example.com/ref.mp4"}},
|
||||
},
|
||||
})
|
||||
if omniVideo != "omni_video" {
|
||||
t.Fatalf("video content should infer omni_video, got %s", omniVideo)
|
||||
}
|
||||
|
||||
textToVideo := modelTypeFromKind("videos.generations", map[string]any{
|
||||
"model": "demo-video",
|
||||
"content": []any{map[string]any{"type": "text", "text": "make a clip"}},
|
||||
})
|
||||
if textToVideo != "video_generate" {
|
||||
t.Fatalf("text-only content should infer video_generate, got %s", textToVideo)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVideoContentTextContributesToTokenEstimate(t *testing.T) {
|
||||
tokens := estimateRequestTokens(map[string]any{
|
||||
"model": "demo-video",
|
||||
"content": []any{
|
||||
map[string]any{"type": "text", "text": "a cinematic product reveal"},
|
||||
},
|
||||
})
|
||||
if tokens <= 1 {
|
||||
t.Fatalf("content text should contribute to token estimate, got %d", tokens)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParamProcessorOmniFiltersUnsupportedVideoAndAudioContent(t *testing.T) {
|
||||
body := map[string]any{
|
||||
"model": "可灵O1",
|
||||
|
||||
Reference in New Issue
Block a user