修复高级参数bug
This commit is contained in:
@ -253,7 +253,7 @@ class ChatBot(ChatBotFrame):
|
||||
# 注册input
|
||||
self.input_combo = [self.cookies, self.max_length_sl, self.md_dropdown,
|
||||
self.txt, self.top_p, self.temperature, self.chatbot, self.history,
|
||||
self.system_prompt, self.models_box]
|
||||
self.system_prompt, self.models_box, self.plugin_advanced_arg]
|
||||
self.output_combo = [self.cookies, self.chatbot, self.history, self.status, self.txt]
|
||||
self.predict_args = dict(fn=ArgsGeneralWrapper(predict), inputs=self.input_combo, outputs=self.output_combo)
|
||||
# 提交按钮、重置按钮
|
||||
@ -302,7 +302,7 @@ class ChatBot(ChatBotFrame):
|
||||
def route(k, ipaddr: gr.Request, *args, **kwargs):
|
||||
if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
|
||||
append = list(args)
|
||||
append.insert(10, ipaddr)
|
||||
append.insert(-1, ipaddr)
|
||||
args = tuple(append)
|
||||
yield from ArgsGeneralWrapper(crazy_fns[k]["Function"])(*args, **kwargs)
|
||||
|
||||
|
||||
@ -254,7 +254,7 @@ def get_crazy_functions():
|
||||
"Color": "stop",
|
||||
"AsButton": True,
|
||||
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
|
||||
"ArgsReminder": "在这里输入分辨率, 如256x256(默认)", # 高级参数输入区的显示提示
|
||||
"ArgsReminder": "在这里输入分辨率, 如'256x256'(默认), '512x512', '1024x1024'", # 高级参数输入区的显示提示
|
||||
"Function": HotReload(图片生成)
|
||||
},
|
||||
})
|
||||
|
||||
@ -28,19 +28,18 @@ def gen_image(llm_kwargs, prompt, resolution="256x256"):
|
||||
response = requests.post(url, headers=headers, json=data, proxies=proxies)
|
||||
print(response.content)
|
||||
image_url = json.loads(response.content.decode('utf8'))['data'][0]['url']
|
||||
|
||||
# 文件保存到本地
|
||||
r = requests.get(image_url, proxies=proxies)
|
||||
file_path = 'gpt_log/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)
|
||||
|
||||
|
||||
with open(file_path + file_name, 'wb+') as f:
|
||||
f.write(r.content)
|
||||
return image_url, file_path + file_name
|
||||
|
||||
|
||||
|
||||
|
||||
@CatchException
|
||||
def 图片生成(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||
"""
|
||||
|
||||
@ -261,7 +261,7 @@
|
||||
"例如chatglm&gpt-3.5-turbo&api2d-gpt-4": "e.g. chatglm&gpt-3.5-turbo&api2d-gpt-4",
|
||||
"先切换模型到openai或api2d": "Switch the model to openai or api2d first",
|
||||
"在这里输入分辨率": "Enter the resolution here",
|
||||
"如256x256": "e.g. 256x256",
|
||||
"如'256x256', '512x512', '1024x1024'": "e.g. '256x256', '512x512', '1024x1024'",
|
||||
"默认": "Default",
|
||||
"建议您复制一个config_private.py放自己的秘密": "We suggest you to copy a config_private.py file to keep your secrets, such as API and proxy URLs, from being accidentally uploaded to Github and seen by others.",
|
||||
"如API和代理网址": "Such as API and proxy URLs",
|
||||
|
||||
@ -50,7 +50,7 @@ def ArgsGeneralWrapper(f):
|
||||
装饰器函数,用于重组输入参数,改变输入参数的顺序与结构。
|
||||
"""
|
||||
def decorated(cookies, max_length, llm_model, txt, top_p, temperature,
|
||||
chatbot, history, system_prompt, models, ipaddr: gr.Request, *args):
|
||||
chatbot, history, system_prompt, models, plugin_advanced_arg, ipaddr: gr.Request, *args):
|
||||
""""""
|
||||
# 引入一个有cookie的chatbot
|
||||
cookies.update({
|
||||
@ -66,7 +66,7 @@ def ArgsGeneralWrapper(f):
|
||||
'ipaddr': ipaddr.client.host
|
||||
}
|
||||
plugin_kwargs = {
|
||||
# "advanced_arg": plugin_advanced_arg, 意义不明的功能,后续再解决冲突
|
||||
"advanced_arg": plugin_advanced_arg
|
||||
}
|
||||
encrypt, private = get_conf('switch_model')[0]['key']
|
||||
private_key = get_conf('private_key')[0]
|
||||
|
||||
Reference in New Issue
Block a user