This commit is contained in:
恍兮惚兮 2024-10-18 16:24:00 +08:00
parent f42f2edeee
commit 0a3ac492f3
7 changed files with 18 additions and 8 deletions

View File

@ -48,7 +48,7 @@ class TS(basetrans):
stream=usingstream, stream=usingstream,
) )
response = self.proxysession.post( response = self.proxysession.post(
urlpathjoin(checkv1(self.config["BASE_URL"]), "messages"), urlpathjoin(checkv1(self.config["BASE_URL"].strip()), "messages"),
headers=headers, headers=headers,
json=data, json=data,
stream=usingstream, stream=usingstream,

View File

@ -62,7 +62,7 @@ class TS(basetrans):
payload = {**contents, **safety, **sys_message, **gen_config} payload = {**contents, **safety, **sys_message, **gen_config}
res = self.proxysession.post( res = self.proxysession.post(
urlpathjoin( urlpathjoin(
self.config["BASE_URL"], self.config["BASE_URL"].strip(),
f"v1beta/models/{model}:{['generateContent','streamGenerateContent'][usingstream]}", f"v1beta/models/{model}:{['generateContent','streamGenerateContent'][usingstream]}",
), ),
params={"key": self.multiapikeycurrent["SECRET_KEY"]}, params={"key": self.multiapikeycurrent["SECRET_KEY"]},

View File

@ -25,7 +25,9 @@ def list_models(typename, regist):
class gptcommon(basetrans): class gptcommon(basetrans):
@property @property
def apiurl(self): 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): def langmap(self):
return createenglishlangmap() return createenglishlangmap()
@ -86,7 +88,8 @@ class gptcommon(basetrans):
break break
try: try:
json_data = json.loads(response_data) json_data = json.loads(response_data)
if len(json_data["choices"]) == 0:
continue
msg = json_data["choices"][0].get("delta", {}).get("content", None) msg = json_data["choices"][0].get("delta", {}).get("content", None)
if msg: if msg:
message += msg message += msg
@ -124,6 +127,7 @@ class gptcommon(basetrans):
if prefill: if prefill:
message.append({"role": "assistant", "content": prefill}) message.append({"role": "assistant", "content": prefill})
usingstream = self.config["流式输出"] usingstream = self.config["流式输出"]
print(self.createurl())
response = self.proxysession.post( response = self.proxysession.post(
self.createurl(), self.createurl(),
headers=self.createheaders(), headers=self.createheaders(),

View File

@ -57,7 +57,9 @@
### **Azure** ### **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.
<!-- tabs:end --> <!-- tabs:end -->

View File

@ -57,7 +57,9 @@
### **Azure** ### **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.
<!-- tabs:end --> <!-- tabs:end -->

View File

@ -59,7 +59,9 @@
### **Azure** ### **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
<!-- tabs:end --> <!-- tabs:end -->

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 5) set(VERSION_MAJOR 5)
set(VERSION_MINOR 43) set(VERSION_MINOR 43)
set(VERSION_PATCH 1) set(VERSION_PATCH 2)
add_library(pch pch.cpp) add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h) target_precompile_headers(pch PUBLIC pch.h)