From 443915b6d6178c4f32cb11322e0d50c5c59d5952 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 14 Nov 2023 20:49:53 +0800
Subject: [PATCH 1/8] =?UTF-8?q?Update=20=E5=9B=BE=E7=89=87=E7=94=9F?=
=?UTF-8?q?=E6=88=90.py?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/图片生成.py | 62 +++++++++++++++++++++++++++++++++++--
1 file changed, 60 insertions(+), 2 deletions(-)
diff --git a/crazy_functions/图片生成.py b/crazy_functions/图片生成.py
index 4968361..8a304b4 100644
--- a/crazy_functions/图片生成.py
+++ b/crazy_functions/图片生成.py
@@ -42,6 +42,47 @@ def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2"):
return image_url, file_path+file_name
+def gen_image_dalle3(quality, llm_kwargs, prompt, resolution="1024x1024", model="dall-e-3"):
+ import requests, json, time, os
+ from request_llms.bridge_all import model_info
+
+ proxies = get_conf('proxies')
+ # Set up OpenAI API key and model
+ api_key = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model'])
+ chat_endpoint = model_info[llm_kwargs['llm_model']]['endpoint']
+ # 'https://api.openai.com/v1/chat/completions'
+ img_endpoint = chat_endpoint.replace('chat/completions','images/generations')
+ # # Generate the image
+ url = img_endpoint
+ headers = {
+ 'Authorization': f"Bearer {api_key}",
+ 'Content-Type': 'application/json'
+ }
+ data = {
+ 'prompt': prompt,
+ 'n': 1,
+ 'size': resolution,
+ 'quality': quality,
+ 'model': model,
+ 'response_format': 'url'
+ }
+ response = requests.post(url, headers=headers, json=data, proxies=proxies)
+ print(response.content)
+ try:
+ image_url = json.loads(response.content.decode('utf8'))['data'][0]['url']
+ except:
+ raise RuntimeError(response.content.decode())
+ # 文件保存到本地
+ r = requests.get(image_url, proxies=proxies)
+ file_path = f'{get_log_folder()}/image_gen/'
+ os.makedirs(file_path, exist_ok=True)
+ file_name = 'Image' + time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.png'
+ with open(file_path+file_name, 'wb+') as f: f.write(r.content)
+
+
+ return image_url, file_path+file_name
+
+
def edit_image(llm_kwargs, prompt, image_path, resolution="1024x1024", model="dall-e-2"):
import requests, json, time, os
from request_llms.bridge_all import model_info
@@ -109,13 +150,30 @@ def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys
@CatchException
-def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
+def 图片生成_DALLE3_Standard(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
history = [] # 清空历史,以免输入溢出
chatbot.append(("这是什么功能?", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文效果不理想, 请尝试英文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')
- image_url, image_path = gen_image(llm_kwargs, prompt, resolution)
+ image_url, image_path = gen_image_dalle3(standard, llm_kwargs, prompt, resolution)
+ chatbot.append([prompt,
+ f'图像中转网址:
`{image_url}`
'+
+ f'中转网址预览:

'
+ f'本地文件地址:
`{image_path}`
'+
+ f'本地文件预览:

'
+ ])
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
+
+
+@CatchException
+def 图片生成_DALLE3_HD(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
+ history = [] # 清空历史,以免输入溢出
+ chatbot.append(("这是什么功能?", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文效果不理想, 请尝试英文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')
+ image_url, image_path = gen_image_dalle3(HD, llm_kwargs, prompt, resolution)
chatbot.append([prompt,
f'图像中转网址:
`{image_url}`
'+
f'中转网址预览:

'
From 518a1b2b75e21f790135bbe0ada5370e4bc748f0 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 14 Nov 2023 20:51:49 +0800
Subject: [PATCH 2/8] Update crazy_functional.py
---
crazy_functional.py | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/crazy_functional.py b/crazy_functional.py
index 42b0151..bb7aba9 100644
--- a/crazy_functional.py
+++ b/crazy_functional.py
@@ -354,7 +354,7 @@ def get_crazy_functions():
print('Load function plugin failed')
try:
- from crazy_functions.图片生成 import 图片生成_DALLE2, 图片生成_DALLE3
+ from crazy_functions.图片生成 import 图片生成_DALLE2, 图片生成_DALLE3_Standard, 图片生成_DALLE3_HD
function_plugins.update({
"图片生成_DALLE2 (先切换模型到openai或api2d)": {
"Group": "对话",
@@ -367,13 +367,24 @@ def get_crazy_functions():
},
})
function_plugins.update({
- "图片生成_DALLE3 (先切换模型到openai或api2d)": {
+ "图片生成_DALLE3_Standard (先切换模型到openai或api2d)": {
"Group": "对话",
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
"ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792", # 高级参数输入区的显示提示
- "Info": "使用DALLE3生成图片 | 输入参数字符串,提供图像的内容",
+ "Info": "使用DALLE3 standard质量生成图片 | 输入参数字符串,提供图像的内容",
+ "Function": HotReload(图片生成_DALLE3)
+ },
+ })
+ function_plugins.update({
+ "图片生成_DALLE3_HD (先切换模型到openai或api2d)": {
+ "Group": "对话",
+ "Color": "stop",
+ "AsButton": False,
+ "AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
+ "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792", # 高级参数输入区的显示提示
+ "Info": "使用DALLE3 HD质量生成图片 | 输入参数字符串,提供图像的内容",
"Function": HotReload(图片生成_DALLE3)
},
})
From 1b28ae3baa21eb56b8a37617595aaf59142213b3 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 14 Nov 2023 21:14:41 +0800
Subject: [PATCH 3/8] Update crazy_functional.py
---
crazy_functional.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crazy_functional.py b/crazy_functional.py
index bb7aba9..7f3af84 100644
--- a/crazy_functional.py
+++ b/crazy_functional.py
@@ -354,7 +354,7 @@ def get_crazy_functions():
print('Load function plugin failed')
try:
- from crazy_functions.图片生成 import 图片生成_DALLE2, 图片生成_DALLE3_Standard, 图片生成_DALLE3_HD
+ from crazy_functions.图片生成 import 图片生成_DALLE2, 图片生成_DALLE3_Standard, 图片生成_DALLE3_HD
function_plugins.update({
"图片生成_DALLE2 (先切换模型到openai或api2d)": {
"Group": "对话",
From 5391cb4198cd9a291f4d2991921e48711d8d3a87 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 14 Nov 2023 21:17:48 +0800
Subject: [PATCH 4/8] Update crazy_functional.py
---
crazy_functional.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/crazy_functional.py b/crazy_functional.py
index 7f3af84..bdf49b7 100644
--- a/crazy_functional.py
+++ b/crazy_functional.py
@@ -374,7 +374,7 @@ def get_crazy_functions():
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
"ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792", # 高级参数输入区的显示提示
"Info": "使用DALLE3 standard质量生成图片 | 输入参数字符串,提供图像的内容",
- "Function": HotReload(图片生成_DALLE3)
+ "Function": HotReload(图片生成_DALLE3_Standard)
},
})
function_plugins.update({
@@ -385,7 +385,7 @@ def get_crazy_functions():
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
"ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792", # 高级参数输入区的显示提示
"Info": "使用DALLE3 HD质量生成图片 | 输入参数字符串,提供图像的内容",
- "Function": HotReload(图片生成_DALLE3)
+ "Function": HotReload(图片生成_DALLE3_HD)
},
})
except:
From 4d1657a53197b87827a46cf9cc57dab4d6a65086 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 14 Nov 2023 21:25:47 +0800
Subject: [PATCH 5/8] =?UTF-8?q?Update=20=E5=9B=BE=E7=89=87=E7=94=9F?=
=?UTF-8?q?=E6=88=90.py?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/图片生成.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/crazy_functions/图片生成.py b/crazy_functions/图片生成.py
index 8a304b4..e871051 100644
--- a/crazy_functions/图片生成.py
+++ b/crazy_functions/图片生成.py
@@ -156,7 +156,7 @@ def 图片生成_DALLE3_Standard(prompt, llm_kwargs, plugin_kwargs, chatbot, his
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')
- image_url, image_path = gen_image_dalle3(standard, llm_kwargs, prompt, resolution)
+ image_url, image_path = gen_image_dalle3("standard", llm_kwargs, prompt, resolution)
chatbot.append([prompt,
f'图像中转网址:
`{image_url}`
'+
f'中转网址预览:

'
@@ -173,7 +173,7 @@ def 图片生成_DALLE3_HD(prompt, llm_kwargs, plugin_kwargs, chatbot, history,
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')
- image_url, image_path = gen_image_dalle3(HD, llm_kwargs, prompt, resolution)
+ image_url, image_path = gen_image_dalle3("HD", llm_kwargs, prompt, resolution)
chatbot.append([prompt,
f'图像中转网址:
`{image_url}`
'+
f'中转网址预览:

'
From f495bb154ecbabdfc08ea051ea699c576cc4cea6 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 14 Nov 2023 21:33:00 +0800
Subject: [PATCH 6/8] =?UTF-8?q?Update=20=E5=9B=BE=E7=89=87=E7=94=9F?=
=?UTF-8?q?=E6=88=90.py?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/图片生成.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crazy_functions/图片生成.py b/crazy_functions/图片生成.py
index e871051..5c1f1b9 100644
--- a/crazy_functions/图片生成.py
+++ b/crazy_functions/图片生成.py
@@ -173,7 +173,7 @@ def 图片生成_DALLE3_HD(prompt, llm_kwargs, plugin_kwargs, chatbot, history,
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')
- image_url, image_path = gen_image_dalle3("HD", llm_kwargs, prompt, resolution)
+ image_url, image_path = gen_image_dalle3("hd", llm_kwargs, prompt, resolution)
chatbot.append([prompt,
f'图像中转网址:
`{image_url}`
'+
f'中转网址预览:

'
From 5caeb7525d11c6f10ac1950e215cf5d2ae46a582 Mon Sep 17 00:00:00 2001
From: binary-husky <96192199+binary-husky@users.noreply.github.com>
Date: Tue, 14 Nov 2023 23:15:19 +0800
Subject: [PATCH 7/8] =?UTF-8?q?Update=20=E5=9B=BE=E7=89=87=E7=94=9F?=
=?UTF-8?q?=E6=88=90.py?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/图片生成.py | 109 ++++++++++--------------------------
1 file changed, 29 insertions(+), 80 deletions(-)
diff --git a/crazy_functions/图片生成.py b/crazy_functions/图片生成.py
index 5c1f1b9..642a9e2 100644
--- a/crazy_functions/图片生成.py
+++ b/crazy_functions/图片生成.py
@@ -2,7 +2,7 @@ from toolbox import CatchException, update_ui, get_conf, select_api_key, get_log
from crazy_functions.multi_stage.multi_stage_utils import GptAcademicState
-def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2"):
+def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2", quality=None):
import requests, json, time, os
from request_llms.bridge_all import model_info
@@ -25,47 +25,7 @@ def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2"):
'model': model,
'response_format': 'url'
}
- response = requests.post(url, headers=headers, json=data, proxies=proxies)
- print(response.content)
- try:
- image_url = json.loads(response.content.decode('utf8'))['data'][0]['url']
- except:
- raise RuntimeError(response.content.decode())
- # 文件保存到本地
- r = requests.get(image_url, proxies=proxies)
- file_path = f'{get_log_folder()}/image_gen/'
- os.makedirs(file_path, exist_ok=True)
- file_name = 'Image' + time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.png'
- with open(file_path+file_name, 'wb+') as f: f.write(r.content)
-
-
- return image_url, file_path+file_name
-
-
-def gen_image_dalle3(quality, llm_kwargs, prompt, resolution="1024x1024", model="dall-e-3"):
- import requests, json, time, os
- from request_llms.bridge_all import model_info
-
- proxies = get_conf('proxies')
- # Set up OpenAI API key and model
- api_key = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model'])
- chat_endpoint = model_info[llm_kwargs['llm_model']]['endpoint']
- # 'https://api.openai.com/v1/chat/completions'
- img_endpoint = chat_endpoint.replace('chat/completions','images/generations')
- # # Generate the image
- url = img_endpoint
- headers = {
- 'Authorization': f"Bearer {api_key}",
- 'Content-Type': 'application/json'
- }
- data = {
- 'prompt': prompt,
- 'n': 1,
- 'size': resolution,
- 'quality': quality,
- 'model': model,
- 'response_format': 'url'
- }
+ if quality is not None: data.update({'quality': quality})
response = requests.post(url, headers=headers, json=data, proxies=proxies)
print(response.content)
try:
@@ -126,17 +86,17 @@ def edit_image(llm_kwargs, prompt, image_path, resolution="1024x1024", model="da
@CatchException
def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
"""
- txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
- llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
- plugin_kwargs 插件模型的参数,暂时没有用武之地
- chatbot 聊天显示框的句柄,用于显示给用户
- history 聊天历史,前情提要
+ txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
+ llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
+ plugin_kwargs 插件模型的参数,暂时没有用武之地
+ chatbot 聊天显示框的句柄,用于显示给用户
+ history 聊天历史,前情提要
system_prompt 给gpt的静默提醒
web_port 当前软件运行的端口号
"""
- history = [] # 清空历史,以免输入溢出
- chatbot.append(("这是什么功能?", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文效果不理想, 请尝试英文Prompt。正在处理中 ....."))
- yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
+ history = [] # 清空历史,以免输入溢出
+ chatbot.append(("您正在调用“图像生成”插件。", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文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')
image_url, image_path = gen_image(llm_kwargs, prompt, resolution)
@@ -146,44 +106,32 @@ def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys
f'本地文件地址:
`{image_path}`
'+
f'本地文件预览:

'
])
- yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 界面更新
@CatchException
-def 图片生成_DALLE3_Standard(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
- history = [] # 清空历史,以免输入溢出
- chatbot.append(("这是什么功能?", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文效果不理想, 请尝试英文Prompt。正在处理中 ....."))
- yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
+def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
+ history = [] # 清空历史,以免输入溢出
+ chatbot.append(("您正在调用“图像生成”插件。", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文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')
- image_url, image_path = gen_image_dalle3("standard", llm_kwargs, prompt, resolution)
+ resolution = plugin_kwargs.get("advanced_arg", '1024x1024').lower()
+ if resolution.endswith('-hd'):
+ resolution = resolution.replace('-hd', '')
+ quality = 'hd'
+ else:
+ quality = 'standard'
+ image_url, image_path = gen_image(llm_kwargs, prompt, resolution, model="dall-e-3", quality=quality)
chatbot.append([prompt,
f'图像中转网址:
`{image_url}`
'+
f'中转网址预览:

'
f'本地文件地址:
`{image_path}`
'+
f'本地文件预览:

'
])
- yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
-
-
-@CatchException
-def 图片生成_DALLE3_HD(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
- history = [] # 清空历史,以免输入溢出
- chatbot.append(("这是什么功能?", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文效果不理想, 请尝试英文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')
- image_url, image_path = gen_image_dalle3("hd", llm_kwargs, prompt, resolution)
- chatbot.append([prompt,
- f'图像中转网址:
`{image_url}`
'+
- f'中转网址预览:

'
- f'本地文件地址:
`{image_path}`
'+
- f'本地文件预览:

'
- ])
- yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
-
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 界面更新
class ImageEditState(GptAcademicState):
+ # 尚未完成
def get_image_file(self, x):
import os, glob
if len(x) == 0: return False, None
@@ -204,8 +152,8 @@ class ImageEditState(GptAcademicState):
def reset(self):
self.req = [
{'value':None, 'description': '请先上传图像(必须是.png格式), 然后再次点击本插件', 'verify_fn': self.get_image_file},
- {'value':None, 'description': '请输入分辨率,可选:256x256, 512x512 或 1024x1024', 'verify_fn': self.get_resolution},
- {'value':None, 'description': '请输入修改需求,建议您使用英文提示词', 'verify_fn': self.get_prompt},
+ {'value':None, 'description': '请输入分辨率,可选:256x256, 512x512 或 1024x1024', 'verify_fn': self.get_resolution},
+ {'value':None, 'description': '请输入修改需求,建议您使用英文提示词', 'verify_fn': self.get_prompt},
]
self.info = ""
@@ -230,11 +178,12 @@ class ImageEditState(GptAcademicState):
@CatchException
def 图片修改_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
+ # 尚未完成
history = [] # 清空历史
state = ImageEditState.get_state(chatbot, ImageEditState)
state = state.feed(prompt, chatbot)
if not state.already_obtained_all_materials():
- chatbot.append(["图片修改(先上传图片,再输入修改需求,最后输入分辨率)", state.next_req()])
+ chatbot.append(["图片修改(先上传图片,再输入修改需求,最后输入分辨率)", state.next_req()])
yield from update_ui(chatbot=chatbot, history=history)
return
@@ -251,5 +200,5 @@ def 图片修改_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys
f'本地文件地址:
`{image_path}`
'+
f'本地文件预览:

'
])
- yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 界面更新
From e7c662a5d66d58150b56fb36abc6a513e44cd27e Mon Sep 17 00:00:00 2001
From: binary-husky <96192199+binary-husky@users.noreply.github.com>
Date: Tue, 14 Nov 2023 23:16:49 +0800
Subject: [PATCH 8/8] Update crazy_functional.py
---
crazy_functional.py | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/crazy_functional.py b/crazy_functional.py
index bdf49b7..3d4df71 100644
--- a/crazy_functional.py
+++ b/crazy_functional.py
@@ -354,7 +354,7 @@ def get_crazy_functions():
print('Load function plugin failed')
try:
- from crazy_functions.图片生成 import 图片生成_DALLE2, 图片生成_DALLE3_Standard, 图片生成_DALLE3_HD
+ from crazy_functions.图片生成 import 图片生成_DALLE2, 图片生成_DALLE3
function_plugins.update({
"图片生成_DALLE2 (先切换模型到openai或api2d)": {
"Group": "对话",
@@ -367,25 +367,14 @@ def get_crazy_functions():
},
})
function_plugins.update({
- "图片生成_DALLE3_Standard (先切换模型到openai或api2d)": {
+ "图片生成_DALLE3 (先切换模型到openai或api2d)": {
"Group": "对话",
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
- "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792", # 高级参数输入区的显示提示
- "Info": "使用DALLE3 standard质量生成图片 | 输入参数字符串,提供图像的内容",
- "Function": HotReload(图片生成_DALLE3_Standard)
- },
- })
- function_plugins.update({
- "图片生成_DALLE3_HD (先切换模型到openai或api2d)": {
- "Group": "对话",
- "Color": "stop",
- "AsButton": False,
- "AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
- "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792", # 高级参数输入区的显示提示
- "Info": "使用DALLE3 HD质量生成图片 | 输入参数字符串,提供图像的内容",
- "Function": HotReload(图片生成_DALLE3_HD)
+ "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792。如需生成高清图像,请输入 1024x1024-HD, 1792x1024-HD, 1024x1792-HD。", # 高级参数输入区的显示提示
+ "Info": "使用DALLE3生成图片 | 输入参数字符串,提供图像的内容",
+ "Function": HotReload(图片生成_DALLE3)
},
})
except: