From cab1a008e702ad54e412a7f42e5f5f39fb2495a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:35:20 +0800 Subject: [PATCH] chatgpt --- .../LunaTranslator/translator/dev_chatgpt.py | 33 ++++--------------- .../defaultconfig/translatorsetting.json | 12 ------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py b/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py index 2f2b2dd9..f965169e 100644 --- a/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py +++ b/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py @@ -54,31 +54,10 @@ class TS(basetransdev): r"""document.querySelector("#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main > div.flex.h-full.flex-col > div.w-full.pt-2.md\\:pt-0.dark\\:border-white\\/20.md\\:border-transparent.md\\:dark\\:border-transparent.md\\:w-\\[calc\\(100\\%-\\.5rem\\)\\] > form > div > div.flex.w-full.items-center > div > button").click()""" ) - if self.config["流式输出"] == False: + currtext = "" + while True: + time.sleep(0.01) # get text before violate usage policies. - self.wait_for_result( - r"""document.querySelector("#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main > div.flex.h-full.flex-col > div.flex-1.overflow-hidden > div > div > div > div > div:nth-child({}) > div > div > div.relative.flex.w-full.flex-col.agent-turn > div.flex-col.gap-1.md\\:gap-3 > div.mt-1.flex.justify-start.gap-3.empty\\:hidden > div > span > button").innerHTML""".format( - idx + 2 - ), - None, - ) # copy button - - yield self.getcurr(idx) - else: - currtext = "" - tutuku = True - while tutuku: - time.sleep(0.01) # get text before violate usage policies. - - tutuku = ( - "value" - in self.Runtime_evaluate( - r"""document.querySelector("#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main > div.flex.h-full.flex-col > div.flex-1.overflow-hidden > div > div > div > div > div:nth-child({}) > div > div > div.relative.flex.w-full.flex-col.agent-turn > div.flex-col.gap-1.md\\:gap-3 > div.mt-1.flex.justify-start.gap-3.empty\\:hidden > div > span > button")""".format( - idx + 2 - ) - )["result"] - ) - - newcurr = self.getcurr(idx) - yield newcurr[len(currtext) :] - currtext = newcurr + newcurr = self.getcurr(idx) + yield newcurr[len(currtext) :] + currtext = newcurr diff --git a/LunaTranslator/files/defaultconfig/translatorsetting.json b/LunaTranslator/files/defaultconfig/translatorsetting.json index 7aea1823..0ce046f3 100644 --- a/LunaTranslator/files/defaultconfig/translatorsetting.json +++ b/LunaTranslator/files/defaultconfig/translatorsetting.json @@ -4,18 +4,6 @@ "host": "translate.plausibility.cloud" } }, - - "dev_chatgpt":{ - "args":{ - "流式输出":false - }, - "argstype":{ - "流式输出":{ - "type": "switch" - } - } - }, - "baiduapi": { "args": { "注册网址": "https://fanyi-api.baidu.com/api/trans/product/desktop",