diff --git a/LunaTranslator/LunaTranslator/translator/claude.py b/LunaTranslator/LunaTranslator/translator/claude.py index d92aa57f..ed1162ed 100644 --- a/LunaTranslator/LunaTranslator/translator/claude.py +++ b/LunaTranslator/LunaTranslator/translator/claude.py @@ -48,7 +48,7 @@ class TS(basetrans): stream=usingstream, ) response = self.proxysession.post( - urlpathjoin(checkv1(self.config["BASE_URL"]), "messages"), + urlpathjoin(checkv1(self.config["BASE_URL"].strip()), "messages"), headers=headers, json=data, stream=usingstream, diff --git a/LunaTranslator/LunaTranslator/translator/gemini.py b/LunaTranslator/LunaTranslator/translator/gemini.py index 051ad932..9604cc04 100644 --- a/LunaTranslator/LunaTranslator/translator/gemini.py +++ b/LunaTranslator/LunaTranslator/translator/gemini.py @@ -62,7 +62,7 @@ class TS(basetrans): payload = {**contents, **safety, **sys_message, **gen_config} res = self.proxysession.post( urlpathjoin( - self.config["BASE_URL"], + self.config["BASE_URL"].strip(), f"v1beta/models/{model}:{['generateContent','streamGenerateContent'][usingstream]}", ), params={"key": self.multiapikeycurrent["SECRET_KEY"]}, diff --git a/LunaTranslator/LunaTranslator/translator/gptcommon.py b/LunaTranslator/LunaTranslator/translator/gptcommon.py index 55e97bfd..61b2ab62 100644 --- a/LunaTranslator/LunaTranslator/translator/gptcommon.py +++ b/LunaTranslator/LunaTranslator/translator/gptcommon.py @@ -25,7 +25,9 @@ def list_models(typename, regist): class gptcommon(basetrans): @property def apiurl(self): - return self.config.get("API接口地址", self.config.get("OPENAI_API_BASE", "")) + return self.config.get( + "API接口地址", self.config.get("OPENAI_API_BASE", "") + ).strip() def langmap(self): return createenglishlangmap() @@ -86,7 +88,8 @@ class gptcommon(basetrans): break try: json_data = json.loads(response_data) - + if len(json_data["choices"]) == 0: + continue msg = json_data["choices"][0].get("delta", {}).get("content", None) if msg: message += msg @@ -124,6 +127,7 @@ class gptcommon(basetrans): if prefill: message.append({"role": "assistant", "content": prefill}) usingstream = self.config["流式输出"] + print(self.createurl()) response = self.proxysession.post( self.createurl(), headers=self.createheaders(), diff --git a/docs/en/guochandamoxing.md b/docs/en/guochandamoxing.md index e7514e75..d24bf862 100644 --- a/docs/en/guochandamoxing.md +++ b/docs/en/guochandamoxing.md @@ -57,7 +57,9 @@ ### **Azure** -https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#completions +**API Endpoint URL** `https://{endpoint}.openai.azure.com/openai/deployments/{deployName}/chat/completions?api-version=2023-12-01-preview` + +Replace `{endpoint}` and `{deployName}` with your endpoint and deployName. diff --git a/docs/ru/guochandamoxing.md b/docs/ru/guochandamoxing.md index 6285a361..1f0be8c3 100644 --- a/docs/ru/guochandamoxing.md +++ b/docs/ru/guochandamoxing.md @@ -57,7 +57,9 @@ ### **Azure** -https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#completions +**Адрес API интерфейса** `https://{endpoint}.openai.azure.com/openai/deployments/{deployName}/chat/completions?api-version=2023-12-01-preview` + +Замените `{endpoint}` и `{deployName}` на ваш endpoint и deployName. diff --git a/docs/zh/guochandamoxing.md b/docs/zh/guochandamoxing.md index 6e0d29ce..e226864c 100644 --- a/docs/zh/guochandamoxing.md +++ b/docs/zh/guochandamoxing.md @@ -59,7 +59,9 @@ ### **Azure** -https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#completions +**API接口地址** `https://{endpoint}.openai.azure.com/openai/deployments/{deployName}/chat/completions?api-version=2023-12-01-preview` + +其中,将`{endpoint}`和`{deployName}`替换成你的endpoint和deployName diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 4ccb58a6..b443f554 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 43) -set(VERSION_PATCH 1) +set(VERSION_PATCH 2) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)