Fix #1110: [BUG] improve the speed when skip language#1285
Fix #1110: [BUG] improve the speed when skip language#1285JiwaniZakir wants to merge 1 commit intomengxi-ream:mainfrom
Conversation
When skip-language is on with LLM detection mode, avoid an extra LLM API call by using franc (enableLLM: false) for the language skip check whenever the translation provider itself is LLM-based, since the translation prompt already handles source language detection. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Contributor trust score15/100 — New contributor This score estimates contributor familiarity with Outcome
Score breakdown
Signals used
Policy
Updated automatically when the PR changes or when a maintainer reruns the workflow. |
|
The optimization makes sense — if the translation LLM already determines language as part of its prompt, the pre-flight |
|
wait I found you are trying to solve #1110. This actually is not the best solution. will create another PR for that |
Closes #1110
Type of Changes
Description
When the "skip language" feature was enabled with LLM language detection and an LLM translation provider,
shouldSkipByLanguagewas making a separate LLM API call to detect the language of every paragraph before translation. This was redundant because the LLM translation prompt already handles language detection internally, resulting in two LLM API calls per paragraph.The fix is in
src/utils/host/translate/translate-variants.tsinsidetranslateTextUsingPageConfig. TheenableLLMflag passed toshouldSkipByLanguage(and ultimately todetectLanguage) is now conditioned on whether the active translation provider is non-LLM:This implements the exact behavior described in the issue:
franconly (enableLLM: false) — no redundant API callmicrosoft-translate-default): LLM detection is still used (enableLLM: true)francRelated Issue
Closes #
How Has This Been Tested?
Two new unit tests added in
src/utils/host/__tests__/translate-text.test.tsxunder"skip language detection with LLM translation provider":openai-default) + LLM detection mode +skipLanguages: ["jpn"]: assertsdetectLanguageis called with{ enableLLM: false }.microsoft-translate-default) + LLM detection mode +skipLanguages: ["jpn"]: assertsdetectLanguageis called with{ enableLLM: true }.Both tests use a 14-character Japanese string that falls in the range
>= MIN_LENGTH_FOR_SKIP_LLM_DETECTION (10)and< MIN_LENGTH_FOR_TARGET_LANG_DETECTION (50), ensuring onlyshouldSkipByLanguagetriggersdetectLanguage, notisTextAlreadyInTargetLanguage.Screenshots
N/A
Checklist
Additional Information
isLLMProviderConfig(imported from@/types/config/provider) is used to determine whether the resolvedproviderConfigis LLM-based, keeping the logic consistent with how provider types are already distinguished elsewhere in the codebase.This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.
Summary by cubic
Speeds up page translation when “skip languages” is enabled by avoiding redundant LLM language detection with LLM translation providers. Fixes #1110 and removes one LLM API call per paragraph.
openai-default): skip-language check usesfranconly (no extra LLM call).microsoft-translate-default): still uses LLM detection.franc-only detection and “skip languages” off remain unchanged.enableLLMbehavior.Written for commit e430f9b. Summary will update on new commits.