From e5c86a212ebeb320ac3b3048099c0f4692e0d215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:47:48 +0800 Subject: [PATCH] fix --- .../LunaTranslator/translator/gptcommon.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/LunaTranslator/LunaTranslator/translator/gptcommon.py b/LunaTranslator/LunaTranslator/translator/gptcommon.py index 532fdd28..07a371e4 100644 --- a/LunaTranslator/LunaTranslator/translator/gptcommon.py +++ b/LunaTranslator/LunaTranslator/translator/gptcommon.py @@ -128,16 +128,19 @@ class gptcommon(basetrans): message.append({"role": "user", "content": query}) usingstream = self.config["流式输出"] - url = self.config["API接口地址"] - if url.endswith("/chat/completions"): - pass - else: - url = self.checkv1(url) + "/chat/completions" response = self.proxysession.post( - url, + self.createurl(), headers=self.createheaders(), params=self.createparam(), json=self.createdata(message), stream=usingstream, ) return self.commonparseresponse(query, response, usingstream) + + def createurl(self): + url = self.config["API接口地址"] + if url.endswith("/chat/completions"): + pass + else: + url = self.checkv1(url) + "/chat/completions" + return url