让翻译支持流式响应,并实时输出翻译内容#2
Open
TacKana wants to merge 3 commits into
Open
Conversation
- 移除TopToolbar中未使用的getCurrentProjectName函数 - 移除SettingsPanel中未使用的testLLMConnection函数 - 调整LLMManager中的axios配置,增加超时时间至10分钟 - 关闭ESLint的eol-last规则以避免与Prettier冲突
- 在 LLMManager 中启用流式 API 调用,实时接收并处理翻译片段 - 修改 IPC 通信以支持流式数据传输,通过事件通道发送翻译片段 - 更新 Workspace 组件以监听流式事件并实时显示翻译内容 - 调整 TranslationService 接口以支持流式回调函数 - 修复事件监听器的内存泄漏问题,返回订阅句柄供后续清理
将 `translateMarkdownFileStream` 和 `translateNotebookStream` 方法中的流式翻译逻辑提取为独立的 `translateTextStream` 方法。新增 `splitMarkdownContent` 方法,用于将过长的 Markdown 内容按标题、段落和行进行智能分块,避免超出 LLM 的 token 限制。这提高了大文件翻译的可靠性并保持了代码的复用性。
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.
No description provided.