diff --git a/LunaTranslator/LunaTranslator/ocrengines/chatgptlike.py b/LunaTranslator/LunaTranslator/ocrengines/chatgptlike.py index edd6ddc3..dfea31c3 100644 --- a/LunaTranslator/LunaTranslator/ocrengines/chatgptlike.py +++ b/LunaTranslator/LunaTranslator/ocrengines/chatgptlike.py @@ -9,6 +9,7 @@ def list_models(typename, regist): createurl(regist["apiurl"]())[: -len("/chat/completions")] + "/models", headers={"Authorization": "Bearer " + regist["SECRET_KEY"]().split("|")[0]}, proxies=getproxy(("ocr", typename)), + timeout=10, ).json() try: diff --git a/LunaTranslator/LunaTranslator/ocrengines/geminiocr.py b/LunaTranslator/LunaTranslator/ocrengines/geminiocr.py index 6d94b803..a46668d9 100644 --- a/LunaTranslator/LunaTranslator/ocrengines/geminiocr.py +++ b/LunaTranslator/LunaTranslator/ocrengines/geminiocr.py @@ -10,6 +10,7 @@ def list_models(typename, regist): "https://generativelanguage.googleapis.com/v1beta/models", params={"key": regist["key"]().split("|")[0]}, proxies=getproxy(("ocr", typename)), + timeout=10, ).json() try: models = js["models"] diff --git a/LunaTranslator/LunaTranslator/requests.py b/LunaTranslator/LunaTranslator/requests.py index b1ef1cc4..808904a4 100644 --- a/LunaTranslator/LunaTranslator/requests.py +++ b/LunaTranslator/LunaTranslator/requests.py @@ -265,8 +265,6 @@ class Requester_common: headers["Content-Type"] = contenttype proxy = proxies.get(scheme, None) if proxies else None proxy = None if proxy == "" else proxy - if timeout is None: - timeout = 10 if timeout: if isinstance(timeout, (float, int)): timeout = int(timeout * 1000) # convert to milliseconds diff --git a/LunaTranslator/LunaTranslator/translator/cohere.py b/LunaTranslator/LunaTranslator/translator/cohere.py index b75d27f7..2887717f 100644 --- a/LunaTranslator/LunaTranslator/translator/cohere.py +++ b/LunaTranslator/LunaTranslator/translator/cohere.py @@ -136,6 +136,7 @@ def list_models(typename, regist): "X-Client-Name": "my-cool-project", }, proxies=getproxy(("fanyi", typename)), + timeout=10, ).json() try: models = js["models"] diff --git a/LunaTranslator/LunaTranslator/translator/gemini.py b/LunaTranslator/LunaTranslator/translator/gemini.py index 9b57205a..f0a0a9a4 100644 --- a/LunaTranslator/LunaTranslator/translator/gemini.py +++ b/LunaTranslator/LunaTranslator/translator/gemini.py @@ -96,6 +96,7 @@ def list_models(typename, regist): "https://generativelanguage.googleapis.com/v1beta/models", params={"key": regist["SECRET_KEY"]().split("|")[0]}, proxies=getproxy(("fanyi", typename)), + timeout=10, ).json() try: models = js["models"] diff --git a/LunaTranslator/LunaTranslator/translator/gptcommon.py b/LunaTranslator/LunaTranslator/translator/gptcommon.py index 914c0301..31072dd6 100644 --- a/LunaTranslator/LunaTranslator/translator/gptcommon.py +++ b/LunaTranslator/LunaTranslator/translator/gptcommon.py @@ -10,6 +10,7 @@ def list_models(typename, regist): createurl(regist["API接口地址"]())[: -len("/chat/completions")] + "/models", headers={"Authorization": "Bearer " + regist["SECRET_KEY"]().split("|")[0]}, proxies=getproxy(("fanyi", typename)), + timeout=10, ).json() try: @@ -51,7 +52,7 @@ class gptcommon(basetrans): def createheaders(self): _ = {"Authorization": "Bearer " + self.multiapikeycurrent["SECRET_KEY"]} - if "openai.azure.com/openai/deployments/" in self.config["API接口地址"]: + if "openai.azure.com/openai/deployments/" in self.config("API接口地址", ""): _.update({"api-key": self.multiapikeycurrent["SECRET_KEY"]}) return _ diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index b108989f..fbe1fcdd 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 34) -set(VERSION_PATCH 1) +set(VERSION_PATCH 2) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)