diff --git a/src/app/api/translate-note/route.ts b/src/app/api/translate-note/route.ts index bf7244c4..39a696d4 100644 --- a/src/app/api/translate-note/route.ts +++ b/src/app/api/translate-note/route.ts @@ -41,7 +41,6 @@ const translationChains = new Map() const getOriginalTranslation = async ( cid: string, targetLang: Language, - originalLang?: Language, ): Promise => { if (!translationModel4K || !translationModel16K) return @@ -50,14 +49,6 @@ const getOriginalTranslation = async ( await fetch(toGateway(`ipfs://${cid}`)) ).json() - // If the detected language is the same as the target language, return the original content - if (originalLang === targetLang) { - console.warn( - `|__ Warn: Detected language is the same as the target language, return the original content: ${cid}, ${targetLang}`, - ) - return - } - console.time(`fetching translation ${cid}, ${targetLang}`) const { modelSize, tokens } = llmModelSwitcherByTextLength(content, { includeResponse: { lang: targetLang }, @@ -73,10 +64,30 @@ const getOriginalTranslation = async ( let chain = translationChains.get(`${modelSize}_${targetLang}`) if (!chain) { + const template = ` +You are a Markdown translation expert. During the translation process, you need to pay special attention to maintaining the integrity of all Markdown syntax and tags, and not changing the function of HTML tags, to ensure that the translated content does not affect the rendering of any syntax or tags. Please follow the following rules to translate: + +1. Identify and translate text content: Only identify and translate plain text content in Markdown, including text in headings, paragraphs, and list items. + +2. Retain tags and attributes: When encountering HTML tags (such as ,