From c53ddf65aa2208f1e7bc1cfb66ef854daa3d9fac Mon Sep 17 00:00:00 2001 From: "G.RQ" <61670021+guoruqiang@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:19:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20bug=E2=80=9C=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E2=80=9D=E6=8C=89=E9=92=AE=E6=8A=A5=E9=94=99=20(#2102?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix 重置按钮bug * fix version control bug --------- Co-authored-by: binary-husky --- themes/common.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/themes/common.js b/themes/common.js index d22d5a6e..04628d1b 100644 --- a/themes/common.js +++ b/themes/common.js @@ -1070,6 +1070,14 @@ function restore_chat_from_local_storage(event) { } +function clear_conversation(a, b, c) { + update_conversation_metadata(); + let stopButton = document.getElementById("elem_stop"); + stopButton.click(); + // console.log("clear_conversation"); + return reset_conversation(a, b); +} + function reset_conversation(a, b) { // console.log("js_code_reset"); From 09a82a572d51e4384bfc6aebffefbd982b5ee5ab Mon Sep 17 00:00:00 2001 From: whyXVI <139840508+whyXVI@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:21:14 +0800 Subject: [PATCH 2/3] Fix RuntimeError in predict_no_ui_long_connection() (#2095) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug fix: Fix RuntimeError in predict_no_ui_long_connection() In the original code, calling predict_no_ui_long_connection() would trigger a RuntimeError("OpenAI拒绝了请求:" + error_msg) even when the server responded normally. The issue occurred due to incorrect handling of SSE protocol comment lines (lines starting with ":"). Modified the parsing logic in both `predict` and `predict_no_ui_long_connection` to handle these lines correctly, making the logic more intuitive and robust. --- request_llms/bridge_openrouter.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/request_llms/bridge_openrouter.py b/request_llms/bridge_openrouter.py index 10dfe57f..71a53a9c 100644 --- a/request_llms/bridge_openrouter.py +++ b/request_llms/bridge_openrouter.py @@ -170,7 +170,7 @@ def predict_no_ui_long_connection(inputs:str, llm_kwargs:dict, history:list=[], except requests.exceptions.ConnectionError: chunk = next(stream_response) # 失败了,重试一次?再失败就没办法了。 chunk_decoded, chunkjson, has_choices, choice_valid, has_content, has_role = decode_chunk(chunk) - if len(chunk_decoded)==0: continue + if len(chunk_decoded)==0 or chunk_decoded.startswith(':'): continue if not chunk_decoded.startswith('data:'): error_msg = get_full_error(chunk, stream_response).decode() if "reduce the length" in error_msg: @@ -181,9 +181,6 @@ def predict_no_ui_long_connection(inputs:str, llm_kwargs:dict, history:list=[], raise RuntimeError("OpenAI拒绝了请求:" + error_msg) if ('data: [DONE]' in chunk_decoded): break # api2d 正常完成 # 提前读取一些信息 (用于判断异常) - if (has_choices and not choice_valid) or ('OPENROUTER PROCESSING' in chunk_decoded): - # 一些垃圾第三方接口的出现这样的错误,openrouter的特殊处理 - continue json_data = chunkjson['choices'][0] delta = json_data["delta"] if len(delta) == 0: break @@ -328,8 +325,7 @@ def predict(inputs:str, llm_kwargs:dict, plugin_kwargs:dict, chatbot:ChatBotWith if chunk: try: - if (has_choices and not choice_valid) or ('OPENROUTER PROCESSING' in chunk_decoded): - # 一些垃圾第三方接口的出现这样的错误, 或者OPENROUTER的特殊处理,因为OPENROUTER的数据流未连接到模型时会出现OPENROUTER PROCESSING + if (has_choices and not choice_valid) or chunk_decoded.startswith(':'): continue if ('data: [DONE]' not in chunk_decoded) and len(chunk_decoded) > 0 and (chunkjson is None): # 传递进来一些奇怪的东西 From fd93622840cfbf8c0c3c73d34e95dcb8a3c6af87 Mon Sep 17 00:00:00 2001 From: Southlandi <54576834+xxflzj@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:22:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGemini=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=EF=BC=88=E5=81=9C=E7=94=A8?= =?UTF-8?q?=E8=AF=8D=E6=95=B0=E9=87=8F=E4=B8=BA0=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=EF=BC=89=20(#2092)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- request_llms/com_google.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/request_llms/com_google.py b/request_llms/com_google.py index 88e094f5..afb81097 100644 --- a/request_llms/com_google.py +++ b/request_llms/com_google.py @@ -202,16 +202,29 @@ class GoogleChatInit: ) # 处理 history messages.append(self.__conversation_user(inputs, llm_kwargs, enable_multimodal_capacity)) # 处理用户对话 - payload = { - "contents": messages, - "generationConfig": { - # "maxOutputTokens": llm_kwargs.get("max_token", 1024), - "stopSequences": str(llm_kwargs.get("stop", "")).split(" "), - "temperature": llm_kwargs.get("temperature", 1), - "topP": llm_kwargs.get("top_p", 0.8), - "topK": 10, - }, - } + stop_sequences = str(llm_kwargs.get("stop", "")).split(" ") + # 过滤空字符串并确保至少有一个停止序列 + stop_sequences = [s for s in stop_sequences if s] + if not stop_sequences: + payload = { + "contents": messages, + "generationConfig": { + "temperature": llm_kwargs.get("temperature", 1), + "topP": llm_kwargs.get("top_p", 0.8), + "topK": 10, + }, + } + else: + payload = { + "contents": messages, + "generationConfig": { + # "maxOutputTokens": llm_kwargs.get("max_token", 1024), + "stopSequences": stop_sequences, + "temperature": llm_kwargs.get("temperature", 1), + "topP": llm_kwargs.get("top_p", 0.8), + "topK": 10, + }, + } return header, payload