更新图形生成工具,优化返回格式并添加新功能
This commit is contained in:
@@ -79,21 +79,19 @@ 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
|
||||
# if not state.get("sketch_need_prompt_generation", False) and not state.get("sketch_prompts"):
|
||||
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)]
|
||||
# else:
|
||||
# prompts = state["sketch_prompts"] if state["sketch_prompts"] else [state["input_text"]]
|
||||
input_text = state.get("input_text", "")
|
||||
prompts = [build_sketch_template_prompt(input_text)]
|
||||
else:
|
||||
prompts = state["sketch_prompts"] if state["sketch_prompts"] else [state["input_text"]]
|
||||
|
||||
# sketch_img_urls = []
|
||||
# for prompt in prompts:
|
||||
# image_url = await generate_sketch_tool.ainvoke({"prompt": prompt})
|
||||
# sketch_img_urls.append(image_url)
|
||||
sketch_img_urls = []
|
||||
for prompt in prompts:
|
||||
image_url = await generate_sketch_tool.ainvoke({"prompt": prompt})
|
||||
sketch_img_urls.append(image_url)
|
||||
|
||||
# result_text = f"服装草图生成完成,共生成 {len(sketch_img_urls)} 张图片:\n" + "\n".join(sketch_img_urls)
|
||||
# return {"sketch_img_urls": sketch_img_urls, "messages": [AIMessage(content=result_text)]}
|
||||
return {"messages": [AIMessage(content="hello")]}
|
||||
return {"sketch_img_urls": sketch_img_urls}
|
||||
|
||||
|
||||
"""条件分支 判断是否需要生成 prompt"""
|
||||
|
||||
@@ -20,7 +20,7 @@ async def generate_sketch_tool(prompt: str) -> str:
|
||||
bucket_name = "fida-public-bucket"
|
||||
object_name = f"test/{uuid7()}.png"
|
||||
image_url = await generate_image(prompt=prompt, bucket_name=bucket_name, object_name=object_name)
|
||||
return image_url
|
||||
return [image_url]
|
||||
|
||||
|
||||
async def run_test():
|
||||
|
||||
Reference in New Issue
Block a user