#7102 翻译字幕阶段出错 [DeepSeek] Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens

95.41**8 Posted at: 1 hour ago

翻译字幕阶段出错 [DeepSeek] Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=65536, prompt_tokens=724, total_tokens=66260, completion_tokens_details=None, prompt_tokens_details=PromptTokensDetails(audio_tokens=None, cached_tokens=640), prompt_cache_hit_tokens=640, prompt_cache_miss_tokens=84)
Traceback (most recent call last):

File "videotrans\translator\_base.py", line 68, in run

File "videotrans\translator\_base.py", line 106, in _run_text

File "tenacity\__init__.py", line 338, in wrapped_f

File "tenacity\__init__.py", line 477, in call

File "tenacity\__init__.py", line 378, in iter

File "tenacity\__init__.py", line 421, in exc_check

tenacity.RetryError: RetryError[]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "videotrans\task\job.py", line 35, in run

File "videotrans\task\job.py", line 137, in process_task

File "videotrans\task\translate_srt.py", line 51, in trans

File "videotrans\translator\_runner.py", line 67, in run

File "videotrans\translator\_base.py", line 74, in run

File "tenacity\__init__.py", line 480, in call

File "videotrans\translator\_openaicompat.py", line 107, in _item_task

openai.LengthFinishReasonError: Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=65536, prompt_tokens=724, total_tokens=66260, completion_tokens_details=None, prompt_tokens_details=PromptTokensDetails(audio_tokens=None, cached_tokens=640), prompt_cache_hit_tokens=640, prompt_cache_miss_tokens=84)
[TranslateSrt]翻译字幕: OutputFormat=双语(目标语言在上)
[TaskCfgSTS]
原始输入文件名: C:/Users/共产主义者/Downloads/用于字幕提取-mp4/th.srt,
输出结果保存到文件夹: D:/BaiduNetdiskDownload/win-pyvideotrans-v4.12/output/translate
翻译渠道:DeepSeek,原始语言:th,目标语言:zh-cn, 未选 发送完整字幕
代理地址:http://127.0.0.1:7897


=
system:Windows-10-10.0.19045-SP0
version:v4.12
frozen:True
language:zh_CN
root_dir:D:/BaiduNetdiskDownload/win-pyvideotrans-v4.12

1 Replies

#1 DeepSeek reply at 1 hour ago

这是 DeepSeek API 单次返回内容达到了模型输出 token 上限(completion_tokens=65536,即 65536 个 token),导致响应被强制截断抛出 LengthFinishReasonError

根本原因是一次提交给 DeepSeek 翻译的字幕行数过多,或 DeepSeek 设置中的 max_tokens 被设得过大,模型一次性生成了超长内容后被截断。

解决步骤

  1. 减小每批翻译行数
    进入 菜单 -> 工具 -> 高级选项 -> 字幕翻译调整,将 AI翻译渠道每批字幕行数 调小,建议值:20 或更低。
  2. 检查 DeepSeek 的 max_tokens 设置
    进入 菜单 -> 翻译设置 -> DeepSeek,查看 最大输出tokenmax_token 项。如果当前设置大于 8192,请将其改为 40968192
  3. 取消并发高效模式(如已开启)
    如果在高级选项中勾选了 AI翻译一次性翻译所有字幕行,请取消勾选,改为分批翻译。
  4. 调低翻译后暂停秒数(可选项)
    菜单 -> 工具 -> 高级选项 -> 字幕翻译调整 中,将 翻译后暂停秒 设置为 5-10,避免因单次请求过快被限流。
  5. 重启软件并重试
    重新翻译字幕文件即可。
注意:DeepSeek 的输出 token 上限是有限制的,completion_tokens=65536 表明已触发上限。将每批字幕行数调小后,每次生成的译文就少了,可正常返回。

请查阅相关文档:

Thinking...
Post Your Reply
If you have more than 50 messages, you will no longer receive an automatic reply. Please ask a new question!
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Dondate via ko-fi.com

Related resource