From 1bd3637d32f8439a4fb76394fb95e8f61932b624 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Mon, 25 Dec 2023 22:24:12 +0800 Subject: [PATCH] modify image gen plugin user interaction --- crazy_functional.py | 8 ++++---- crazy_functions/图片生成.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crazy_functional.py b/crazy_functional.py index 4cc6304..c323dc3 100644 --- a/crazy_functional.py +++ b/crazy_functional.py @@ -345,7 +345,7 @@ def get_crazy_functions(): "Color": "stop", "AsButton": False, "AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False) - "ArgsReminder": "支持任意数量的llm接口,用&符号分隔。例如chatglm&gpt-3.5-turbo&api2d-gpt-4", # 高级参数输入区的显示提示 + "ArgsReminder": "支持任意数量的llm接口,用&符号分隔。例如chatglm&gpt-3.5-turbo&gpt-4", # 高级参数输入区的显示提示 "Function": HotReload(同时问询_指定模型) }, }) @@ -356,7 +356,7 @@ def get_crazy_functions(): try: from crazy_functions.图片生成 import 图片生成_DALLE2, 图片生成_DALLE3, 图片修改_DALLE2 function_plugins.update({ - "图片生成_DALLE2 (先切换模型到openai或api2d)": { + "图片生成_DALLE2 (先切换模型到gpt-*)": { "Group": "对话", "Color": "stop", "AsButton": False, @@ -367,7 +367,7 @@ def get_crazy_functions(): }, }) function_plugins.update({ - "图片生成_DALLE3 (先切换模型到openai或api2d)": { + "图片生成_DALLE3 (先切换模型到gpt-*)": { "Group": "对话", "Color": "stop", "AsButton": False, @@ -378,7 +378,7 @@ def get_crazy_functions(): }, }) function_plugins.update({ - "图片修改_DALLE2 (先切换模型到openai或api2d)": { + "图片修改_DALLE2 (先切换模型到gpt-*)": { "Group": "对话", "Color": "stop", "AsButton": False, diff --git a/crazy_functions/图片生成.py b/crazy_functions/图片生成.py index f32d136..9751e16 100644 --- a/crazy_functions/图片生成.py +++ b/crazy_functions/图片生成.py @@ -104,7 +104,11 @@ def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys web_port 当前软件运行的端口号 """ history = [] # 清空历史,以免输入溢出 - chatbot.append(("您正在调用“图像生成”插件。", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文Prompt效果不理想, 请尝试英文Prompt。正在处理中 .....")) + if prompt.strip() == "": + chatbot.append((prompt, "[Local Message] 图像生成提示为空白,请在“输入区”输入图像生成提示。")) + yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 界面更新 + return + chatbot.append(("您正在调用“图像生成”插件。", "[Local Message] 生成图像, 请先把模型切换至gpt-*。如果中文Prompt效果不理想, 请尝试英文Prompt。正在处理中 .....")) yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 由于请求gpt需要一段时间,我们先及时地做一次界面更新 if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg") resolution = plugin_kwargs.get("advanced_arg", '1024x1024') @@ -121,7 +125,11 @@ def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys @CatchException def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): history = [] # 清空历史,以免输入溢出 - chatbot.append(("您正在调用“图像生成”插件。", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文Prompt效果不理想, 请尝试英文Prompt。正在处理中 .....")) + if prompt.strip() == "": + chatbot.append((prompt, "[Local Message] 图像生成提示为空白,请在“输入区”输入图像生成提示。")) + yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 界面更新 + return + chatbot.append(("您正在调用“图像生成”插件。", "[Local Message] 生成图像, 请先把模型切换至gpt-*。如果中文Prompt效果不理想, 请尝试英文Prompt。正在处理中 .....")) yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 由于请求gpt需要一段时间,我们先及时地做一次界面更新 if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg") resolution_arg = plugin_kwargs.get("advanced_arg", '1024x1024-standard-vivid').lower()