feat: 😽增加重试机制, 解决模型不稳定的报错
修复了 #1300
Motivation
- 解决由于某些供应商/模型本身不太稳定导致频繁报错
- 解决网络等其他因素不稳定而导致的报错
- 在发生错误时不应当直接回复错误信息, 而应该将错误信息保留在日志, 以此防止错误刷屏
Modifications
- 增加两项供应商配置: 最大重试次数和重试间隔时间
- 为LLM请求部分增加遇到错误的重试机制
Check
- [x] 我的 Commit Message 符合良好的规范
- [x] 我新增/修复/优化的功能经过良好的测试
好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
为 LLM 请求添加重试机制,以提高稳定性和处理瞬时错误
新特性:
- 为 LLM 提供程序请求实现可配置的重试机制
- 为 API 调用添加可配置的最大重试次数和重试延迟
增强功能:
- 改进对不稳定模型提供程序的错误处理
- 为特定类型的网络和服务器错误添加选择性重试
杂项:
- 更新默认配置以包含重试设置
Original summary in English
Summary by Sourcery
Add retry mechanism for LLM requests to improve stability and handle transient errors
New Features:
- Implement configurable retry mechanism for LLM provider requests
- Add configurable maximum retry attempts and retry delay for API calls
Enhancements:
- Improve error handling for unstable model providers
- Add selective retry for specific types of network and server errors
Chores:
- Update default configuration to include retry settings
Sourcery 评审者指南
此 Pull Request 引入了 LLM 请求的重试机制,以解决某些提供商/模型和网络相关问题导致的不稳定性。它增加了最大重试次数和重试延迟的配置选项,并确保错误消息被记录而不是直接返回给用户。
更新后的提供商设置类图
classDiagram
class ProviderSettings {
streaming_response: bool
max_retries: int
retry_delay: float
}
note for ProviderSettings "Added max_retries and retry_delay attributes"
文件级别变更
| 变更 | 详情 | 文件 |
|---|---|---|
| 实现了 LLM 请求的重试机制,以处理由于提供商不稳定或网络问题导致的潜在故障。 |
|
astrbot/core/pipeline/process_stage/method/llm_request.py |
| 为 LLM 请求添加了最大重试次数和重试延迟的配置选项。 |
|
astrbot/core/pipeline/process_stage/method/llm_request.pyastrbot/core/config/default.py |
可能相关的 issue
- #1300: 此 PR 通过为 LLM 请求添加重试机制来修复此问题。
- #1300: 此 PR 实现了 issue 中请求的重试系统。
提示和命令
与 Sourcery 互动
- 触发新的审查: 在 Pull Request 上评论
@sourcery-ai review。 - 继续讨论: 直接回复 Sourcery 的审查评论。
- 从审查评论生成 GitHub issue: 要求 Sourcery 从审查评论创建一个 issue,方法是回复该评论。您也可以回复审查评论并使用
@sourcery-ai issue从该评论创建一个 issue。 - 生成 Pull Request 标题: 在 Pull Request 标题中的任何位置写入
@sourcery-ai以随时生成标题。您也可以在 Pull Request 上评论@sourcery-ai title以随时(重新)生成标题。 - 生成 Pull Request 摘要: 在 Pull Request 正文中的任何位置写入
@sourcery-ai summary以随时在您想要的位置生成 PR 摘要。您也可以在 Pull Request 上评论@sourcery-ai summary以随时(重新)生成摘要。 - 生成评审者指南: 在 Pull Request 上评论
@sourcery-ai guide以随时(重新)生成评审者指南。 - 解决所有 Sourcery 评论: 在 Pull Request 上评论
@sourcery-ai resolve以解决所有 Sourcery 评论。如果您已经解决了所有评论并且不想再看到它们,这将非常有用。 - 驳回所有 Sourcery 审查: 在 Pull Request 上评论
@sourcery-ai dismiss以驳回所有现有的 Sourcery 审查。如果您想从新的审查开始,这将特别有用 - 不要忘记评论@sourcery-ai review以触发新的审查! - 为 issue 生成行动计划: 在 issue 上评论
@sourcery-ai plan以为其生成行动计划。
自定义您的体验
访问您的 仪表板 以:
- 启用或禁用审查功能,例如 Sourcery 生成的 Pull Request 摘要、评审者指南等。
- 更改审查语言。
- 添加、删除或编辑自定义审查说明。
- 调整其他审查设置。
获取帮助
Original review guide in English
Reviewer's Guide by Sourcery
This pull request introduces a retry mechanism for LLM requests to address instability issues with certain providers/models and network-related errors. It adds configuration options for maximum retry attempts and retry delay, and it ensures that error messages are logged instead of being directly returned to the user.
Updated class diagram for provider settings
classDiagram
class ProviderSettings {
streaming_response: bool
max_retries: int
retry_delay: float
}
note for ProviderSettings "Added max_retries and retry_delay attributes"
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Implemented a retry mechanism for LLM requests to handle potential failures due to provider instability or network issues. |
|
astrbot/core/pipeline/process_stage/method/llm_request.py |
| Added configuration options for maximum retry attempts and retry delay for LLM requests. |
|
astrbot/core/pipeline/process_stage/method/llm_request.pyastrbot/core/config/default.py |
Possibly linked issues
- #1300: The PR fixes the issue by adding retry mechanisms for LLM requests.
- #1300: The PR implements the retry system requested in the issue.
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment@sourcery-ai reviewto trigger a new review! - Generate a plan of action for an issue: Comment
@sourcery-ai planon an issue to generate a plan of action for it.
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
感觉这个 process() 方法现在已经过分复杂了()我抽空仔细 check 一下吧~ 感觉重试机制得用装饰器来包装了