-
-
Notifications
You must be signed in to change notification settings - Fork 731
feat: 😽增加重试机制, 解决模型不稳定的报错 #1344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
13fe424
feat: 😽增加重试机制, 解决模型不稳定的报错
anka-afk 77bfc20
fix: 🤔修复default漏掉的配置
anka-afk 7b8e6c7
Merge branch 'master' into anka-dev
anka-afk 094de0d
Merge branch 'AstrBotDevs:master' into anka-dev
anka-afk 6fe0375
refactor: 😸拆分单次请求逻辑
anka-afk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题 (复杂度): 考虑重构
requesting
函数,通过将请求执行和重试逻辑提取到单独的辅助函数中,以提高可读性并降低嵌套复杂度,而无需更改功能。考虑将重试逻辑和内部处理提取到单独的辅助函数中。这将扁平化嵌套循环和 try/except 块,以提高可读性,而无需更改行为。例如,将执行单个请求的逻辑移动到其自己的函数中,然后用重试循环包装它:
然后用重试逻辑包装此执行:
最后,更新您的调用站点以使用此重构的
requesting
函数,保持所有功能完整,同时减少嵌套。Original comment in English
issue (complexity): Consider refactoring the
requesting
function by extracting the request execution and retry logic into separate helper functions to improve readability and reduce nesting complexity without altering the functionality.Consider extracting the retry logic and inner handling into separate helper functions. This would flatten the nested loops and try/except blocks to improve readability without changing behavior. For example, move the logic that executes a single request into its own function and then wrap that with the retry loop:
Then wrap this execution with retry logic:
Finally, update your call sites to use this refactored
requesting
function, keeping all functionality intact while reducing nesting.