From 6b6be0504d16701c8322355cd27a86a98a9502e9 Mon Sep 17 00:00:00 2001 From: Bo26fhmC5M <88071760+Bo26fhmC5M@users.noreply.github.com> Date: Sat, 8 Feb 2025 11:17:46 +0900 Subject: [PATCH] fix: display cached llm translations while sending message --- src/lang/en.ts | 4 ++-- src/lang/ko.ts | 4 +++- src/lang/zh-Hant.ts | 4 ++-- src/ts/translator/translator.ts | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lang/en.ts b/src/lang/en.ts index a034db13..55d99f16 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -170,7 +170,7 @@ export const languageEnglish = { summarizationPrompt: "The prompt that is used for summarization. if it is blank, it will use the default prompt. you can also use ChatML formating with {{slot}} for the chat data.", translatorPrompt: "The prompt that is used for translation. if it is blank, it will use the default prompt. you can also use ChatML formating with {{slot}} for the dest language, {{solt::content}} for the content, and {{slot::tnote}} for the translator note.", translateBeforeHTMLFormatting: "If enabled, it will translate the text before Regex scripts and HTML formatting. this could make the token lesser but could break the formatting.", - autoTranslateCachedOnly: "If enabled with Auto Translation option on, it will automatically translate only the text that the user has translated previously.", + autoTranslateCachedOnly: "If enabled with Auto Translation option on, it will automatically translate only the messages that the user has translated previously.", presetChain: "If it is not blank, the preset will be changed and applied randomly every time when user sends a message in the preset list in this input. preset list should be seperated by comma, for example, `preset1,preset2`.", legacyMediaFindings: "If enabled, it will use the old method to find media assets, without using the additional search algorithm.", comfyWorkflow: "Put the API workflow of comfy UI. you can get your API workflow in comfy UI by pressing the 'Workflow > Export (API)' button. you must also put {{risu_prompt}} in you workflow text. the {{risu_prompt}} will be replaced with the prompt provided by the Risu.", @@ -816,7 +816,7 @@ export const languageEnglish = { translateBeforeHTMLFormatting: "Translate Before HTML Formatting", retranslate: "Retranslate", loading: "Loading", - autoTranslateCachedOnly: "Auto Translate Cached Only", + autoTranslateCachedOnly: "Auto-translate Cached Messages Only", notification: "Notification", permissionDenied: "Permission Denied by Your Browser or OS", customFlags: "Custom Flags", diff --git a/src/lang/ko.ts b/src/lang/ko.ts index 9d3cfa0b..5d80ad82 100644 --- a/src/lang/ko.ts +++ b/src/lang/ko.ts @@ -123,7 +123,8 @@ export const languageKorean = { "translatorNote": "여기에서 캐릭터마다 별도의 번역 프롬프트를 넣을 수 있습니다. 해당 옵션은 Ax. model 번역을 사용할 때만 적용됩니다. 언어 설정에서 `{{slot::tnote}}`를 넣으세요. 그룹챗에서는 작동하지 않습니다.", "groupInnerFormat": "This defines a format that is used in group chat for characters that isn't speaker. if it is not blank, it will use this format instead of the default format. if `Group Other Bot Role` is `assistant`, it will also be applied to the speaker.", "groupOtherBotRole": "This defines a role that is used in group chat for characters that isn't speaker.", - "chatHTML": "A HTML that would be inserted as each chat.\n\nYou can use CBS and special tags.\n- ``: a textbox that would be used to render text\n- ``: an icon for user or assistant\n- ``: icon buttons for chat edit, translations and etc.\n- ``: generation information button." + "chatHTML": "A HTML that would be inserted as each chat.\n\nYou can use CBS and special tags.\n- ``: a textbox that would be used to render text\n- ``: an icon for user or assistant\n- ``: icon buttons for chat edit, translations and etc.\n- ``: generation information button.", + "autoTranslateCachedOnly": "자동 번역 옵션이 켜진 상태에서 활성화하면, 사용자가 이전에 번역한 메시지만 자동으로 번역됩니다.", }, "setup": { "chooseProvider": "AI 제공자를 선택해 주세요", @@ -767,4 +768,5 @@ export const languageKorean = { "translateBeforeHTMLFormatting": "HTML 포맷 전 번역", "retranslate": "다시 번역", "loading": "로딩중", + "autoTranslateCachedOnly": "캐시된 메시지만 자동 번역", } \ No newline at end of file diff --git a/src/lang/zh-Hant.ts b/src/lang/zh-Hant.ts index fb386234..48de6e93 100644 --- a/src/lang/zh-Hant.ts +++ b/src/lang/zh-Hant.ts @@ -129,7 +129,7 @@ export const languageChineseTraditional = { "summarizationPrompt": "用於摘要的提示詞。留空將使用預設提示詞。您也可以使用包含 {{slot}} 的 ChatML 格式來處理聊天數據。", "translatorPrompt": "用於翻譯的提示詞。留空將使用默認提示。您還可以使用帶有 {{slot}} 的 ChatML 格式表示目標語言:用 {{slot::content}} 表示內容,用 {{slot::tnote}} 表示翻譯註釋。", "translateBeforeHTMLFormatting": "啟用後,將在正規表達式和 HTML 格式化之前翻譯文本。這可能減少 Token 數,但可能破壞格式。", - "autoTranslateCachedOnly": "啟用後,僅會自動翻譯使用者之前已翻譯的內容。", + "autoTranslateCachedOnly": "啟用自動翻譯選項時,將只自動翻譯使用者先前已翻譯過的訊息。", "presetChain": "若欄位不為空,則每次使用者發送訊息時,系統會從此輸入中的預設列表中隨機變更並應用預設設定。預設列表應以逗號分隔,例如 `preset1,preset2`。", "legacyMediaFindings": "啟用後,將使用舊版方法尋找媒體資源,而不使用額外的搜尋演算法。", "comfyWorkflow": "請輸入 Comfy UI 的 API 工作流程。您可以在 Comfy UI 中點選「Workflow > Export (API)」按鈕以取得您的 API 工作流程。此外,您必須在工作流程文本中加入 {{risu_prompt}},該佔位符將被 Risu 提供的提示詞替換。", @@ -777,7 +777,7 @@ export const languageChineseTraditional = { "translateBeforeHTMLFormatting": "於 HTML 格式化前翻譯", "retranslate": "重新翻譯", "loading": "載入中", - "autoTranslateCachedOnly": "僅自動翻譯已快取的內容", + "autoTranslateCachedOnly": "僅自動翻譯已快取訊息", "notification": "使用系統通知", "permissionDenied": "權限被您的瀏覽器或操作系統拒絕", "customFlags": "自定義修飾詞(Flags)", diff --git a/src/ts/translator/translator.ts b/src/ts/translator/translator.ts index 542aae0b..1194ac4b 100644 --- a/src/ts/translator/translator.ts +++ b/src/ts/translator/translator.ts @@ -231,7 +231,9 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl let DoingChat = get(doingChat) if(DoingChat){ if(isExpTranslator()){ - return html + if(!(db.translatorType === 'llm' && await getLLMCache(html) !== null)){ + return html + } } } if(db.translatorType === 'llm'){