From 00c51002e04bc67b6082b85a760e801304e1c82d 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: Fri, 13 Sep 2024 13:17:57 +0800 Subject: [PATCH] dev --- .../LunaTranslator/gui/setting_translate.py | 6 +++--- .../translator/dev_duckduckgo.py | 10 ++++++++++ LunaTranslator/files/defaultconfig/config.json | 7 +++++++ .../files/defaultconfig/translatorsetting.json | 18 ++++++++++++++++++ README.md | 2 +- 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 LunaTranslator/LunaTranslator/translator/dev_duckduckgo.py diff --git a/LunaTranslator/LunaTranslator/gui/setting_translate.py b/LunaTranslator/LunaTranslator/gui/setting_translate.py index 1b357776..73bddbbd 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_translate.py +++ b/LunaTranslator/LunaTranslator/gui/setting_translate.py @@ -63,7 +63,7 @@ def loadvisinternal(btnplus, copy): is_gpt_likes, not_is_gpt_like = splitapillm(shoufei) elif btnplus == "offline": is_gpt_likes, not_is_gpt_like = splitapillm(lixians) - elif btnplus == "develop": + elif btnplus == "dev": is_gpt_likes, not_is_gpt_like = splitapillm(develop) for _ in is_gpt_likes: @@ -289,7 +289,7 @@ def createmanybtn(self, countnum, btnplus): dynamiclink("{docs_server}/#/zh/guochandamoxing") ) ) - elif btnplus == "develop": + elif btnplus == "dev": btn.clicked.connect( lambda: gobject.baseobject.openlink( dynamiclink("{docs_server}/#/zh/tiaoshiliulanqi") @@ -548,7 +548,7 @@ def setTabTwo_lazy(self, basel): offlinegrid = initsome2(self, lixians, btnplus="offline") onlinegrid = initsome11(self, mianfei) - developgrid += initsome2(self, develop, btnplus="develop") + developgrid += initsome2(self, develop, btnplus="dev") online_reg_grid += initsome2(self, shoufei, btnplus="api") pretransgrid += initsome11(self, pre) vw, vl = getvboxwidget() diff --git a/LunaTranslator/LunaTranslator/translator/dev_duckduckgo.py b/LunaTranslator/LunaTranslator/translator/dev_duckduckgo.py new file mode 100644 index 00000000..0f64d134 --- /dev/null +++ b/LunaTranslator/LunaTranslator/translator/dev_duckduckgo.py @@ -0,0 +1,10 @@ +from translator.dev_llm_common import commonllmdev + + +class TS(commonllmdev): + target_url = "https://duckduckgo.com/?t=h_&q=hi&ia=chat" + jsfile = "commonhookfetchstream.js" + function1 = 'url.includes("duckchat/v1/chat")' + function2 = r"""thistext += (chunk.message?chunk.message:"")""" + textarea_selector = 'textarea[name="user-prompt"]' + button_selector = 'button[type="submit"]' diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 2ba575f0..21703d32 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -1647,6 +1647,13 @@ "name": "chatgpt", "is_gpt_like": true }, + "dev_duckduckgo": { + "use": false, + "color": "blue", + "type": "dev", + "name": "DuckDuckGo", + "is_gpt_like": true + }, "dev_theb": { "use": false, "color": "blue", diff --git a/LunaTranslator/files/defaultconfig/translatorsetting.json b/LunaTranslator/files/defaultconfig/translatorsetting.json index dd781568..c3362c3d 100644 --- a/LunaTranslator/files/defaultconfig/translatorsetting.json +++ b/LunaTranslator/files/defaultconfig/translatorsetting.json @@ -798,6 +798,24 @@ } } }, + "dev_duckduckgo": { + "args": { + "usingstream": true, + "use_custom_prompt": false, + "custom_prompt": "" + }, + "argstype": { + "usingstream": { + "name": "流式输出", + "type": "switch" + }, + "custom_prompt": { + "name": "自定义_promt", + "type": "multiline", + "refswitch": "use_custom_prompt" + } + } + }, "dev_theb": { "args": { "usingstream": true, diff --git a/README.md b/README.md index 94edb081..1061b130 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ - **离线翻译** 支持 **传统翻译** ( J北京7、金山快译、译典通、ezTrans、Sugoi、MT5 ) 和离线部署的 **大模型翻译** ( ChatGPT兼容接口、Sakura大模型 ) -- **Chrome调试翻译** 支持 **传统翻译** ( deepl、yandex、有道、百度、腾讯、必应、彩云、小牛、阿里、谷歌 ) 和 **大模型翻译** ( chatgpt、deepseek、moonshot、qianwen、chatglm、Theb.ai ) +- **Chrome调试翻译** 支持 **传统翻译** ( deepl、yandex、有道、百度、腾讯、必应、彩云、小牛、阿里、谷歌 ) 和 **大模型翻译** ( chatgpt、deepseek、moonshot、qianwen、chatglm、Theb.ai、DuckDuckGo ) - **预翻译** 支持读取预翻译文件,支持翻译缓存