feat: Add specific rate limit error messages for ZIP task analysis, instant analysis, and repository scanning.
Build and Push CodeReview / build (push) Has been cancelled Details

This commit is contained in:
vinland100 2026-01-16 10:21:30 +08:00
parent ed1fab2c11
commit 05db656fd1
3 changed files with 13 additions and 1 deletions

View File

@ -164,6 +164,11 @@ async def process_zip_task(task_id: str, file_path: str, db_session_factory, use
except Exception as e:
if attempt < MAX_RETRIES - 1:
wait_time = (attempt + 1) * 2
# 特殊处理限流错误提示
error_str = str(e)
if "429" in error_str or "rate limit" in error_str.lower() or "额度不足" in error_str:
print(f"🚫 [限流提示] ZIP任务分析文件触发 LLM 频率限制 (429),建议在设置中降低并发数或增加请求间隔。文件: {f_path}")
print(f"⚠️ ZIP任务分析文件失败 ({f_path}), 正在进行第 {attempt+1} 次重试... 错误: {e}")
await asyncio.sleep(wait_time)
continue
@ -487,6 +492,8 @@ async def instant_analysis(
except Exception as e:
# 分析失败,返回错误信息
error_msg = str(e)
if "429" in error_msg or "rate limit" in error_msg.lower() or "额度不足" in error_msg:
print(f"🚫 [限流提示] 即时分析触发 LLM 频率限制 (429),请检查账户余额或稍后重试。")
print(f"❌ 即时分析失败: {error_msg}")
raise HTTPException(
status_code=500,

View File

@ -13,7 +13,7 @@ from app.core.timezone import beijing_time
# 配置日志
logging.Formatter.converter = beijing_time
logging.basicConfig(
level=logging.DEBUG,
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)

View File

@ -625,6 +625,11 @@ async def scan_repo_task(task_id: str, db_session_factory, user_config: dict = N
except Exception as e:
if attempt < MAX_RETRIES - 1:
wait_time = (attempt + 1) * 2
# 特殊处理限流错误提示
error_str = str(e)
if "429" in error_str or "rate limit" in error_str.lower() or "额度不足" in error_str:
print(f"🚫 [限流提示] 仓库扫描任务触发 LLM 频率限制 (429),建议在设置中降低并发数或增加请求间隔。文件: {f_path}")
print(f"⚠️ 分析文件失败 ({f_path}), 正在进行第 {attempt+1} 次重试... 错误: {e}")
await asyncio.sleep(wait_time)
continue