Publish Seedance 2.5 draft mode and video updates

- Add the 样片模式 flow: 480p draft generation, a linkable draft task ID, and pre-flight verification before the 1080p final request.

- Allow reference images and audio in video edit/extend requests, matching the provider's 2.5 contract.

- Move 主模型 and 样片模式 ahead of 生成模式, default 主模型 to seedance 2.5, and migrate saved widget values.

- Refresh the video panel, asset API response logs, and LLM node handling; cover the new behavior with offline tests.
This commit is contained in:
Jony
2026-10-21 20:13:55 +08:00
parent 532d4a9541
commit ff1cf830fa
27 changed files with 1810 additions and 341 deletions
+46 -15
View File
@@ -87,6 +87,32 @@ class SeedanceClient:
# ── 2. 轮询状态 ────────────────────────────────────────────────────
async def get_task_async(
self,
task_id: str,
session: aiohttp.ClientSession = None,
) -> Dict[str, Any]:
"""查询一次任务详情(不轮询),用于样片任务出片前校验。"""
url = f"{self.base_url}{self.STATUS_ENDPOINT.format(task_id=task_id)}"
should_close = session is None
if session is None:
connector = aiohttp.TCPConnector(ssl=False, force_close=True)
session = aiohttp.ClientSession(connector=connector)
try:
check_interrupt()
resp = await run_with_interrupt(async_request_with_retry(
session, "GET", url, headers=self._headers(), prefix="Seedance 任务查询: "
))
text = await resp.text()
resp.release()
payload = json.loads(text)
if not isinstance(payload, dict):
raise RuntimeError("Seedance 任务查询返回格式错误")
return payload
finally:
if should_close:
await session.close()
async def poll_async(
self,
task_id: str,
@@ -102,18 +128,13 @@ class SeedanceClient:
while True:
deadline.check()
check_interrupt()
async with session.get(url, headers=self._headers()) as resp:
text = await resp.text()
if resp.status != 200:
try:
err = json.loads(text)
msg = (err.get("error", {}).get("message")
or err.get("message")
or text)
except Exception:
msg = text
raise RuntimeError(f"状态查询失败 ({resp.status}): {msg}")
result = json.loads(text)
# 轮询同样走重试:长任务中途的 429/503 不应让已付费的任务作废
resp = await run_with_interrupt(async_request_with_retry(
session, "GET", url, headers=self._headers(), prefix="Seedance 状态查询: "
))
text = await resp.text()
resp.release()
result = json.loads(text)
# new-api 包装格式:真实数据在 result["data"] 里
inner = result.get("data") or result
@@ -129,20 +150,27 @@ class SeedanceClient:
if is_success_status(status):
# 响应结构:result["data"] = inner,inner["data"] = platform_data
# 视频 URL 在 inner["result_url"] 或 inner["data"]["content"]["video_url"]
# 视频 URL 在 inner["result_url"] 或 metadata.url
# 末帧图片 URL 在 metadata.last_frame_url
platform_data = inner.get("data") or {}
content = platform_data.get("content") or {}
metadata = inner.get("metadata")
if not isinstance(metadata, dict):
metadata = platform_data.get("metadata")
if not isinstance(metadata, dict):
metadata = {}
video_url = (
inner.get("result_url")
or metadata.get("url")
or content.get("video_url")
or platform_data.get("video_url")
or inner.get("url")
)
if not video_url:
raise RuntimeError("任务成功但未找到视频 URL")
# 末帧图片 URL 在 inner["data"]["content"]["last_frame_url"]
last_frame_url = (
content.get("last_frame_url")
metadata.get("last_frame_url")
or content.get("last_frame_url")
or platform_data.get("last_frame_url")
or inner.get("last_frame_url")
)
@@ -178,6 +206,7 @@ class SeedanceClient:
on_stage: Optional[Callable[[str], None]] = None,
on_progress: Optional[Callable[[int], None]] = None,
use_new_format: bool = False,
on_submitted: Optional[Callable[[str], None]] = None,
) -> tuple:
"""提交 → 轮询 → 下载,返回 (本地视频路径, 末帧图片URL或None)"""
connector = aiohttp.TCPConnector(ssl=False, force_close=True)
@@ -189,6 +218,8 @@ class SeedanceClient:
on_stage("submitting")
task_id = await self.submit_async(body, session, use_new_format=use_new_format)
print(f"[Seedance] 任务已提交 → {task_id}")
if on_submitted:
on_submitted(task_id)
if on_stage:
on_stage(f"submitted:{task_id}")