Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加入qianfan,gemini-和moonshot-多线程请求;重试次数参数加入设置(config.py)RETRY_TIMES_AT_UNKNOWN_ERROR=3 #1745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions crazy_functions/crazy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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模型同时维持用户界面活跃。
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crazy_functions/latex_fns/latex_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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前端界面
Expand Down