From d9fc21c23482931ac5de931f2210bd99fbd42736 Mon Sep 17 00:00:00 2001 From: lin-qian123 Date: Fri, 26 Apr 2024 16:38:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8A=A0=E5=85=A5qianfan=E4=B8=8Egemini-?= =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E8=AF=B7=E6=B1=82=202.=E6=94=B9?= =?UTF-8?q?=E5=8F=98=E9=87=8D=E8=AF=95=E6=AC=A1=E6=95=B0=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=AE=BE=E7=BD=AE=EF=BC=88config.py=EF=BC=89?= =?UTF-8?q?RETRY=5FTIMES=5FAT=5FUNKNOWN=5FERROR=3D3=203.=E6=94=B9=E5=8F=98?= =?UTF-8?q?tex=E9=87=8D=E5=A4=8D=E7=BC=96=E8=AF=91=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E5=B0=8632=E6=AC=A1=E6=94=B9=E4=B8=BA12=E6=AC=A1?= =?UTF-8?q?=EF=BC=88=E7=AC=AC=E4=B8=80=E6=AC=A1=E7=BC=96=E8=AF=91=E4=B8=8D?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=E9=9D=A2=E5=A4=A7=E6=A6=82=E7=8E=87?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E4=B8=8D=E6=88=90=E5=8A=9F=EF=BC=8C=E6=B2=A1?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E8=BF=99=E4=B9=88=E5=A4=9A=E6=AC=A1=E6=B5=AA?= =?UTF-8?q?=E8=B4=B9=E6=97=B6=E9=97=B4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 3 +++ crazy_functions/crazy_utils.py | 7 +++++-- crazy_functions/latex_fns/latex_actions.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 44788bc76..68ae39a1f 100644 --- a/config.py +++ b/config.py @@ -78,6 +78,9 @@ # 默认的系统提示词(system prompt) INIT_SYS_PROMPT = "Serve me as a writing and programming assistant." +# 任务失败时默认重试的次数 +RETRY_TIMES_AT_UNKNOWN_ERROR = 3 + # 对话窗的高度 (仅在LAYOUT="TOP-DOWN"时生效) CHATBOT_HEIGHT = 1115 diff --git a/crazy_functions/crazy_utils.py b/crazy_functions/crazy_utils.py index 83d108622..6845efd2e 100644 --- a/crazy_functions/crazy_utils.py +++ b/crazy_functions/crazy_utils.py @@ -41,7 +41,7 @@ def request_gpt_model_in_new_thread_with_ui_alive( inputs, inputs_show_user, llm_kwargs, chatbot, history, sys_prompt, refresh_interval=0.2, handle_token_exceed=True, - retry_times_at_unknown_error=2, + retry_times_at_unknown_error=get_conf('RETRY_TIMES_AT_UNKNOWN_ERROR'), ): """ Request GPT model,请求GPT模型同时维持用户界面活跃。 @@ -142,6 +142,9 @@ def default_condition(llm) -> bool: # legacy condition if llm.startswith('gpt-'): return True if llm.startswith('api2d-'): return True + if llm.startswith('qianfan'): return True + if llm.startswith('gemini-'): return True + if llm.startswith('moonshot-'): return True if llm.startswith('azure-'): return True if llm.startswith('spark'): return True if llm.startswith('zhipuai') or llm.startswith('glm-'): return True @@ -160,7 +163,7 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency( chatbot, history_array, sys_prompt_array, refresh_interval=0.2, max_workers=-1, scroller_max_len=30, handle_token_exceed=True, show_user_at_complete=False, - retry_times_at_unknown_error=2, + retry_times_at_unknown_error=get_conf('RETRY_TIMES_AT_UNKNOWN_ERROR'), ): """ Request GPT model using multiple threads with UI and high efficiency diff --git a/crazy_functions/latex_fns/latex_actions.py b/crazy_functions/latex_fns/latex_actions.py index 0ec01b998..9f9b807b2 100644 --- a/crazy_functions/latex_fns/latex_actions.py +++ b/crazy_functions/latex_fns/latex_actions.py @@ -345,7 +345,7 @@ def 编译Latex(chatbot, history, main_file_original, main_file_modified, work_f import os, time n_fix = 1 fixed_line = [] - max_try = 32 + max_try = 12 chatbot.append([f"正在编译PDF文档", f'编译已经开始。当前工作路径为{work_folder},如果程序停顿5分钟以上,请直接去该路径下取回翻译结果,或者重启之后再度尝试 ...']); yield from update_ui(chatbot=chatbot, history=history) chatbot.append([f"正在编译PDF文档", '...']); yield from update_ui(chatbot=chatbot, history=history); time.sleep(1); chatbot[-1] = list(chatbot[-1]) # 刷新界面 yield from update_ui_lastest_msg('编译已经开始...', chatbot, history) # 刷新Gradio前端界面