This commit is contained in:
恍兮惚兮 2024-07-19 15:57:39 +08:00
parent 44c79512d7
commit a903acb75b

View File

@ -29,6 +29,8 @@ class gptcommon(basetrans):
super().__init__(typename)
def createurl(self):
if self.config["API接口地址"].endswith("/chat/completions"):
return self.config["API接口地址"]
return self.checkv1(self.config["API接口地址"]) + "/chat/completions"
def createparam(self):
@ -37,12 +39,16 @@ class gptcommon(basetrans):
def createheaders(self):
return {"Authorization": "Bearer " + self.multiapikeycurrent["SECRET_KEY"]}
def checkv1(self, api_url):
if api_url[-4:] == "/v1/":
def checkv1(self, api_url: str):
# 傻逼豆包大模型是非要v3不是v1
if api_url.endswith("/v3"):
return api_url
if api_url.endswith("/v1/"):
api_url = api_url[:-1]
elif api_url[-3:] == "/v1":
elif api_url.endswith("/v1"):
pass
elif api_url[-1] == "/":
elif api_url.endswith("/"):
api_url += "v1"
else:
api_url += "/v1"