Handle overloaded AI provider responses

- Preserve upstream AI provider HTTP status codes and expose AI-specific error codes for overload, rate limit, unavailable, and generic provider failures.

- Add short retries for transient AI provider 429/5xx chat completion responses, with configurable retry delays.

- Show friendly AI busy/unavailable messages in the report editor instead of raw provider JSON.

- Preserve custom backend error codes in the shared API exception filter.

- Add AI service tests for retry behavior and overload error mapping.

- Update API, feature, and testing documentation for AI proxy retry and error handling.
This commit is contained in:
2026-05-09 03:35:55 +08:00
parent 1faaa05032
commit 95a4678340
7 changed files with 174 additions and 9 deletions

View File

@@ -541,6 +541,7 @@ pageSize?: number
- 请求上下文只能包含当前报告内容和当前报告内用户有权访问的图片/关键帧。
- 不允许跨部门检索报告作为上下文。
- 当前实现接收 OpenAI 兼容 `messages`、温度等参数,后端会用全局 Provider 的 `modelName` 覆盖请求中的 `model`,所有用户共用同一套 key。
- 上游模型返回 `429/5xx` 等临时错误时,后端会对 `/chat/completions` 做短暂重试;重试后仍失败时保留上游 HTTP 状态码,并通过错误码区分 `AI_PROVIDER_OVERLOADED``AI_PROVIDER_RATE_LIMITED``AI_PROVIDER_UNAVAILABLE``AI_PROVIDER_ERROR`
## Speech API