From b538d31b1357b46838f431fc5902b1e3feca4a65 Mon Sep 17 00:00:00 2001 From: kainstan Date: Tue, 6 Jun 2023 09:07:53 +0800 Subject: [PATCH] Str is a built-in type and cannot be used directly as a variable name --- toolbox.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/toolbox.py b/toolbox.py index ddfe34c..9f9703f 100644 --- a/toolbox.py +++ b/toolbox.py @@ -84,11 +84,12 @@ def update_ui_lastest_msg(lastmsg, chatbot, history, delay=1): # 刷新界面 def trimmed_format_exc(): - import os, traceback - str = traceback.format_exc() + import os + import traceback + _str = traceback.format_exc() current_path = os.getcwd() replace_path = "." - return str.replace(current_path, replace_path) + return _str.replace(current_path, replace_path) def CatchException(f): @@ -101,7 +102,7 @@ def CatchException(f): yield from f(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT) except Exception as e: from check_proxy import check_proxy - from toolbox import get_conf + # from toolbox import get_conf # 不需要导入本文件内容 proxies, = get_conf('proxies') tb_str = '```\n' + trimmed_format_exc() + '```' if len(chatbot) == 0: @@ -109,7 +110,7 @@ def CatchException(f): chatbot.append(["插件调度异常", "异常原因"]) chatbot[-1] = (chatbot[-1][0], f"[Local Message] 实验性函数调用出错: \n\n{tb_str} \n\n当前代理可用性: \n\n{check_proxy(proxies)}") - yield from update_ui(chatbot=chatbot, history=history, msg=f'异常 {e}') # 刷新界面 + yield from update_ui(chatbot=chatbot, history=history, msg=f'异常 {e}') # 刷新界面 return decorated