Skip to content

feat: 当上游 API 返回内容长度为 0 时,将其认定为失败并触发负载均衡重试 - #208

Open
adamhj wants to merge 1 commit into
bestruirui:devfrom
adamhj:feat/empty-response-retry
Open

feat: 当上游 API 返回内容长度为 0 时,将其认定为失败并触发负载均衡重试#208
adamhj wants to merge 1 commit into
bestruirui:devfrom
adamhj:feat/empty-response-retry

Conversation

@adamhj

@adamhj adamhj commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

我遇到某些上游中转,会出现回包不为空(http 200,有json包体),但是没有实际内容(assistant消息/工具调用)的情况,所以有了这个PR

例如这样的:

{
  "id": "chatcmpl-20260226085904630433901GfXOX42G",
  "object": "chat.completion",
  "created": 1772096386,
  "model": "gemini-3-flash-preview",
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}

由于流式没办法在转发流量之前判断,所以这个只能覆盖非流式响应

chenjingxiong added a commit to chenjingxiong/octopus that referenced this pull request Jun 21, 2026
…truirui#208 已内置)

合入的 PR:
- bestruirui#262 添加活动热力图自定义日期范围选择功能 (cherry-pick)
- bestruirui#271 修复日志无法滚动问题 (手动适配:VirtualizedGrid reachEnd 重置 + 日志分页偏移)
- bestruirui#287 加入 rerank 转发路由 + 重复资源检测 (手动适配)
- bestruirui#208 空响应检测触发负载均衡重试 → 已被 axonhub/llm 内置 WithEmptyResponseDetection() 覆盖,无需手动移植

跳过的 PR:
- bestruirui#282 TOTP + JSON 替换 (+1425/-115,改动过大)
- bestruirui#270 key 选择模式 (改了已删除的 images.go,需大量适配)
- bestruirui#199 熔断器开关 (改了已删除的 transformer,冲突复杂)
- bestruirui#198 渠道标签系统 (13 文件,改动偏大)
- bestruirui#194 日志筛选增强 (8 文件 +512/-86,改动偏大)
- bestruirui#190 统计清除 (合并提交多,冲突复杂)
- bestruirui#184 渠道排序 (排序已内置上游,复制功能非核心)

版本升级至 v0.9.28-2

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant