#4001 openai.LengthFinishReasonError: Could not parse response content as the length limit was reached - CompletionUsage(compl

31.94* Posted at: 2 hours ago 👁9

内容太长超出最大允许Token,请减小内容或增大max_token,或者降低每次发送字幕行数
Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=4096, prompt_tokens=4283, total_tokens=8379, completion_tokens_details=None, prompt_tokens_details=None)
Traceback (most recent call last):
File "videotrans\task\_only_one.py", line 65, in run
File "videotrans\task\trans_create.py", line 658, in trans
File "videotrans\translator\__init__.py", line 970, in run
File "videotrans\translator\_base.py", line 97, in run
File "videotrans\translator\_base.py", line 161, in _run_srt
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 400, in
File "concurrent\futures\_base.py", line 451, in result
File "concurrent\futures\_base.py", line 403, in __get_result
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_localllm.py", line 68, in _item_task
openai.LengthFinishReasonError: Could not parse response content as the length limit was reached - CompletionUsage(completion_tokens=4096, prompt_tokens=4283, total_tokens=8379, completion_tokens_details=None, prompt_tokens_details=None)


=
system:Windows-10-10.0.26200-SP0
version:v3.98
frozen:True
language:zh
root_dir:D:/project/Videotrans/win-pyvideotrans-v3.98-0408

1 Replies

这是由于AI翻译渠道返回的响应内容过长,超出了模型的最大输出Token限制(例如4096个Token)导致的错误。

解决方案:

  1. 减少每次发送的字幕行数:在顶部菜单栏 -> 工具/选项 -> 高级选项 -> 字幕翻译调整 区域,将 AI翻译渠道每批字幕行数 的值调小(例如从默认值调为 20 或 10)。
  2. 取消“发送完整字幕”选项:在主界面的翻译参数区域,取消勾选 发送完整字幕。同时,在 高级选项 -> 字幕翻译调整 中,也取消勾选 发送完整字幕AI翻译附带完整原字幕。这将大幅减少每次请求的Token消耗。
  3. 降低模型温度值:在 高级选项 -> 字幕翻译调整 中,将 AI翻译模型温度值 调低(例如设为 0.1),以减少模型生成冗余内容的风险。
  4. 检查并优化提示词:如果使用了自定义提示词(位于 prompts 目录),请确保其内容简洁,避免过长。

请查阅相关文档:

Post Your Reply
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.

Related resource

Similar issues already exist