From 045cdb15d86c262a55ede6dd9c84a5ab63dcc797 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Mon, 10 Mar 2025 23:41:59 +0800 Subject: [PATCH 1/9] ensure display none even if css load fails --- shared_utils/advanced_markdown_format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared_utils/advanced_markdown_format.py b/shared_utils/advanced_markdown_format.py index 4771a4f1..7be1db20 100644 --- a/shared_utils/advanced_markdown_format.py +++ b/shared_utils/advanced_markdown_format.py @@ -347,7 +347,7 @@ def markdown_convertion(txt): # 在文本中插入一个base64编码的原始文本,以便在复制时能够获得原始文本 raw_text_encoded = compress_string(txt) - raw_text_node = f'
{raw_text_encoded}
' + raw_text_node = f'' suf = raw_text_node + "" # 用于查找数学公式的正则表达式 From 82aac97980a610fa7847204b3ad8b3621bcf8b5d Mon Sep 17 00:00:00 2001 From: BZfei <33652938+zqfzqf@users.noreply.github.com> Date: Tue, 25 Mar 2025 00:11:55 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E7=99=BE?= =?UTF-8?q?=E7=82=BC(=E5=8E=9F=E7=81=B5=E7=A7=AF)=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9deepseek-r1=E3=80=81deepseek-v3=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20(#2182)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 阿里云百炼(原灵积)增加对deepseek-r1、deepseek-v3模型支持 * update reasoning display --------- Co-authored-by: binary-husky --- config.py | 1 + request_llms/bridge_all.py | 25 +++++++++++++++++++++++-- request_llms/bridge_chatgpt.py | 8 ++++---- request_llms/com_qwenapi.py | 28 +++++++++++++++++++++++----- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/config.py b/config.py index e668ac90..ac8d2fdf 100644 --- a/config.py +++ b/config.py @@ -45,6 +45,7 @@ AVAIL_LLM_MODELS = ["qwen-max", "o1-mini", "o1-mini-2024-09-12", "o1", "o1-2024- "gemini-1.5-pro", "chatglm3", "chatglm4", "deepseek-chat", "deepseek-coder", "deepseek-reasoner", "volcengine-deepseek-r1-250120", "volcengine-deepseek-v3-241226", + "dashscope-deepseek-r1", "dashscope-deepseek-v3", ] EMBEDDING_MODEL = "text-embedding-3-small" diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index e911a765..a2bb3a01 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -813,8 +813,9 @@ if "qwen-local" in AVAIL_LLM_MODELS: }) except: logger.error(trimmed_format_exc()) -# -=-=-=-=-=-=- 通义-在线模型 -=-=-=-=-=-=- -qwen_models = ["qwen-max-latest", "qwen-max-2025-01-25","qwen-max","qwen-turbo","qwen-plus"] + +# -=-=-=-=-=-=- 阿里云百炼(通义)-在线模型 -=-=-=-=-=-=- +qwen_models = ["qwen-max-latest", "qwen-max-2025-01-25","qwen-max","qwen-turbo","qwen-plus","dashscope-deepseek-r1","dashscope-deepseek-v3"] if any(item in qwen_models for item in AVAIL_LLM_MODELS): try: from .bridge_qwen import predict_no_ui_long_connection as qwen_noui @@ -864,10 +865,30 @@ if any(item in qwen_models for item in AVAIL_LLM_MODELS): "max_token": 30720, "tokenizer": tokenizer_gpt35, "token_cnt": get_token_num_gpt35, + }, + "dashscope-deepseek-r1": { + "fn_with_ui": qwen_ui, + "fn_without_ui": qwen_noui, + "enable_reasoning": True, + "can_multi_thread": True, + "endpoint": None, + "max_token": 57344, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, + }, + "dashscope-deepseek-v3": { + "fn_with_ui": qwen_ui, + "fn_without_ui": qwen_noui, + "can_multi_thread": True, + "endpoint": None, + "max_token": 57344, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, } }) except: logger.error(trimmed_format_exc()) + # -=-=-=-=-=-=- 零一万物模型 -=-=-=-=-=-=- yi_models = ["yi-34b-chat-0205","yi-34b-chat-200k","yi-large","yi-medium","yi-spark","yi-large-turbo","yi-large-preview"] if any(item in yi_models for item in AVAIL_LLM_MODELS): diff --git a/request_llms/bridge_chatgpt.py b/request_llms/bridge_chatgpt.py index 7d5cbe64..b1eddb9e 100644 --- a/request_llms/bridge_chatgpt.py +++ b/request_llms/bridge_chatgpt.py @@ -368,12 +368,12 @@ def predict(inputs:str, llm_kwargs:dict, plugin_kwargs:dict, chatbot:ChatBotWith log_chat(llm_model=llm_kwargs["llm_model"], input_str=inputs, output_str=gpt_replying_buffer) break # 对于符合规范的接口,这里可以break else: - continue # 对于不符合规范的狗屎接口,这里需要继续 + continue # 对于不符合规范的接口,这里需要继续 # 到这里,我们已经可以假定必须包含choice了 try: status_text = f"finish_reason: {chunkjson['choices'][0].get('finish_reason', 'null')}" except: - logger.error(f"一些垃圾第三方接口出现这样的错误,兼容一下吧: {chunk_decoded}") + logger.error(f"一些第三方接口出现这样的错误,兼容一下吧: {chunk_decoded}") # 处理数据流的主体 if has_content: # 正常情况 @@ -382,9 +382,9 @@ def predict(inputs:str, llm_kwargs:dict, plugin_kwargs:dict, chatbot:ChatBotWith # 一些第三方接口的出现这样的错误,兼容一下吧 continue else: - # 至此已经超出了正常接口应该进入的范围,一些垃圾第三方接口会出现这样的错误 + # 至此已经超出了正常接口应该进入的范围,一些第三方接口会出现这样的错误 if chunkjson['choices'][0]["delta"].get("content", None) is None: - logger.error(f"一些垃圾第三方接口出现这样的错误,兼容一下吧: {chunk_decoded}") + logger.error(f"一些第三方接口出现这样的错误,兼容一下吧: {chunk_decoded}") continue gpt_replying_buffer = gpt_replying_buffer + chunkjson['choices'][0]["delta"]["content"] diff --git a/request_llms/com_qwenapi.py b/request_llms/com_qwenapi.py index 70872e16..edbf9d7b 100644 --- a/request_llms/com_qwenapi.py +++ b/request_llms/com_qwenapi.py @@ -3,6 +3,7 @@ from toolbox import get_conf import threading timeout_bot_msg = '[Local Message] Request timeout. Network error.' +model_prefix_to_remove = 'dashscope-' class QwenRequestInstance(): def __init__(self): @@ -20,6 +21,13 @@ class QwenRequestInstance(): raise RuntimeError('请配置 DASHSCOPE_API_KEY') dashscope.api_key = get_conf("DASHSCOPE_API_KEY") + def format_reasoning(self, reasoning_content:str, main_content:str): + if reasoning_content: + reasoning_content_paragraphs = ''.join([f'

{line}

' for line in reasoning_content.split('\n')]) + formatted_reasoning_content = f'
{reasoning_content_paragraphs}
\n\n---\n\n' + return formatted_reasoning_content + main_content + else: + return main_content def generate(self, inputs, llm_kwargs, history, system_prompt): # import _thread as thread @@ -28,9 +36,13 @@ class QwenRequestInstance(): if top_p == 0: top_p += 1e-5 if top_p == 1: top_p -= 1e-5 + model_name = llm_kwargs['llm_model'] + if model_name.startswith(model_prefix_to_remove): model_name = model_name[len(model_prefix_to_remove):] + + self.reasoning_buf = "" self.result_buf = "" responses = Generation.call( - model=llm_kwargs['llm_model'], + model=model_name, messages=generate_message_payload(inputs, llm_kwargs, history, system_prompt), top_p=top_p, temperature=llm_kwargs.get('temperature', 1.0), @@ -46,18 +58,24 @@ class QwenRequestInstance(): self.result_buf += response.output.choices[0].message.content except: pass - yield self.result_buf + yield self.format_reasoning(self.reasoning_buf, self.result_buf) break elif response.output.choices[0].finish_reason == 'length': self.result_buf += "[Local Message] 生成长度过长,后续输出被截断" - yield self.result_buf + yield self.format_reasoning(self.reasoning_buf, self.result_buf) break else: + try: + contain_reasoning = hasattr(response.output.choices[0].message, 'reasoning_content') + except: + contain_reasoning = False + if contain_reasoning: + self.reasoning_buf += response.output.choices[0].message.reasoning_content self.result_buf += response.output.choices[0].message.content - yield self.result_buf + yield self.format_reasoning(self.reasoning_buf, self.result_buf) else: self.result_buf += f"[Local Message] 请求错误:状态码:{response.status_code},错误码:{response.code},消息:{response.message}" - yield self.result_buf + yield self.format_reasoning(self.reasoning_buf, self.result_buf) break # 耗尽generator避免报错 From 63c61e62042a44484ce53d183b22ea9382e1d086 Mon Sep 17 00:00:00 2001 From: davidfir3 <40458162+davidfir3@users.noreply.github.com> Date: Tue, 25 Mar 2025 00:13:18 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0gemini-2.0-flash=20(#2180?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 柯仕锋 <12029064@zju.edu.cn> --- request_llms/bridge_all.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index a2bb3a01..52ed2fa7 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -530,6 +530,15 @@ model_info = { "tokenizer": tokenizer_gpt35, "token_cnt": get_token_num_gpt35, }, + "gemini-2.0-flash": { + "fn_with_ui": genai_ui, + "fn_without_ui": genai_noui, + "endpoint": gemini_endpoint, + "has_multimodal_capacity": True, + "max_token": 1024 * 204800, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, + }, # cohere "cohere-command-r-plus": { From 858b5f69b05c592604a08ffe2bfd36b175f95f03 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Tue, 15 Apr 2025 01:08:54 +0800 Subject: [PATCH 4/9] add in-text stop btn --- main.py | 2 +- shared_utils/advanced_markdown_format.py | 2 +- themes/common.css | 70 ++++++++++++++ themes/common.js | 114 +++++++++++++++-------- 4 files changed, 149 insertions(+), 39 deletions(-) diff --git a/main.py b/main.py index 73a3e2b8..062cba5f 100644 --- a/main.py +++ b/main.py @@ -184,7 +184,7 @@ def main(): from themes.gui_floating_menu import define_gui_floating_menu area_input_secondary, txt2, area_customize, _, resetBtn2, clearBtn2, stopBtn2 = \ define_gui_floating_menu(customize_btns, functional, predefined_btns, cookies, web_cookie_cache) - + # 浮动时间线定义 gr.Spark() diff --git a/shared_utils/advanced_markdown_format.py b/shared_utils/advanced_markdown_format.py index 7be1db20..a8a10411 100644 --- a/shared_utils/advanced_markdown_format.py +++ b/shared_utils/advanced_markdown_format.py @@ -347,7 +347,7 @@ def markdown_convertion(txt): # 在文本中插入一个base64编码的原始文本,以便在复制时能够获得原始文本 raw_text_encoded = compress_string(txt) - raw_text_node = f'' + raw_text_node = f'" # 用于查找数学公式的正则表达式 diff --git a/themes/common.css b/themes/common.css index 2f7dda2f..610d46c2 100644 --- a/themes/common.css +++ b/themes/common.css @@ -335,4 +335,74 @@ .raw_text { display: none; +} + +.message_tail { + justify-content: center; + align-items: center; +} +.message_tail_stop { + border: dotted !important; + margin-top: 5px !important; + padding-left: 8px !important; + padding-top: 1px !important; + padding-bottom: 1px !important; + padding-right: 12px !important; +} + +/* ant 开始 */ + +/* 通用按钮样式 */ +.ant-btn { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 8px 16px; + font-size: 14px; + font-weight: bold; + border-radius: 4px; + cursor: pointer; + transition: background-color 0.3s; +} + +/* 按钮颜色和状态 */ +.ant-btn-primary { + background-color: #1890ff; + color: white; + border: none; +} + +.ant-btn-primary:hover { + background-color: #40a9ff; +} + +.ant-btn-loading { + pointer-events: none; + opacity: 0.7; +} + +/* 图标样式 */ +.ant-btn-icon { + display: inline-flex; + margin-right: 8px; +} + +.anticon { + width: 1em; + height: 1em; + fill: currentColor; +} + +.anticon-spin { + animation: spin 1s linear infinite; +} + +/* 动画效果 */ +@keyframes spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } } \ No newline at end of file diff --git a/themes/common.js b/themes/common.js index f8510624..f05b9b71 100644 --- a/themes/common.js +++ b/themes/common.js @@ -289,7 +289,7 @@ function addCopyButton(botElement, index, is_last_in_arr) { const audioIcon = ''; // const cancelAudioIcon = ''; - // 此功能没准备好 + // audio functionality if (allow_auto_read_continously && is_last_in_arr && allow_auto_read_tts_flag) { process_latest_text_output(botElement.innerText, index); } @@ -300,41 +300,6 @@ function addCopyButton(botElement, index, is_last_in_arr) { return; } - // var copyButton = document.createElement('button'); - // copyButton.classList.add('copy-bot-btn'); - // copyButton.setAttribute('aria-label', 'Copy'); - // copyButton.innerHTML = copyIcon; - // copyButton.addEventListener('click', async () => { - // const textToCopy = botElement.innerText; - // try { - // // push_text_to_audio(textToCopy).catch(console.error); - // if ("clipboard" in navigator) { - // await navigator.clipboard.writeText(textToCopy); - // copyButton.innerHTML = copiedIcon; - // setTimeout(() => { - // copyButton.innerHTML = copyIcon; - // }, 1500); - // } else { - // const textArea = document.createElement("textarea"); - // textArea.value = textToCopy; - // document.body.appendChild(textArea); - // textArea.select(); - // try { - // document.execCommand('copy'); - // copyButton.innerHTML = copiedIcon; - // setTimeout(() => { - // copyButton.innerHTML = copyIcon; - // }, 1500); - // } catch (error) { - // console.error("Copy failed: ", error); - // } - // document.body.removeChild(textArea); - // } - // } catch (error) { - // console.error("Copy failed: ", error); - // } - // }); - // 原始文本拷贝 var copyButtonOrig = document.createElement('button'); copyButtonOrig.classList.add('copy-bot-btn'); @@ -436,7 +401,6 @@ function do_something_but_not_too_frequently(min_interval, func) { function chatbotContentChanged(attempt = 1, force = false) { - // https://github.com/GaiZhenbiao/ChuanhuChatGPT/tree/main/web_assets/javascript for (var i = 0; i < attempt; i++) { setTimeout(() => { const messages = gradioApp().querySelectorAll('#gpt-chatbot .message-wrap .message.bot'); @@ -447,6 +411,9 @@ function chatbotContentChanged(attempt = 1, force = false) { // Now pass both the message element and the is_last_in_arr boolean to addCopyButton addCopyButton(message, index, is_last_in_arr); + // if last message, add stop btn link + addStopButton(message, index, is_last_in_arr); + // save_conversation_history save_conversation_history_slow_down(); }); @@ -457,6 +424,79 @@ function chatbotContentChanged(attempt = 1, force = false) { } +function addStopButton(botElement, index, is_last_in_arr) { + function is_generating() { + var statePanelElement = document.getElementById("state-panel"); + var generatingElement = statePanelElement.querySelector(".generating"); + if (generatingElement) { + return true; + } else { + return false; + } + } + function on_stop_btn_click() { + let stopButton = document.getElementById("elem_stop"); + stopButton.click(); + } + function remove_stop_generate_btn(messageTailElement) { + // remove all child elements of messageTailElement + while (messageTailElement.firstChild) { + messageTailElement.removeChild(messageTailElement.firstChild); + } + messageTailElement.style.display = 'none'; + messageTailElement.classList.add('removed'); + } + function add_stop_generate_btn() { + // write here: add a beautiful stop btn `bottomElement` as child, when clicked execute on_stop_btn_click + console.log("get_gradio_component") + const bottomElement = document.createElement('button'); + bottomElement.className = 'ant-btn ant-btn-primary'; + bottomElement.innerHTML = ` + + + + 终止 + `; + bottomElement.classList.add('message_tail_stop'); + bottomElement.addEventListener('click', on_stop_btn_click); + messageTailElement.appendChild(bottomElement); + } + + // find a sub element of class `message_tail` + const messageTailElement = botElement.querySelector('.message_tail'); + // if not is_last_in_arr, hide this elem (display none) + if (!messageTailElement) { + return; + } + if (messageTailElement.classList.contains('removed')) { + return; + } + if (!is_last_in_arr) { + remove_stop_generate_btn(messageTailElement); + return; + } + messageTailElement.style.display = 'flex'; + const messageTailStopElem = messageTailElement.querySelector('.message_tail_stop'); + if(!is_generating()) { + setTimeout(() => { + if(!is_generating()) { + remove_stop_generate_btn(messageTailElement); + return; + } else { + if (!messageTailStopElem) { + add_stop_generate_btn() + } + } + }, 500); + } else { + if (!messageTailStopElem) { + add_stop_generate_btn() + } + } + +} // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= From 24cebaf4ec4874d65d67c357f61f75f80fc26002 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Mon, 21 Apr 2025 00:48:59 +0800 Subject: [PATCH 5/9] add o3 and o4 models --- request_llms/bridge_all.py | 43 +++++++++++++++++++++++++++++ shared_utils/key_pattern_manager.py | 10 ++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index 52ed2fa7..f530f5f2 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -314,6 +314,49 @@ model_info = { "openai_force_temperature_one": True, }, + "gpt-4.1":{ + "fn_with_ui": chatgpt_ui, + "fn_without_ui": chatgpt_noui, + "has_multimodal_capacity": True, + "endpoint": openai_endpoint, + "max_token": 828000, + "tokenizer": tokenizer_gpt4, + "token_cnt": get_token_num_gpt4, + }, + + "gpt-4.1-mini":{ + "fn_with_ui": chatgpt_ui, + "fn_without_ui": chatgpt_noui, + "has_multimodal_capacity": True, + "endpoint": openai_endpoint, + "max_token": 828000, + "tokenizer": tokenizer_gpt4, + "token_cnt": get_token_num_gpt4, + }, + + "o3":{ + "fn_with_ui": chatgpt_ui, + "fn_without_ui": chatgpt_noui, + "has_multimodal_capacity": True, + "endpoint": openai_endpoint, + "max_token": 828000, + "tokenizer": tokenizer_gpt4, + "token_cnt": get_token_num_gpt4, + "openai_disable_system_prompt": True, + "openai_disable_stream": True, + "openai_force_temperature_one": True, + }, + + "o4-mini":{ + "fn_with_ui": chatgpt_ui, + "fn_without_ui": chatgpt_noui, + "has_multimodal_capacity": True, + "endpoint": openai_endpoint, + "max_token": 828000, + "tokenizer": tokenizer_gpt4, + "token_cnt": get_token_num_gpt4, + }, + "gpt-4-turbo": { "fn_with_ui": chatgpt_ui, "fn_without_ui": chatgpt_noui, diff --git a/shared_utils/key_pattern_manager.py b/shared_utils/key_pattern_manager.py index b7191638..8ea20016 100644 --- a/shared_utils/key_pattern_manager.py +++ b/shared_utils/key_pattern_manager.py @@ -79,6 +79,14 @@ def what_keys(keys): return f"检测到: OpenAI Key {avail_key_list['OpenAI Key']} 个, Azure Key {avail_key_list['Azure Key']} 个, API2D Key {avail_key_list['API2D Key']} 个" +def is_o_family_for_openai(llm_model): + if not llm_model.startswith('o'): + return False + if llm_model in ['o1', 'o2', 'o3', 'o4', 'o5', 'o6', 'o7', 'o8']: + return True + if llm_model[:3] in ['o1-', 'o2-', 'o3-', 'o4-', 'o5-', 'o6-', 'o7-', 'o8-']: + return True + return False def select_api_key(keys, llm_model): import random @@ -86,7 +94,7 @@ def select_api_key(keys, llm_model): key_list = keys.split(',') if llm_model.startswith('gpt-') or llm_model.startswith('chatgpt-') or \ - llm_model.startswith('one-api-') or llm_model == 'o1' or llm_model.startswith('o1-'): + llm_model.startswith('one-api-') or is_o_family_for_openai(llm_model): for k in key_list: if is_openai_api_key(k): avail_key_list.append(k) From 883b513b9112a7f845dee04624275af2673ee3fb Mon Sep 17 00:00:00 2001 From: binary-husky Date: Mon, 21 Apr 2025 00:50:24 +0800 Subject: [PATCH 6/9] add can_multi_thread --- request_llms/bridge_all.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index f530f5f2..c738864f 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -282,6 +282,7 @@ model_info = { "fn_with_ui": chatgpt_ui, "fn_without_ui": chatgpt_noui, "endpoint": openai_endpoint, + "can_multi_thread": True, "max_token": 128000, "tokenizer": tokenizer_gpt4, "token_cnt": get_token_num_gpt4, @@ -351,6 +352,7 @@ model_info = { "fn_with_ui": chatgpt_ui, "fn_without_ui": chatgpt_noui, "has_multimodal_capacity": True, + "can_multi_thread": True, "endpoint": openai_endpoint, "max_token": 828000, "tokenizer": tokenizer_gpt4, From fc06be6f7a44268f997e2fe0795a285d8bfb199f Mon Sep 17 00:00:00 2001 From: binary-husky <96192199+binary-husky@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:09:53 +0800 Subject: [PATCH 7/9] support qwen3 models --- request_llms/bridge_all.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index c738864f..a37daae3 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -869,7 +869,10 @@ if "qwen-local" in AVAIL_LLM_MODELS: logger.error(trimmed_format_exc()) # -=-=-=-=-=-=- 阿里云百炼(通义)-在线模型 -=-=-=-=-=-=- -qwen_models = ["qwen-max-latest", "qwen-max-2025-01-25","qwen-max","qwen-turbo","qwen-plus","dashscope-deepseek-r1","dashscope-deepseek-v3"] +qwen_models = ["qwen-max-latest", "qwen-max-2025-01-25","qwen-max","qwen-turbo","qwen-plus", + "dashscope-deepseek-r1","dashscope-deepseek-v3", + "dashscope-qwen3-14b", "dashscope-qwen3-235b-a22b", "dashscope-qwen3-qwen3-32b", + ] if any(item in qwen_models for item in AVAIL_LLM_MODELS): try: from .bridge_qwen import predict_no_ui_long_connection as qwen_noui @@ -938,6 +941,34 @@ if any(item in qwen_models for item in AVAIL_LLM_MODELS): "max_token": 57344, "tokenizer": tokenizer_gpt35, "token_cnt": get_token_num_gpt35, + }, + "dashscope-qwen3-14b": { + "fn_with_ui": qwen_ui, + "fn_without_ui": qwen_noui, + "enable_reasoning": True, + "can_multi_thread": True, + "endpoint": None, + "max_token": 129024, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, + }, + "dashscope-qwen3-235b-a22b": { + "fn_with_ui": qwen_ui, + "fn_without_ui": qwen_noui, + "can_multi_thread": True, + "endpoint": None, + "max_token": 129024, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, + }, + "dashscope-qwen3-32b": { + "fn_with_ui": qwen_ui, + "fn_without_ui": qwen_noui, + "can_multi_thread": True, + "endpoint": None, + "max_token": 129024, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, } }) except: From ee1a9e7cce18eb07a2f8cb592573d6d82475d24c Mon Sep 17 00:00:00 2001 From: binary-husky <96192199+binary-husky@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:10:49 +0800 Subject: [PATCH 8/9] support qwen3 models - edit config hint --- config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index ac8d2fdf..90e7fe7e 100644 --- a/config.py +++ b/config.py @@ -7,11 +7,11 @@ Configuration reading priority: environment variable > config_private.py > config.py """ -# [step 1-1]>> ( 接入GPT等模型 ) API_KEY = "sk-123456789xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx123456789"。极少数情况下,还需要填写组织(格式如org-123456789abcdefghijklmno的),请向下翻,找 API_ORG 设置项 +# [step 1-1]>> ( 接入OpenAI模型家族 ) API_KEY = "sk-123456789xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx123456789"。极少数情况下,还需要填写组织(格式如org-123456789abcdefghijklmno的),请向下翻,找 API_ORG 设置项 API_KEY = "在此处填写APIKEY" # 可同时填写多个API-KEY,用英文逗号分割,例如API_KEY = "sk-openaikey1,sk-openaikey2,fkxxxx-api2dkey3,azure-apikey4" -# [step 1-2]>> ( 接入通义 qwen-max ) 接入通义千问在线大模型,api-key获取地址 https://dashscope.console.aliyun.com/ -DASHSCOPE_API_KEY = "" # 阿里灵积云API_KEY +# [step 1-2]>> ( 强烈推荐!接入通义家族 & 大模型服务平台百炼 ) 接入通义千问在线大模型,api-key获取地址 https://dashscope.console.aliyun.com/ +DASHSCOPE_API_KEY = "" # 阿里灵积云API_KEY(用于接入qwen-max,dashscope-qwen3-14b,dashscope-deepseek-r1等) # [step 1-3]>> ( 接入 deepseek-reasoner, 即 deepseek-r1 ) 深度求索(DeepSeek) API KEY,默认请求地址为"https://api.deepseek.com/v1/chat/completions" DEEPSEEK_API_KEY = "" @@ -46,6 +46,7 @@ AVAIL_LLM_MODELS = ["qwen-max", "o1-mini", "o1-mini-2024-09-12", "o1", "o1-2024- "deepseek-chat", "deepseek-coder", "deepseek-reasoner", "volcengine-deepseek-r1-250120", "volcengine-deepseek-v3-241226", "dashscope-deepseek-r1", "dashscope-deepseek-v3", + "dashscope-qwen3-14b", "dashscope-qwen3-235b-a22b", "dashscope-qwen3-32b", ] EMBEDDING_MODEL = "text-embedding-3-small" From eba48a0f1abbcdac479473b8b1574277a969e204 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Tue, 6 May 2025 22:10:21 +0800 Subject: [PATCH 9/9] improve reset conversation ui --- main.py | 2 +- requirements.txt | 2 +- themes/common.js | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 062cba5f..af20207d 100644 --- a/main.py +++ b/main.py @@ -34,7 +34,7 @@ def encode_plugin_info(k, plugin)->str: def main(): import gradio as gr - if gr.__version__ not in ['3.32.12', '3.32.13']: + if gr.__version__ not in ['3.32.14', '3.32.13']: raise ModuleNotFoundError("使用项目内置Gradio获取最优体验! 请运行 `pip install -r requirements.txt` 指令安装内置Gradio及其他依赖, 详情信息见requirements.txt.") # 一些基础工具 diff --git a/requirements.txt b/requirements.txt index 92c86c01..266c81c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -https://public.agent-matrix.com/publish/gradio-3.32.13-py3-none-any.whl +https://public.agent-matrix.com/publish/gradio-3.32.14-py3-none-any.whl fastapi==0.110 gradio-client==0.8 pypdf2==2.12.1 diff --git a/themes/common.js b/themes/common.js index f05b9b71..87420797 100644 --- a/themes/common.js +++ b/themes/common.js @@ -1184,6 +1184,15 @@ async function clear_conversation(a, b, c) { update_conversation_metadata(); let stopButton = document.getElementById("elem_stop"); stopButton.click(); + // Save back to local storage + try { + const EVENT_NAME = "gptac_reset_btn_clicked"; + window.dispatchEvent( + new CustomEvent(EVENT_NAME, { + detail: "" + }) + ); + } catch (e) {} return reset_conversation(a, b); }