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