feat: integrate quality-gated draw flow with online dispatch transfer
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
This commit is contained in:
@@ -28,6 +28,7 @@ async def auto_draw_preview(
|
||||
logger.info("[作图] 开始 customer=%s image=%s", customer_id, image_url)
|
||||
from services.service_gemini_stable import GeminiExtractStableService # type: ignore
|
||||
from services.service_tuhui_upload import upload_to_tuhui # type: ignore
|
||||
from .image_quote_analyzer import analyze_image_for_quote, evaluate_generated_image
|
||||
except Exception as e:
|
||||
logger.error("[作图] 依赖加载失败: %s", e)
|
||||
return {"ok": False, "error": f"依赖加载失败:{e}"}
|
||||
@@ -37,6 +38,25 @@ async def auto_draw_preview(
|
||||
output_path = os.path.join(tempfile.gettempdir(), f"qjcs_out_{uuid.uuid4().hex}.jpg")
|
||||
|
||||
try:
|
||||
logger.info("[作图] 识图评估中")
|
||||
analysis = await analyze_image_for_quote(
|
||||
image_url=image_url,
|
||||
customer_text=requirement,
|
||||
goods_name="",
|
||||
)
|
||||
if analysis.get("ok"):
|
||||
business_related = str(analysis.get("business_related", "yes")).lower()
|
||||
can_do = str(analysis.get("can_do", "partial")).lower()
|
||||
if business_related == "no":
|
||||
logger.info("[作图] 终止: 非印花/印刷相关")
|
||||
return {"ok": False, "error": "非印花/印刷相关,退出"}
|
||||
if can_do == "no":
|
||||
logger.info("[作图] 终止: 识图判定不可做")
|
||||
return {"ok": False, "error": "识图判定不可做,退出"}
|
||||
if str(analysis.get("gemini_prompt", "")).strip():
|
||||
prompt = str(analysis.get("gemini_prompt", "")).strip()
|
||||
logger.info("[作图] 使用识图提示词: %s", prompt[:80])
|
||||
|
||||
logger.info("[作图] 下载原图中")
|
||||
headers = {
|
||||
"User-Agent": (
|
||||
@@ -71,6 +91,20 @@ async def auto_draw_preview(
|
||||
return {"ok": False, "error": "生成失败:未产出文件"}
|
||||
logger.info("[作图] Gemini 生成完成")
|
||||
|
||||
logger.info("[作图] 结果评估中")
|
||||
review = await evaluate_generated_image(
|
||||
original_image_url=image_url,
|
||||
generated_image_path=output_path,
|
||||
requirement=requirement,
|
||||
)
|
||||
if not review.get("pass", False):
|
||||
logger.info("[作图] 终止: 评估不通过 reason=%s", review.get("reason", ""))
|
||||
return {
|
||||
"ok": False,
|
||||
"need_transfer": True,
|
||||
"error": f"评估不通过:{review.get('reason', 'unknown')}",
|
||||
}
|
||||
|
||||
logger.info("[作图] 上传图绘中")
|
||||
ok_upload, link, _ = await upload_to_tuhui(
|
||||
output_path,
|
||||
|
||||
Reference in New Issue
Block a user