(message)
| 383 | } |
| 384 | |
| 385 | function formatUserFacingError(message) { |
| 386 | const text = stripAnsi(String(message || '')).trim() |
| 387 | if (!text) { |
| 388 | return '运行失败,请查看运行日志了解详情。' |
| 389 | } |
| 390 | |
| 391 | if ( |
| 392 | /selected model is at capacity|try a different model|model is overloaded|overloaded|capacity/i.test( |
| 393 | text, |
| 394 | ) |
| 395 | ) { |
| 396 | return '上游模型当前已满载。本地链路已经连通,但 provider 现在比较繁忙。请稍后重试,或切换到其他上游模型。' |
| 397 | } |
| 398 | |
| 399 | if (/rate limit|too many requests|quota/i.test(text)) { |
| 400 | return '上游 provider 对当前请求进行了限流。请稍等片刻,降低请求频率,或切换 API Key / 模型。' |
| 401 | } |
| 402 | |
| 403 | if (/invalid api key|incorrect api key|unauthorized|401/i.test(text)) { |
| 404 | return '上游 API Key 被拒绝了。请在配置里检查 API Key,并确认它与当前 provider 匹配。' |
| 405 | } |
| 406 | |
| 407 | if (/model.*not found|unknown model|does not exist|404/i.test(text)) { |
| 408 | return '上游模型名称未被接受。请在配置面板里重新检查模型字符串。' |
| 409 | } |
| 410 | |
| 411 | if (/timed out|timeout|etimedout/i.test(text)) { |
| 412 | return '上游请求超时。当前 provider 或网络可能较慢,请稍后重试。' |
| 413 | } |
| 414 | |
| 415 | if (/fetch failed|enotfound|econnrefused|connection refused|network/i.test(text)) { |
| 416 | return '应用无法连接到上游接口。请检查接口地址、网络连接,以及 provider 是否可达。' |
| 417 | } |
| 418 | |
| 419 | return text |
| 420 | } |
| 421 | |
| 422 | function previewValue(value, max = 900) { |
| 423 | const text = |
no test coverage detected