mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
azure
This commit is contained in:
parent
438222e9db
commit
4259e235c6
@ -39,9 +39,6 @@ class OCR(baseocr):
|
||||
)
|
||||
return data
|
||||
|
||||
def createparam(self):
|
||||
return None
|
||||
|
||||
def createheaders(self):
|
||||
return {"Authorization": "Bearer " + self.config["SECRET_KEY"]}
|
||||
|
||||
@ -93,7 +90,6 @@ class OCR(baseocr):
|
||||
response = self.proxysession.post(
|
||||
self.createurl(),
|
||||
headers=self.createheaders(),
|
||||
params=self.createparam(),
|
||||
json=self.createdata(message),
|
||||
)
|
||||
try:
|
||||
|
14
LunaTranslator/LunaTranslator/translator/azureopenai.py
Normal file
14
LunaTranslator/LunaTranslator/translator/azureopenai.py
Normal file
@ -0,0 +1,14 @@
|
||||
from translator.gptcommon import gptcommon
|
||||
|
||||
|
||||
class TS(gptcommon):
|
||||
def createurl(self):
|
||||
return f'https://{self.config["endpoint"]}/openai/deployments/{self.config["deployment-id"]}/completions?api-version={self.config["api-version"]}'
|
||||
|
||||
def createheaders(self):
|
||||
_ = super().createheaders()
|
||||
_.update({"api-key": self.multiapikeycurrent["api-key"]})
|
||||
|
||||
def translate(self, query):
|
||||
self.checkempty(["api-key", "api-version", "endpoint", "deployment-id"])
|
||||
return super().translate(query)
|
@ -1,25 +0,0 @@
|
||||
from translator.gptcommon import gptcommon
|
||||
|
||||
|
||||
class TS(gptcommon):
|
||||
def createurl(self):
|
||||
return self.config["OPENAI_API_BASE"] + self.config["Appedix"]
|
||||
|
||||
def createparam(self):
|
||||
api_type = self.config["api_type"]
|
||||
if api_type in [1, 2]:
|
||||
api_version = "2023-05-15"
|
||||
return {"api-version": api_version}
|
||||
else:
|
||||
return super().createparam()
|
||||
|
||||
def createheaders(self):
|
||||
api_type = self.config["api_type"]
|
||||
_ = super().createheaders()
|
||||
if api_type == 1: # azure
|
||||
_.update({"api-key": self.multiapikeycurrent["SECRET_KEY"]})
|
||||
return _
|
||||
|
||||
def translate(self, query):
|
||||
self.checkempty(["SECRET_KEY", "model"])
|
||||
return super().translate(query)
|
@ -50,9 +50,6 @@ class gptcommon(basetrans):
|
||||
pass
|
||||
return data
|
||||
|
||||
def createparam(self):
|
||||
return None
|
||||
|
||||
def createheaders(self):
|
||||
return {"Authorization": "Bearer " + self.multiapikeycurrent["SECRET_KEY"]}
|
||||
|
||||
@ -158,7 +155,6 @@ class gptcommon(basetrans):
|
||||
response = self.proxysession.post(
|
||||
self.createurl(),
|
||||
headers=self.createheaders(),
|
||||
params=self.createparam(),
|
||||
json=self.createdata(message),
|
||||
stream=usingstream,
|
||||
)
|
||||
|
@ -1561,6 +1561,13 @@
|
||||
}
|
||||
},
|
||||
"fanyi": {
|
||||
"chatgpt-3rd-party": {
|
||||
"type": "api",
|
||||
"use": false,
|
||||
"color": "blue",
|
||||
"name": "ChatGPT_兼容接口",
|
||||
"is_gpt_like": true
|
||||
},
|
||||
"microsoft": {
|
||||
"use": false,
|
||||
"color": "gray",
|
||||
@ -1932,11 +1939,11 @@
|
||||
"color": "blue",
|
||||
"name": "有道api"
|
||||
},
|
||||
"chatgpt": {
|
||||
"azureopenai": {
|
||||
"type": "api",
|
||||
"use": false,
|
||||
"color": "blue",
|
||||
"name": "ChatGPT",
|
||||
"name": "Azure Openai",
|
||||
"is_gpt_like": true
|
||||
},
|
||||
"cohere": {
|
||||
@ -1953,13 +1960,6 @@
|
||||
"name": "claude",
|
||||
"is_gpt_like": true
|
||||
},
|
||||
"chatgpt-3rd-party": {
|
||||
"type": "api",
|
||||
"use": false,
|
||||
"color": "blue",
|
||||
"name": "ChatGPT_兼容接口",
|
||||
"is_gpt_like": true
|
||||
},
|
||||
"hanshant": {
|
||||
"type": "offline",
|
||||
"use": false,
|
||||
|
@ -209,20 +209,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"chatgpt": {
|
||||
"azureopenai": {
|
||||
"args": {
|
||||
"SECRET_KEY": "",
|
||||
"api-key": "",
|
||||
"Temperature": 0.3,
|
||||
"top_p": 0.3,
|
||||
"max_tokens": 128,
|
||||
"frequency_penalty": 0,
|
||||
"model": "gpt-3.5-turbo",
|
||||
"附带上下文个数": 0,
|
||||
"OPENAI_API_BASE": "https://api.openai.com/v1",
|
||||
"Appedix": "/chat/completions",
|
||||
"endpoint": "https://your-resource-name.openai.azure.com",
|
||||
"deployment-id":"",
|
||||
"api-version":"2024-06-01",
|
||||
"使用自定义promt": false,
|
||||
"自定义promt": "",
|
||||
"api_type": 0,
|
||||
"流式输出": true,
|
||||
"user_user_prompt": "{sentence}",
|
||||
"use_user_user_prompt": false,
|
||||
@ -245,12 +245,15 @@
|
||||
"type": "split",
|
||||
"rank": 2.5
|
||||
},
|
||||
"OPENAI_API_BASE": {
|
||||
"endpoint": {
|
||||
"rank": 0
|
||||
},
|
||||
"Appedix": {
|
||||
"deployment-id": {
|
||||
"rank": 1
|
||||
},
|
||||
"api-version": {
|
||||
"rank": 1.5
|
||||
},
|
||||
"model": {
|
||||
"rank": 2
|
||||
},
|
||||
@ -282,16 +285,7 @@
|
||||
"type": "switch",
|
||||
"rank": 3
|
||||
},
|
||||
"api_type": {
|
||||
"type": "combo",
|
||||
"rank": 1.5,
|
||||
"list": [
|
||||
"open_ai",
|
||||
"azure",
|
||||
"azure_ad"
|
||||
]
|
||||
},
|
||||
"SECRET_KEY": {
|
||||
"api-key": {
|
||||
"rank": 1.6
|
||||
},
|
||||
"附带上下文个数": {
|
||||
|
@ -132,6 +132,10 @@
|
||||
|
||||
**model** https://docs.cohere.com/docs/models
|
||||
|
||||
### **Azure**
|
||||
|
||||
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#completions
|
||||
|
||||
<!-- tabs:end -->
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user