From c9fad58226df89cff5fe9a8948cdcd24174f0ca6 Mon Sep 17 00:00:00 2001 From: dseditor Date: Sun, 4 Jan 2026 15:28:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20PhotoMagazine=20=E7=AF=80?= =?UTF-8?q?=E9=BB=9E=EF=BC=9A=E5=8A=A0=E5=9B=9E=20features=20=E5=8F=83?= =?UTF-8?q?=E6=95=B8=20+=20DesignPrompt=20=E8=B3=87=E6=96=99=E5=A4=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 加回 features 參數(人物特徵描述) - 模板移至 DesignPrompt/ 資料夾(避免與其他 Prompt 混淆) - 更新文件說明 - 模板支援 {features} 和 {features_description} 變數 --- photo_magazine_generator.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/photo_magazine_generator.py b/photo_magazine_generator.py index d710544..e19cfb1 100644 --- a/photo_magazine_generator.py +++ b/photo_magazine_generator.py @@ -46,6 +46,7 @@ class PhotoMagazinePromptGenerator: "photo_style": ("STRING", {"default": "自然清新", "placeholder": "拍攝風格(自由輸入)"}), "custom_scene": ("STRING", {"default": "", "placeholder": "場景設定(可選)"}), "content_pages": ("INT", {"default": 8, "min": 3, "max": 30, "step": 1}), + "features": ("STRING", {"default": "", "placeholder": "人物特徵描述(例如:戴著黑框眼鏡的長髮女性)"}), } } @@ -54,11 +55,11 @@ class PhotoMagazinePromptGenerator: FUNCTION = "generate_prompt" CATEGORY = "DesignPack" - def generate_prompt(self, model_name, photo_style, custom_scene, content_pages): + def generate_prompt(self, model_name, photo_style, custom_scene, content_pages, features): """讀取模板並注入參數""" try: - # 讀取模板檔案 - template_path = os.path.join(os.path.dirname(__file__), "prompts", "photomagazine_json_output.md") + # 讀取模板檔案(從 DesignPrompt 資料夾) + template_path = os.path.join(os.path.dirname(__file__), "DesignPrompt", "photomagazine_json_output.md") if not os.path.exists(template_path): return (f"錯誤:找不到模板檔案 {template_path}",) @@ -66,16 +67,22 @@ class PhotoMagazinePromptGenerator: with open(template_path, 'r', encoding='utf-8') as f: template = f.read() + # 準備人物特徵描述 + features_description = f"人物特徵:{features}" if features else "人物特徵:根據模特兒名稱自行判斷" + # 注入參數 prompt = template.format( model_name=model_name, + features=features if features else "根據模特兒名稱自行判斷", photo_style=photo_style, custom_scene=custom_scene if custom_scene else "自動判定", - content_pages=content_pages + content_pages=content_pages, + features_description=features_description ) print("📝 提示詞生成完成") print(f" 模特兒:{model_name}") + print(f" 特徵:{features if features else '自動判定'}") print(f" 風格:{photo_style}") print(f" 場景:{custom_scene if custom_scene else '自動判定'}") print(f" 頁數:{content_pages}")