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.
fix #805
当原始逻辑出错,重试到最大上限仍继续遇到问题时,尝试分割翻译,否则仍然按原始逻辑返回结果。
分割翻译的好处如下:
标点和数字不再可能单独作为一句返回而导致翻译结果和气泡错位的问题,见下方多出一个省略号的例子有点激进了,已去除。这会强制让所有位置都保留翻译,但是可能部分位置的翻译是需要去除的。缺点是会稍增大token用量(已尽可能降低),但消耗token量显然比堆重试次数还要低。下面例子从10句拆到1句时最多只需发送7次请求就能得到最终结果,原逻辑重试7次可能依然不行且最终返回空白结果。
分割后的部分由于互相没有前后文联系,翻译质量会稍有下滑。
text_region
fails to translate properly, it will indicate which sentence failed to translate successfully;The disadvantage is that it will increase token usage (already minimized as much as possible), and translation quality will somewhat decrease