修复下拉插件和普通问答的bug

This commit is contained in:
w_xiaolizu
2023-05-15 13:34:49 +08:00
parent 7f64f2a00f
commit 7e07ccf040
5 changed files with 10 additions and 10 deletions

View File

@ -191,7 +191,7 @@ class ChatBot(ChatBotFrame):
not crazy_fns[k].get("AsButton", True)] not crazy_fns[k].get("AsButton", True)]
self.dropdown = gr.Dropdown(dropdown_fn_list, value=r"打开插件列表", label="").style( self.dropdown = gr.Dropdown(dropdown_fn_list, value=r"打开插件列表", label="").style(
container=False) container=False)
self.plugin_advanced_arg = gr.Textbox(show_label=False, label="高级参数输入区", visible=True, self.plugin_advanced_arg = gr.Textbox(show_label=True, label="高级参数输入区", visible=False,
placeholder="这里是特殊函数插件的高级参数输入区").style( placeholder="这里是特殊函数插件的高级参数输入区").style(
container=False) container=False)
self.switchy_bt = gr.Button(r"请先从插件列表中选择", variant="secondary") self.switchy_bt = gr.Button(r"请先从插件列表中选择", variant="secondary")
@ -297,9 +297,12 @@ class ChatBot(ChatBotFrame):
# 随变按钮的回调函数注册 # 随变按钮的回调函数注册
def route(k, ipaddr: gr.Request, *args, **kwargs): def route(k, ipaddr: gr.Request, *args, **kwargs):
if k in [r"打开插件列表", r"请先从插件列表中选择"]: return if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
yield from ArgsGeneralWrapper(crazy_fns[k]["Function"])(ipaddr=ipaddr, *args, **kwargs) append = list(args)
append.insert(10, ipaddr)
args = tuple(append)
yield from ArgsGeneralWrapper(crazy_fns[k]["Function"])(*args, **kwargs)
self.click_handle = self.switchy_bt.click(route, [self.switchy_bt, *self.input_combo], self.output_combo) self.click_handle = self.switchy_bt.click(route, [self.switchy_bt, *self.input_combo, gr.State(PORT)], self.output_combo)
self.click_handle.then(on_report_generated, [self.file_upload, self.chatbot], [self.file_upload, self.chatbot]) self.click_handle.then(on_report_generated, [self.file_upload, self.chatbot], [self.file_upload, self.chatbot])
self.cancel_handles.append(self.click_handle) self.cancel_handles.append(self.click_handle)
# 终止按钮的回调函数注册 # 终止按钮的回调函数注册

View File

@ -56,6 +56,7 @@ def get_crazy_functions():
"ArgsReminder": "若输入0则不解析notebook中的Markdown块", # 高级参数输入区的显示提示 "ArgsReminder": "若输入0则不解析notebook中的Markdown块", # 高级参数输入区的显示提示
}, },
"批量总结Word文档": { "批量总结Word文档": {
"AsButton": False,
"Color": "stop", "Color": "stop",
"Function": HotReload(总结word文档) "Function": HotReload(总结word文档)
}, },
@ -102,6 +103,7 @@ def get_crazy_functions():
"Markdown/Readme英译中": { "Markdown/Readme英译中": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Color": "stop", "Color": "stop",
"AsButton": False,
"Function": HotReload(Markdown英译中) "Function": HotReload(Markdown英译中)
}, },
"批量生成函数注释": { "批量生成函数注释": {
@ -219,7 +221,7 @@ def get_crazy_functions():
from crazy_functions.联网的ChatGPT import 连接网络回答问题 from crazy_functions.联网的ChatGPT import 连接网络回答问题
function_plugins.update({ function_plugins.update({
"连接网络回答问题(先输入问题,再点击按钮,需要访问谷歌)": { "连接网络回答问题": {
"Color": "stop", "Color": "stop",
"AsButton": True, # 加入下拉菜单中 "AsButton": True, # 加入下拉菜单中
"Function": HotReload(连接网络回答问题) "Function": HotReload(连接网络回答问题)

View File

@ -417,10 +417,6 @@ class FileHandle:
if __name__ == '__main__': if __name__ == '__main__':
txt = "Authorization: WPS-2:AqY7ik9XQ92tvO7+NlCRvA==:b2f626f496de9c256605a15985c855a8b3e4be99\nwps-Sid: V02SgISzdeWrYdwvW_xbib-fGlqUIIw00afc5b890008c1976f\nCookie: wpsua=V1BTVUEvMS4wIChhbmRyb2lkLW9mZmljZToxNy41O2FuZHJvaWQ6MTA7ZjIwZDAyNWQzYTM5MmExMDBiYzgxNWI2NmI3Y2E5ODI6ZG1sMmJ5QldNakF5TUVFPSl2aXZvL1YyMDIwQQ=="
txt = "Authorization: WPS-2:AqY7ik9XQ92tvO7+NlCRvA==:b2f626f496de9c256605a15985c855a8b3e4be99 客户发顺丰啦 这是其他文本哦"
print(YamlHandle().load()) print(YamlHandle().load())

View File

@ -82,7 +82,6 @@ def ArgsGeneralWrapper(f):
chatbot_with_cookie.write_list(chatbot) chatbot_with_cookie.write_list(chatbot)
txt_passon = txt txt_passon = txt
if encrypt in models: txt_passon = func_box.encryption_str(txt) if encrypt in models: txt_passon = func_box.encryption_str(txt)
if args == (): args = (ipaddr.client.port, )
if txt_passon == '' and txt_passon == ' ' and len(args) > 1: if txt_passon == '' and txt_passon == ' ' and len(args) > 1:
msgs = f'### {args[1]} Warning 输入框为空\n' \ msgs = f'### {args[1]} Warning 输入框为空\n' \
'tips: 使用基础功能时,请在输入区输入需要处理的文本内容' 'tips: 使用基础功能时,请在输入区输入需要处理的文本内容'