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): class basetrans(commonbase):
def langmap(self): 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 {} return {}
def inittranslator(self): def inittranslator(self):
@ -159,13 +161,17 @@ class basetrans(commonbase):
@property @property
def is_gpt_like(self): def is_gpt_like(self):
try: # Don't use short-term cache, only use long-term cache, useful for gpt like apis to modify prompt
return globalconfig["fanyi"][self.typename]["is_gpt_like"] return globalconfig["fanyi"][self.typename].get("is_gpt_like", False)
except:
return False @property
def onlymanual(self):
# Only used during manual translation, not used during automatic translation
return globalconfig["fanyi"][self.typename].get("manual", False)
@property @property
def needzhconv(self): 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"]] l = static_data["language_list_translator_inner"][globalconfig["tgtlang3"]]
return l == "cht" and "cht" not in self.langmap() return l == "cht" and "cht" not in self.langmap()
@ -175,6 +181,7 @@ class basetrans(commonbase):
@property @property
def transtype(self): def transtype(self):
# free/dev/api/offline/pre
return globalconfig["fanyi"][self.typename].get("type", "free") return globalconfig["fanyi"][self.typename].get("type", "free")
def gettask(self, content): def gettask(self, content):
@ -263,12 +270,6 @@ class basetrans(commonbase):
return res 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): def _iterget(self, __callback, rid, __res):
succ = True succ = True
for i, _res in enumerate(__res): for i, _res in enumerate(__res):

View File

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