fix: harden outbound leak guard and title naming

This commit is contained in:
2026-03-09 14:34:04 +08:00
parent d3b55798e5
commit a2119f3b6d
3 changed files with 104 additions and 5 deletions

View File

@@ -77,6 +77,22 @@ def _build_processing_prompt(intent: str, requirement_text: str, analysis: Dict)
return f"根据客户需求“{req or '找原图'}”,严格参考原图元素与构图,生成完整干净的高质量素材图。"
def _build_upload_title(intent: str, analysis: Dict, requirement_text: str, idx: int) -> str:
analysis = analysis or {}
subject = _safe_name(str(analysis.get("subject") or ""), "")
proc_type = _safe_name(str(analysis.get("proc_type") or ""), "")
requirement = _safe_name(str(requirement_text or ""), "")
action = "修复" if intent == "repair" else "原图"
parts = [part for part in (subject, proc_type, requirement) if part]
if parts:
base = "_".join(parts[:2])
else:
base = "图片识别结果"
return f"{base}_{action}_{idx}"
class AutoImagePipelineService:
def __init__(self):
self.customer_db = CustomerDatabase()
@@ -244,7 +260,7 @@ class AutoImagePipelineService:
digest = hashlib.md5(f"{customer_id}|{acc_id}|{image_url}".encode("utf-8")).hexdigest()[:10]
input_path = pipeline_root / f"{digest}_src{_suffix_from_url(image_url)}"
output_path = pipeline_root / f"{digest}_out.png"
title = f"{_safe_name(customer_id, '客户')}_{'修复' if intent == 'repair' else '原图'}_{idx}"
title = _build_upload_title(intent, analysis, requirement_text, idx)
prompt = _build_processing_prompt(intent, requirement_text, analysis)
task_id = task_db.add_task(
customer_id=customer_id,