A8多套打包+M4归档+R5多图:存量功能备份
A8 多套交付包(packaging_task.py): - 修复交付包只打第1条混乱note的bug,按ImageCandidate.strategy分A/B/C组 - 每组生独立note_0N夹(6图+文案.txt),同seq留最新去重,老数据兼容 - task74端到端验:3套各6图,独立agent7项交叉验证全过 M4 归档(tasks.py/exports.py/前端): - list_tasks加date_from/date_to/product_id筛选+product_name批量填(防N+1) - 新增exports.py:产品JSON导出+标杆CSV导出(UTF-8 BOM) - 前端HistoryFilters日期/产品筛选+产品列+打回原因红banner - response.py加raise_param_error;独立agent验A1/A2/A9通过 R5 产品多图(product_images.py/020迁移/前端): - product_images表+5端点(上传/列/改场景/设主图/删图) - 生图按ROLE_SCENE_PREFERENCE选对应场景图,回落primary - 前端ProductImageManager多图画廊 R6 账号config拆页(settings/): - 配置页按角色拆/settings(运营+组长+admin)+/config(仅admin) - Key只显末4位不显余额(守红线) 核销表对齐真实代码状态:D1改稿框/M7裂变/E12评图分纠偏为已完成(曾漏回写) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,13 +14,36 @@ import logging
|
||||
import os
|
||||
from typing import Any, Protocol
|
||||
|
||||
from .constants import IMAGE_RETRY_ATTEMPTS, IMAGE_RETRY_BACKOFF_BASE, IMAGE_SIZE_DEFAULT
|
||||
from .constants import IMAGE_RETRY_ATTEMPTS, IMAGE_RETRY_BACKOFF_BASE, IMAGE_SIZE_DEFAULT, ROLE_SCENE_PREFERENCE
|
||||
from .image_scorer import score_image
|
||||
from .storyboard import plan_image_set, sanitize_text
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _pick_reference_for_role(
|
||||
role: str,
|
||||
images_by_scene: dict[str, list[bytes]] | None,
|
||||
fallback: list[bytes] | None,
|
||||
) -> tuple[list[bytes] | None, str]:
|
||||
"""R5多图:按分镜 role 选该场景的产品图。取不到回落主图。
|
||||
|
||||
返回 (参考图bytes列表, 命中scene标签用于日志)。
|
||||
"""
|
||||
if images_by_scene:
|
||||
for scene in ROLE_SCENE_PREFERENCE.get(role, ["primary"]):
|
||||
imgs = images_by_scene.get(scene)
|
||||
if imgs:
|
||||
return imgs, scene
|
||||
# 偏好全落空:用任意可用图兜底(仍优先 primary)
|
||||
if images_by_scene.get("primary"):
|
||||
return images_by_scene["primary"], "primary"
|
||||
for scene, imgs in images_by_scene.items():
|
||||
if imgs:
|
||||
return imgs, f"{scene}(兜底)"
|
||||
return fallback, "fallback"
|
||||
|
||||
|
||||
class ImageClient(Protocol):
|
||||
"""worker 注入的图片生成客户端协议(隔离 key 细节)"""
|
||||
async def gpt_edits(
|
||||
@@ -129,12 +152,18 @@ async def generate_storyboard_images(
|
||||
strategy: str | None = None,
|
||||
target_role: str | None = None,
|
||||
custom_prompt: str | None = None,
|
||||
images_by_scene: dict[str, list[bytes]] | None = None,
|
||||
flywheel_fragment: str | None = None,
|
||||
) -> list[dict]:
|
||||
"""
|
||||
按 storyboard 逐张生图(asyncio.gather 并发),返回每张结果列表。
|
||||
strategy: None=默认叙事,'A'/'B'/'C'=三套正交叙事策略
|
||||
target_role: 非空时只生成该 role 那一张(R2 单张重生)
|
||||
custom_prompt: 非空时追加到每张 per_prompt 末尾(R2 人工提示词)
|
||||
images_by_scene: R5多图,{scene: [bytes]},按分镜 role 选对应场景图;
|
||||
为空则全分镜共用 reference_images(向后兼容)。
|
||||
flywheel_fragment: R7 飞轮偏好片段(最近选图/打回真实信号聚合),注入图片
|
||||
排版偏好;仅影响文字角度/版式取向,绝不改瓶身(合规红线)。
|
||||
每项:{role, name, image_bytes, error}
|
||||
"""
|
||||
plan = plan_image_set(note, product, image_count, analysis, strategy=strategy)
|
||||
@@ -169,8 +198,20 @@ async def generate_storyboard_images(
|
||||
# R2 人工提示词:追加到末尾权重最高,但不覆盖前面合规/真实约束
|
||||
if custom_prompt:
|
||||
per_prompt += f"\n运营补充要求(在不违反上述合规与真实约束前提下尽量满足):{sanitize_text(custom_prompt, 200)}。"
|
||||
# R7 飞轮偏好:仅作用于文字角度/版式取向参考,绝不改瓶身(合规+真实红线)
|
||||
if flywheel_fragment:
|
||||
per_prompt += (
|
||||
f"\n历史偏好参考(仅影响标题文字角度与排版取向,不得据此改动产品瓶身):"
|
||||
f"{sanitize_text(flywheel_fragment, 300)}。"
|
||||
)
|
||||
try:
|
||||
img_bytes = await generate_one_image(client, per_prompt, reference_images)
|
||||
# R5多图:按本张分镜 role 选对应场景产品图;无多图则共用 reference_images
|
||||
ref_for_item, _scene_hit = _pick_reference_for_role(
|
||||
item["role"], images_by_scene, reference_images
|
||||
)
|
||||
if images_by_scene:
|
||||
logger.info("分镜 %s 选用产品图场景=%s", item["role"], _scene_hit)
|
||||
img_bytes = await generate_one_image(client, per_prompt, ref_for_item)
|
||||
# 注:gpt-image-2 渲染中文偶发错别字(约1/6)。vision/OCR 文字校验闸门实测
|
||||
# 不可靠(漏报形近字+幻觉误伤品牌词),倩倩姐2026-06-16拍板先撤,纯生图,
|
||||
# 错别字作已知问题记录,后续迭代再处理。详见记忆 clover-image-text-check-shelved。
|
||||
|
||||
Reference in New Issue
Block a user