存量积累:生图素人感约束+评图分+幂等防重跑+审核回路
- 015-017迁移:image_candidate 文案复审/AI视觉分/重生标记 - constants C7素人感约束(反电商摆拍对齐真实笔记)+C3叠字口子 - celery visibility_timeout=2h 防长任务被误判重投重复烧钱(task75教训) - image_scorer 评图分(只筛选+展示,真实信号才进飞轮权重) - storyboard/image_gen/pipeline_io 生图存量 - task_actions/tasks/task_service/flywheel 审核回路+飞轮存量 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -95,22 +95,38 @@ def import_text(
|
||||
return ok(_fmt_text(tc))
|
||||
|
||||
|
||||
class RegenerateRequest(BaseModel):
|
||||
"""R2 重生参数(全 None=整体重生,兼容旧调用)。
|
||||
strategy='A'/'B'/'C' 指定单套;role 指定单张(需配 strategy);custom_prompt 人工追加提示词。"""
|
||||
strategy: str | None = Field(default=None, pattern="^[ABC]$")
|
||||
role: str | None = None
|
||||
custom_prompt: str | None = Field(default=None, max_length=500)
|
||||
|
||||
|
||||
@router.post("/{task_id}/regenerate")
|
||||
def regenerate(
|
||||
task_id: int,
|
||||
body: RegenerateRequest | None = None,
|
||||
current_user: Annotated[CurrentUser, Depends(require_write_permission)] = None,
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""重新生成(飞轮信号 regenerate -1)。"""
|
||||
"""重新生成(飞轮信号 regenerate -1)。
|
||||
body 全空=整体重生;带 strategy=单套重生;带 strategy+role=单张重生;custom_prompt=人工提示词。"""
|
||||
from app.services.flywheel_service import record_signal
|
||||
from app.services.task_service import enqueue_generation
|
||||
task = _check_task_ownership(
|
||||
db.query(GenerationTask).filter(GenerationTask.id == task_id).first(),
|
||||
current_user.workspace_id,
|
||||
)
|
||||
body = body or RegenerateRequest()
|
||||
# role 必须配 strategy(单张重生需知道是哪套的哪张)
|
||||
if body.role and not body.strategy:
|
||||
raise_state_invalid("指定单张重生(role)时必须同时指定 strategy(套别)")
|
||||
record_signal(db, current_user, task, "regenerate")
|
||||
enqueue_generation(task.id)
|
||||
return ok({"task_id": task_id, "status": "regenerating"})
|
||||
enqueue_generation(task.id, regen_strategy=body.strategy,
|
||||
regen_role=body.role, custom_prompt=body.custom_prompt)
|
||||
scope = "单张" if body.role else ("单套" if body.strategy else "整体")
|
||||
return ok({"task_id": task_id, "status": "regenerating", "scope": scope})
|
||||
|
||||
|
||||
@router.post("/{task_id}/submit-review")
|
||||
|
||||
@@ -60,6 +60,10 @@ def _fmt_task(t: GenerationTask) -> dict:
|
||||
"id": t.id, "product_id": t.product_id, "theme": t.theme,
|
||||
"status": t.status, "text_count": t.text_count, "image_count": t.image_count,
|
||||
"track": t.track, "need_product_image": t.need_product_image,
|
||||
# 审核回路:打回原因+审核状态,任务页/历史页展示"为何被打回"(R4-b死链修复,R8历史复用)
|
||||
"review_status": t.review_status,
|
||||
"reject_reason": t.reject_reason,
|
||||
"reviewed_at": t.reviewed_at.isoformat() if t.reviewed_at else None,
|
||||
"created_at": t.created_at.isoformat(),
|
||||
}
|
||||
|
||||
@@ -129,6 +133,7 @@ def _fmt_text(tc: TextCandidate) -> dict:
|
||||
# AI 评委总评(verdict/summary 存在 content 列,新数据有,旧数据为空字符串降级)
|
||||
"verdict": parsed.get("verdict", ""), # "优秀"|"合格"|"不合格"
|
||||
"summary": parsed.get("summary", ""), # 一句话总评含改进点
|
||||
"edited": tc.edited, # D1 改稿标记(飞轮最强信号)
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +141,9 @@ def _fmt_image(ic: ImageCandidate) -> dict:
|
||||
return {
|
||||
"candidate_id": ic.id, "role": ic.role, "url": ic.url,
|
||||
"strategy": ic.strategy, "seq": ic.seq, "is_selected": ic.is_selected,
|
||||
"is_regen": getattr(ic, "is_regen", False), # R2 重生标记(前端同strategy+role去重展示最新)
|
||||
# E12 AI评图分:纯展示+排序,绝不进飞轮权重(eval_score 另留 NULL)
|
||||
"ai_visual_score": ic.ai_visual_score, "ai_visual_note": ic.ai_visual_note,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user