diff --git a/LunaTranslator/LunaTranslator/ocrengines/chatgptlike.py b/LunaTranslator/LunaTranslator/ocrengines/chatgptlike.py index dfea31c3..4b30e4b0 100644 --- a/LunaTranslator/LunaTranslator/ocrengines/chatgptlike.py +++ b/LunaTranslator/LunaTranslator/ocrengines/chatgptlike.py @@ -6,14 +6,14 @@ from myutils.proxy import getproxy def list_models(typename, regist): js = requests.get( - createurl(regist["apiurl"]())[: -len("/chat/completions")] + "/models", - headers={"Authorization": "Bearer " + regist["SECRET_KEY"]().split("|")[0]}, + createurl(regist["apiurl"]().strip())[: -len("/chat/completions")] + "/models", + headers={"Authorization": "Bearer " + regist["SECRET_KEY"]().split("|")[0].strip()}, proxies=getproxy(("ocr", typename)), timeout=10, ).json() try: - return [_["id"] for _ in js["data"]] + return sorted([_["id"] for _ in js["data"]]) except: raise Exception(js) diff --git a/LunaTranslator/LunaTranslator/ocrengines/geminiocr.py b/LunaTranslator/LunaTranslator/ocrengines/geminiocr.py index a46668d9..ffc81e9b 100644 --- a/LunaTranslator/LunaTranslator/ocrengines/geminiocr.py +++ b/LunaTranslator/LunaTranslator/ocrengines/geminiocr.py @@ -8,7 +8,7 @@ from myutils.proxy import getproxy def list_models(typename, regist): js = requests.get( "https://generativelanguage.googleapis.com/v1beta/models", - params={"key": regist["key"]().split("|")[0]}, + params={"key": regist["key"]().split("|")[0].strip()}, proxies=getproxy(("ocr", typename)), timeout=10, ).json() @@ -25,7 +25,7 @@ def list_models(typename, regist): if name.startswith("models/"): name = name[7:] mm.append(name) - return mm + return sorted(mm) class OCR(baseocr): diff --git a/LunaTranslator/LunaTranslator/translator/cohere.py b/LunaTranslator/LunaTranslator/translator/cohere.py index 2887717f..c3417676 100644 --- a/LunaTranslator/LunaTranslator/translator/cohere.py +++ b/LunaTranslator/LunaTranslator/translator/cohere.py @@ -132,7 +132,7 @@ def list_models(typename, regist): js = requests.get( "https://api.cohere.com/v1/models", headers={ - "Authorization": "Bearer " + regist["SECRET_KEY"]().split("|")[0], + "Authorization": "Bearer " + regist["SECRET_KEY"]().split("|")[0].strip(), "X-Client-Name": "my-cool-project", }, proxies=getproxy(("fanyi", typename)), @@ -148,4 +148,4 @@ def list_models(typename, regist): if "chat" not in endpoints: continue mm.append(m["name"]) - return mm + return sorted(mm) diff --git a/LunaTranslator/LunaTranslator/translator/gemini.py b/LunaTranslator/LunaTranslator/translator/gemini.py index f0a0a9a4..c0db2ea2 100644 --- a/LunaTranslator/LunaTranslator/translator/gemini.py +++ b/LunaTranslator/LunaTranslator/translator/gemini.py @@ -94,7 +94,7 @@ class TS(basetrans): def list_models(typename, regist): js = requests.get( "https://generativelanguage.googleapis.com/v1beta/models", - params={"key": regist["SECRET_KEY"]().split("|")[0]}, + params={"key": regist["SECRET_KEY"]().split("|")[0].strip()}, proxies=getproxy(("fanyi", typename)), timeout=10, ).json() @@ -111,4 +111,4 @@ def list_models(typename, regist): if name.startswith("models/"): name = name[7:] mm.append(name) - return mm + return sorted(mm) diff --git a/LunaTranslator/LunaTranslator/translator/gptcommon.py b/LunaTranslator/LunaTranslator/translator/gptcommon.py index b470a141..26664180 100644 --- a/LunaTranslator/LunaTranslator/translator/gptcommon.py +++ b/LunaTranslator/LunaTranslator/translator/gptcommon.py @@ -7,14 +7,14 @@ from myutils.proxy import getproxy def list_models(typename, regist): js = requests.get( - createurl(regist["API接口地址"]())[: -len("/chat/completions")] + "/models", - headers={"Authorization": "Bearer " + regist["SECRET_KEY"]().split("|")[0]}, + createurl(regist["API接口地址"]().strip())[: -len("/chat/completions")] + "/models", + headers={"Authorization": "Bearer " + regist["SECRET_KEY"]().split("|")[0].strip()}, proxies=getproxy(("fanyi", typename)), timeout=10, ).json() try: - return [_["id"] for _ in js["data"]] + return sorted([_["id"] for _ in js["data"]]) except: raise Exception(js) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 082e6848..13a4d8f6 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 3) +set(VERSION_PATCH 4) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)