-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: handle GitHub API rate limits with token auth and exponential backoff #6885
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -421,6 +421,8 @@ async def _query_stream( | |||||||||||||||||||||||
| try: | ||||||||||||||||||||||||
| if "input_json" in tool_info: | ||||||||||||||||||||||||
| tool_info["input"] = json.loads(tool_info["input_json"]) | ||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||
| tool_info["input"] = tool_info.get("input", {}) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # 添加到最终结果 | ||||||||||||||||||||||||
| final_tool_calls.append( | ||||||||||||||||||||||||
|
|
@@ -442,7 +444,7 @@ async def _query_stream( | |||||||||||||||||||||||
| id=id, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| except json.JSONDecodeError: | ||||||||||||||||||||||||
| # JSON 解析失败,跳过这个工具调用 | ||||||||||||||||||||||||
| # JSON 解析失败,跳过这个工具调用,不 yield | ||||||||||||||||||||||||
| logger.warning(f"工具调用参数 JSON 解析失败: {tool_info}") | ||||||||||||||||||||||||
|
Comment on lines
446
to
448
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider logging the exception details in addition to Currently the log only includes
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # 清理缓冲区 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
This
elseblock is redundant. Thetool_infodictionary, which comes fromtool_use_buffer, is guaranteed to have an'input'key initialized to{}on line 377. When'input_json'is not present,tool_info['input']already contains the correct empty dictionary. Thiselseblock is a no-op and can be removed to improve code clarity.