fix: display cached llm translations while sending message (#751)

# PR Checklist
- [x] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [x] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Description
This PR introduces fix: display cached llm translations while sending
message
This commit is contained in:
kwaroran
2025-02-09 16:24:12 +09:00
committed by GitHub
4 changed files with 10 additions and 6 deletions

View File

@@ -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",

View File

@@ -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- `<risutextbox>`: a textbox that would be used to render text\n- `<risuicon>`: an icon for user or assistant\n- `<risubuttons>`: icon buttons for chat edit, translations and etc.\n- `<risugeninfo>`: generation information button."
"chatHTML": "A HTML that would be inserted as each chat.\n\nYou can use CBS and special tags.\n- `<risutextbox>`: a textbox that would be used to render text\n- `<risuicon>`: an icon for user or assistant\n- `<risubuttons>`: icon buttons for chat edit, translations and etc.\n- `<risugeninfo>`: generation information button.",
"autoTranslateCachedOnly": "자동 번역 옵션이 켜진 상태에서 활성화하면, 사용자가 이전에 번역한 메시지만 자동으로 번역됩니다.",
},
"setup": {
"chooseProvider": "AI 제공자를 선택해 주세요",
@@ -767,6 +768,7 @@ export const languageKorean = {
"translateBeforeHTMLFormatting": "HTML 포맷 전 번역",
"retranslate": "다시 번역",
"loading": "로딩중",
"autoTranslateCachedOnly": "캐시된 메시지만 자동 번역",
"hypaV3Settings": {
"descriptionLabel": "HypaMemory V3는 요약과 벡터 검색을 모두 사용하는 장기 기억 시스템입니다.",
"supaMemoryPromptPlaceHolder": "기본값을 사용하려면 비워두세요",

View File

@@ -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",

View File

@@ -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'){