Repository navigation
fix(translation): 百度限流重试后仍保持请求间隔 - #53
Closed
cursor[bot] wants to merge 3 commits into
Closed
cursor[bot] wants to merge 3 commits into
cursor[bot] wants to merge 3 commits into
Conversation
新增百度开放平台(APP ID + 密钥,MD5 签名、按字节分片、串行限流重试)与必应免费接口(无需密钥、批量请求、实体与换行恢复)两种翻译服务,并在设置页提供服务选项、凭据字段与提示。 缓存键按百度 APP ID 隔离且不改变其他服务的既有缓存;术语表仍只支持 AI 服务。补充提供商单元回归与文档。
必应改为直接发送原文,只对出参做一次 HTML 实体解码,避免 `<b>bold</b>` 这类文本被标签对齐器吞词;百度串行队列补约 1 秒间隔,减少 54003 频控重试。 回归补充 54003 重试、请求间隔与原文请求体断言,文档同步。
54003 等可重试错误原先包在同一次排队任务里,1 秒间隔只在任务开始时计算, 重试一返回下一段就会立刻发出。改为每次实际请求单独占队列,重试等待放在队列外。 Co-authored-by: zilorn <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解决的问题 / Problem
PR #51 已把百度请求改为串行,并在任务开始时记下一次可发送时间。
52001/52002/54003的重试仍包在同一次排队任务里:重试请求发出后,下一段会立刻跟上,标准版 1 QPS 仍可能连续撞上54003。本分支从 #51 的头部切出,对
main的差异还包含该 PR 已有的百度 / 必应翻译(Fixes #43)。本次新增的提交只修正上述间隔。改动后的行为 / Resulting behavior
54003占住后续段落,也不会在重试成功后立刻再发下一段。验证 / Validation
pnpm exec tsc --noEmit通过pnpm run i18n:check通过pnpm build通过node scripts/translation-test.mjs、node scripts/glossary-test.mjs、node scripts/translation-manual-test.mjs通过。新增断言:54003退避后才重试,且重试成功后的下一次请求仍至少间隔约 1 秒。edge.microsoft.com/translate/translatetext,Use <b>bold</b> tags here.译为这里使用<b>粗体</b>标签。,AT&T、a < b与换行均保留。百度没有可用的 APP ID / 密钥,未做真实账号验证;未在 Tauri / Android 实机验证。本次无界面改动。数据与兼容性 / Data and compatibility
不涉及持久化格式、迁移或缓存键。只改变百度请求的发送节奏。
提交前检查 / Checklist