This commit is contained in:
zcr
2026-06-17 11:57:45 +08:00
parent b9163f0b46
commit 44cd88e8af

View File

@@ -51,15 +51,15 @@ def generate_sketch_prompt_node(state: SketchState) -> dict:
structured_llm = qwen_plus_llm.with_structured_output(SketchPrompt)
messages = [
SystemMessage(content=f"""你是一个专业的服装设计师
请根据用户输入生成用于AI图像生成的服装草图提示词
SystemMessage(content=f"""你是一个专业的服装设计师.
请根据用户输入,生成用于AI图像生成的服装草图提示词.
要求
1. 提示词必须包含clean black and white line drawing only, pure white background, centered composition
2. 提示词应该详细描述服装的廓形结构细节
要求:
1. 提示词必须包含:clean black and white line drawing only, pure white background, centered composition
2. 提示词应该详细描述服装的廓形,结构,细节
3. 提示词应该适合用于 Stable Diffusion 图像生成模型
4. 提示词应该使用英文因为图像生成模型对英文理解更好
5. 草图风格必须是黑白线稿不要添加颜色
4. 提示词应该使用英文,因为图像生成模型对英文理解更好
5. 草图风格必须是黑白线稿,不要添加颜色
6. 提示词数量为 {state.get("sketch_num", 1)}
"""),
HumanMessage(content=state["input_text"]),
@@ -77,8 +77,8 @@ def generate_sketch_prompt_node(state: SketchState) -> dict:
async def generate_sketch_img_node(state: SketchState) -> dict:
"""根据生成的提示词生成服装草图"""
# 如果 sketch_need_prompt_generation=False 且 sketch_prompts 为空使用模板生成 prompt
"""根据生成的提示词,生成服装草图"""
# 如果 sketch_need_prompt_generation=False 且 sketch_prompts 为空,使用模板生成 prompt
if not state.get("sketch_need_prompt_generation", False) and not state.get("sketch_prompts"):
input_text = state.get("input_text", "")
prompts = [build_sketch_template_prompt(input_text)]
@@ -99,7 +99,7 @@ async def generate_sketch_img_node(state: SketchState) -> dict:
def should_generate_prompt(state: SketchState) -> str:
"""条件分支判断是否需要生成 prompt"""
"""条件分支:判断是否需要生成 prompt"""
if state.get("sketch_need_prompt_generation", False):
return "gen_prompt"
else:
@@ -137,7 +137,7 @@ def build_sketch_template_prompt(input_text: str) -> str:
async def main(test_input, sketch_need_prompt_generation=False):
graph = build_sketch_graph()
# 如果不需要 LLM 生成 prompt使用模板
# 如果不需要 LLM 生成 prompt,使用模板
if not sketch_need_prompt_generation:
sketch_prompts = [build_sketch_template_prompt(test_input)]
else:
@@ -157,14 +157,14 @@ async def main(test_input, sketch_need_prompt_generation=False):
if __name__ == "__main__":
# 测试示例 1: 直接使用模板 prompt默认
# 测试示例 1: 直接使用模板 prompt(默认)
test_input = "dress"
result = asyncio.run(main(test_input, sketch_need_prompt_generation=False))
print("=== 使用模板 prompt ===")
print(f"Result: {result}")
# # 测试示例 2: 使用 LLM 生成 prompt
# test_input = "设计一条优雅的A字廓形连衣裙V领设计收腰裙摆到膝盖适合日常穿着"
# test_input = "设计一条优雅的A字廓形连衣裙,V领设计,收腰,裙摆到膝盖,适合日常穿着"
# result = asyncio.run(main(test_input, sketch_need_prompt_generation=True))
# print("\n=== 使用 LLM 生成 prompt ===")
# print(f"Result: {result}")