Skip to content

Commit a756954

Browse files
committed
fix: sync R2V landscape model key and image limits
1 parent e3a2615 commit a756954

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ python main.py
203203
> - 顶层新增 `mediaGenerationContext.batchId`
204204
> - 顶层新增 `useV2ModelConfig: true`
205205
> - 横屏 / 竖屏 `R2V` 模型共用同一套新版请求体
206-
> - 根据当前上游协议,`referenceImages` 建议最多传 **3 张**
206+
> - 横屏 `R2V` 的上游 `videoModelKey` 已切换为 `*_landscape` 形式
207+
> - 根据当前上游协议,`referenceImages` 当前最多传 **3 张**
207208
208209
| 模型名称 | 说明| 尺寸 |
209210
|---------|---------|--------|
@@ -340,7 +341,8 @@ curl -X POST "http://localhost:8000/v1/chat/completions" \
340341
### 多图生成视频
341342

342343
> `R2V` 会由服务端自动组装新版视频请求体,调用方仍然使用 OpenAI 兼容输入即可。
343-
> 当前建议最多传 **3 张参考图**
344+
> 服务端会将横屏 `R2V` 自动映射到最新的 `*_landscape` 上游模型键。
345+
> 当前最多传 **3 张参考图**
344346
345347
```bash
346348
curl -X POST "http://localhost:8000/v1/chat/completions" \

src/services/flow_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Flow API Client for VideoFX (Veo)"""
1+
"""Flow API Client for VideoFX (Veo)"""
22
import asyncio
33
import json
44
import contextvars
@@ -1241,7 +1241,7 @@ async def generate_video_reference_images(
12411241
at: Access Token
12421242
project_id: 项目ID
12431243
prompt: 提示词
1244-
model_key: veo_3_1_r2v_fast
1244+
model_key: veo_3_1_r2v_fast_landscape
12451245
aspect_ratio: 视频宽高比
12461246
reference_images: 参考图片列表 [{"imageUsageType": "IMAGE_USAGE_TYPE_ASSET", "mediaId": "..."}]
12471247
user_paygate_tier: 用户等级

src/services/generation_handler.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@
440440
},
441441

442442
# ========== 多图生成 (R2V - Reference Images to Video) ==========
443-
# 支持多张图片,不限制数量
443+
# 当前上游协议最多支持 3 张参考图
444444

445445
# veo_3_1_r2v_fast (横竖屏)
446446
"veo_3_1_r2v_fast_portrait": {
@@ -450,16 +450,16 @@
450450
"aspect_ratio": "VIDEO_ASPECT_RATIO_PORTRAIT",
451451
"supports_images": True,
452452
"min_images": 0,
453-
"max_images": None # 不限制
453+
"max_images": 3
454454
},
455455
"veo_3_1_r2v_fast": {
456456
"type": "video",
457457
"video_type": "r2v",
458-
"model_key": "veo_3_1_r2v_fast",
458+
"model_key": "veo_3_1_r2v_fast_landscape",
459459
"aspect_ratio": "VIDEO_ASPECT_RATIO_LANDSCAPE",
460460
"supports_images": True,
461461
"min_images": 0,
462-
"max_images": None # 不限制
462+
"max_images": 3
463463
},
464464

465465
# veo_3_1_r2v_fast_ultra (横竖屏)
@@ -470,16 +470,16 @@
470470
"aspect_ratio": "VIDEO_ASPECT_RATIO_PORTRAIT",
471471
"supports_images": True,
472472
"min_images": 0,
473-
"max_images": None # 不限制
473+
"max_images": 3
474474
},
475475
"veo_3_1_r2v_fast_ultra": {
476476
"type": "video",
477477
"video_type": "r2v",
478-
"model_key": "veo_3_1_r2v_fast_ultra",
478+
"model_key": "veo_3_1_r2v_fast_landscape_ultra",
479479
"aspect_ratio": "VIDEO_ASPECT_RATIO_LANDSCAPE",
480480
"supports_images": True,
481481
"min_images": 0,
482-
"max_images": None # 不限制
482+
"max_images": 3
483483
},
484484

485485
# veo_3_1_r2v_fast_ultra_relaxed (横竖屏)
@@ -490,16 +490,16 @@
490490
"aspect_ratio": "VIDEO_ASPECT_RATIO_PORTRAIT",
491491
"supports_images": True,
492492
"min_images": 0,
493-
"max_images": None # 不限制
493+
"max_images": 3
494494
},
495495
"veo_3_1_r2v_fast_ultra_relaxed": {
496496
"type": "video",
497497
"video_type": "r2v",
498-
"model_key": "veo_3_1_r2v_fast_ultra_relaxed",
498+
"model_key": "veo_3_1_r2v_fast_landscape_ultra_relaxed",
499499
"aspect_ratio": "VIDEO_ASPECT_RATIO_LANDSCAPE",
500500
"supports_images": True,
501501
"min_images": 0,
502-
"max_images": None # 不限制
502+
"max_images": 3
503503
},
504504

505505
# ========== 视频放大 (Video Upsampler) ==========
@@ -625,17 +625,17 @@
625625
"aspect_ratio": "VIDEO_ASPECT_RATIO_PORTRAIT",
626626
"supports_images": True,
627627
"min_images": 0,
628-
"max_images": None,
628+
"max_images": 3,
629629
"upsample": {"resolution": "VIDEO_RESOLUTION_4K", "model_key": "veo_3_1_upsampler_4k"}
630630
},
631631
"veo_3_1_r2v_fast_ultra_4k": {
632632
"type": "video",
633633
"video_type": "r2v",
634-
"model_key": "veo_3_1_r2v_fast_ultra",
634+
"model_key": "veo_3_1_r2v_fast_landscape_ultra",
635635
"aspect_ratio": "VIDEO_ASPECT_RATIO_LANDSCAPE",
636636
"supports_images": True,
637637
"min_images": 0,
638-
"max_images": None,
638+
"max_images": 3,
639639
"upsample": {"resolution": "VIDEO_RESOLUTION_4K", "model_key": "veo_3_1_upsampler_4k"}
640640
},
641641

@@ -647,17 +647,17 @@
647647
"aspect_ratio": "VIDEO_ASPECT_RATIO_PORTRAIT",
648648
"supports_images": True,
649649
"min_images": 0,
650-
"max_images": None,
650+
"max_images": 3,
651651
"upsample": {"resolution": "VIDEO_RESOLUTION_1080P", "model_key": "veo_3_1_upsampler_1080p"}
652652
},
653653
"veo_3_1_r2v_fast_ultra_1080p": {
654654
"type": "video",
655655
"video_type": "r2v",
656-
"model_key": "veo_3_1_r2v_fast_ultra",
656+
"model_key": "veo_3_1_r2v_fast_landscape_ultra",
657657
"aspect_ratio": "VIDEO_ASPECT_RATIO_LANDSCAPE",
658658
"supports_images": True,
659659
"min_images": 0,
660-
"max_images": None,
660+
"max_images": 3,
661661
"upsample": {"resolution": "VIDEO_RESOLUTION_1080P", "model_key": "veo_3_1_upsampler_1080p"}
662662
}
663663
}
@@ -1258,7 +1258,7 @@ async def _handle_video_generation(
12581258
# veo_3_1_i2v_s_fast_portrait_fl -> veo_3_1_i2v_s_fast_portrait_ultra_fl
12591259
# veo_3_1_t2v_fast -> veo_3_1_t2v_fast_ultra
12601260
# veo_3_1_t2v_fast_portrait -> veo_3_1_t2v_fast_portrait_ultra
1261-
# veo_3_0_r2v_fast -> veo_3_0_r2v_fast_ultra
1261+
# veo_3_1_r2v_fast_landscape -> veo_3_1_r2v_fast_landscape_ultra
12621262
if "_fl" in model_key:
12631263
model_key = model_key.replace("_fl", "_ultra_fl")
12641264
else:
@@ -1275,6 +1275,7 @@ async def _handle_video_generation(
12751275
if "ultra" in model_key:
12761276
# veo_3_1_i2v_s_fast_ultra_fl -> veo_3_1_i2v_s_fast_fl
12771277
# veo_3_1_t2v_fast_ultra -> veo_3_1_t2v_fast
1278+
# veo_3_1_r2v_fast_landscape_ultra -> veo_3_1_r2v_fast_landscape
12781279
model_key = model_key.replace("_ultra_fl", "_fl").replace("_ultra", "")
12791280

12801281
if stream:
@@ -1308,10 +1309,14 @@ async def _handle_video_generation(
13081309
yield self._create_error_response(error_msg)
13091310
return
13101311

1311-
# R2V: 多图生成 - 支持多张图片,不限制数量
1312+
# R2V: 多图生成 - 当前上游协议最多 3 张参考图
13121313
elif video_type == "r2v":
1313-
# 不再限制最大图片数量
1314-
pass
1314+
if max_images is not None and image_count > max_images:
1315+
error_msg = f"❌ 多图视频模型最多支持 {max_images} 张参考图,当前提供了 {image_count} 张"
1316+
if stream:
1317+
yield self._create_stream_chunk(f"{error_msg}\n")
1318+
yield self._create_error_response(error_msg)
1319+
return
13151320

13161321
# ========== 上传图片 ==========
13171322
start_media_id = None
@@ -1346,7 +1351,7 @@ async def _handle_video_generation(
13461351
if stream:
13471352
yield self._create_stream_chunk(f"上传 {image_count} 张参考图片...\n")
13481353

1349-
for idx, img in enumerate(images): # 上传所有图片,不限制数量
1354+
for img in images:
13501355
media_id = await self.flow_client.upload_image(
13511356
token.at, img, model_config["aspect_ratio"], project_id=project_id
13521357
)
@@ -1752,4 +1757,3 @@ async def _log_request(
17521757
except Exception as e:
17531758
# 日志记录失败不影响主流程
17541759
debug_logger.log_error(f"Failed to log request: {e}")
1755-

0 commit comments

Comments
 (0)