issues/719

This commit is contained in:
恍兮惚兮 2024-05-06 17:42:40 +08:00
parent bea704ca6c
commit d648913f66
2 changed files with 23 additions and 16 deletions

View File

@ -59,6 +59,8 @@ def timeoutfunction(
class basetrans(commonbase):
def langmap(self):
# The mapping between standard language code and API language code, if not declared, defaults to using standard language code.
# But the exception is cht. If api support cht, if must be explicitly declared the support of cht, otherwise it will translate to chs and then convert to cht.
return {}
def inittranslator(self):
@ -159,13 +161,17 @@ class basetrans(commonbase):
@property
def is_gpt_like(self):
try:
return globalconfig["fanyi"][self.typename]["is_gpt_like"]
except:
return False
# Don't use short-term cache, only use long-term cache, useful for gpt like apis to modify prompt
return globalconfig["fanyi"][self.typename].get("is_gpt_like", False)
@property
def onlymanual(self):
# Only used during manual translation, not used during automatic translation
return globalconfig["fanyi"][self.typename].get("manual", False)
@property
def needzhconv(self):
# The API does not support direct translation to Traditional Chinese, only Simplified Chinese can be translated first and then converted to Traditional Chinese
l = static_data["language_list_translator_inner"][globalconfig["tgtlang3"]]
return l == "cht" and "cht" not in self.langmap()
@ -175,6 +181,7 @@ class basetrans(commonbase):
@property
def transtype(self):
# free/dev/api/offline/pre
return globalconfig["fanyi"][self.typename].get("type", "free")
def gettask(self, content):
@ -263,12 +270,6 @@ class basetrans(commonbase):
return res
@property
def onlymanual(self):
if "manual" not in globalconfig["fanyi"][self.typename]:
return False
return globalconfig["fanyi"][self.typename]["manual"]
def _iterget(self, __callback, rid, __res):
succ = True
for i, _res in enumerate(__res):

View File

@ -984,7 +984,8 @@
"type": "api",
"use": false,
"color": "blue",
"name": "gemini"
"name": "gemini",
"is_gpt_like": true
},
"jb7": {
"type": "offline",
@ -1159,13 +1160,15 @@
"type": "api",
"use": false,
"color": "blue",
"name": "cohere"
"name": "cohere",
"is_gpt_like": true
},
"claude": {
"type": "api",
"use": false,
"color": "blue",
"name": "claude"
"name": "claude",
"is_gpt_like": true
},
"chatgpt-3rd-party": {
"type": "api",
@ -1204,19 +1207,22 @@
"use": false,
"type": "offline",
"color": "blue",
"name": "Sakura大模型"
"name": "Sakura大模型",
"is_gpt_like": true
},
"chatgpt-offline": {
"use": false,
"type": "offline",
"color": "blue",
"name": "ChatGPT_离线"
"name": "ChatGPT_离线",
"is_gpt_like": true
},
"TGW": {
"use": false,
"type": "offline",
"color": "blue",
"name": "TGW语言模型"
"name": "TGW语言模型",
"is_gpt_like": true
}
},
"magpiepath": "",