Skip to content

fix(log): derive response model mismatch from names stored flag - #7464

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/responses-model-suffix
Sep 19, 2026
Merged

seefs001 merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/responses-model-suffix

Conversation

@seefs001

@seefs001 seefs001 commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ 提交说明 / PR Notice

English template: .github/PULL_REQUEST_TEMPLATE/en.md

Important

  • 描述可用 AI 辅助。提交前请审阅并精炼全文,仅保留维护者需要复核的要点,并声明对其负责。PR 正文及后续评论均不得直接粘贴未经人工过滤的大段 AI 文本;多次提交此类内容可能会被 block。
  • 开启透传请勿反馈问题;透传会直接发送内容,不会经过 new-api 的逻辑处理。
  • 请按本模板填写后再提交。

🔗 关联任务 / Related Issue

  • 新功能请填写下方 Issue 编号;若还没有对应 Issue,请先自行创建。功能讨论请放在 Issue 中进行。

  • 改动较大或方向性变更,请先在关联 Issue 中与维护者达成一致,再提交 PR。

  • Bug 修复请关联对应 Issue。设计取舍、理解偏差或预期不一致,更适合作为讨论或功能请求。

  • Closes #

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

📝 变更描述 / Description

(简述做了什么、为什么生效。不得直接粘贴未经人工过滤的大段 AI 文本。如果难以简述,建议先拆分范围,或在 Issue 中与维护者对齐。)

响应模型不一致匹配逻辑放到前端

📸 运行证明 / Proof of Work

(请写明如何验证:实际命令或步骤,以及观察结果。仅声明 go build 通过或测试通过,不视为有效证明。UI 变更请附截图或录屏;Bug 修复请说明复现过程与修复后结果。)

✅ 提交前检查项 / Checklist

  • 人工确认: 无论描述是否由 AI 生成,我已审阅并精炼全文,仅保留可复核的要点,并声明对其准确性与完整性负责。PR 正文及后续评论均未直接粘贴未经人工过滤的大段 AI 文本。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • 新功能关联 Issue: 若此 PR 标记为 New feature,我已关联对应 Issue;若尚无 Issue,我已先自行创建。
  • 事前沟通: 若改动较大或涉及方向性变更,已在关联 Issue 中与维护者沟通并达成一致。
  • 功能范围: 本 PR 不是 Coding Plan、逆向渠道、第三方封装接口,也不是对 Codex 渠道类型的改动。
  • 非透传: 本 PR 不是针对开启透传后的转发行为;透传会直接发送内容,不会经过 new-api 的逻辑处理。
  • 范围聚焦: 本 PR 为一项聚焦改动,未包含无关代码。
  • 本地验证: 已按变更路径实际验证,并写明命令与观察结果。仅声明 go build 通过或测试通过,不视为有效证明。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

Summary by CodeRabbit

  • Bug Fixes

    • Improved response-model matching across usage logs, including case differences, dated variants, and provider-qualified model names.
    • Reduced incorrect mismatch warnings for compatible returned models.
    • Updated usage-log badges, details, and explanatory notices to show mismatch status consistently.
    • Improved handling of missing or blank model information without displaying false warnings.
  • Tests

    • Added coverage for provider paths, model variants, and edge cases to help ensure accurate mismatch indicators.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c77e5d3c-e0b7-4321-acfb-2ff397fca9db

📥 Commits

Reviewing files that changed from the base of the PR and between b0bf258 and 82c928f.

📒 Files selected for processing (11)
  • relay/common/response_model.go
  • relay/response_model_test.go
  • service/log_info_generate.go
  • web/src/features/usage-logs/components/__tests__/mobile-card.test.tsx
  • web/src/features/usage-logs/components/__tests__/model-badge.test.tsx
  • web/src/features/usage-logs/components/__tests__/usage-facts.test.tsx
  • web/src/features/usage-logs/components/model-badge.tsx
  • web/src/features/usage-logs/lib/__tests__/response-model.test.ts
  • web/src/features/usage-logs/lib/index.ts
  • web/src/features/usage-logs/lib/response-model.ts
  • web/src/features/usage-logs/types.ts
 ________________________________________________________________
< First, solve the problem. Then, write the code. - John Johnson >
 ----------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seefs001
seefs001 merged commit 972aed1 into QuantumNous:main Sep 19, 2026
2 of 3 checks passed
yang-yang9 added a commit to yyangTeam/new-api that referenced this pull request Sep 19, 2026
…rivation)

Merged 2 upstream commits from origin/main (972aed1 QuantumNous#7464 + merge commit).

Conflict resolution: zero conflicts — clean auto-merge. The new commit
touches 3 files dev also modified (service/log_info_generate.go,
usage-logs/types.ts, usage-logs/components/model-badge.tsx) but the changes
are in non-overlapping regions; git auto-merged both sides.

Upstream change (QuantumNous#7464): derive upstream response model mismatch from the
model names instead of a stored flag. Adds relay/common/response_model.go
refactor, new web/src/features/usage-logs/lib/response-model.ts, and the
AppendResponseModelLogInfo helper in log_info_generate.go that records
other.response_model only when names actually diverge.

Phase 6a spot-check (dev content in auto-merged files intact):
- service/log_info_generate.go: diff vs origin/dev shows only upstream
  additions (AppendResponseModelLogInfo, request_policy events,
  MarkRequestPolicySuccess, stream ResponseFailed/ResponseOutcome); 0 dev
  lines removed.
- usage-logs/types.ts: dev fields (is_model_mapped, upstream_model_name,
  request_policy, response_model) all present; upstream added more.
- model-badge.tsx: ResponseModelDetails still exported; upstream
  name-derivation logic added cleanly.

Verification:
- go build ./... passes
- relaykit standalone build passes (GOWORK=off)
- go vet ./... passes (all test packages compile)
- bun run typecheck: zero errors
- bun run i18n:check: passes

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ChinaToyHunter added a commit to ChinaToyHunter/new-api that referenced this pull request Sep 19, 2026
Brings in 972aed1 fix(log): derive response model mismatch from names instead
of a stored flag (QuantumNous#7464).

Auto-merged with zero conflicts: 10 of the 11 files were untouched by this fork
since the merge base, and the only shared file, usage-logs/types.ts, had the two
sides editing disjoint regions.

Verified rather than assumed, since upstream turned a field into a method:

- types.ts keeps every fork addition (ModelNameMode, modelNameMode,
  model_name_mode, ExportLogsParams, ExportLogsResult) alongside the upstream
  relocation of the PolicyEvent import and the response_model type without the
  stored mismatch flag.
- relay/common/response_model.go turns ResponseModel.Mismatch into a method;
  nothing still reads it as a field (the other Mismatch symbols in the tree are
  unrelated payment/OAuth/session errors).
- No .mismatch reader remains in web/src outside upstream own rewritten fixtures.
- service/log_info_generate.go only drops a now-redundant guard on whether to
  attach the diagnostic response_model block; it does not touch
  attachQuotaSaturation or any quota conversion, so billing invariants stand.

Verified: go build ./... ; go vet ./relay/common/... ./relay/ ./service/ ;
go test ./relay/ -run ResponseModel ; bun run typecheck ; and 261 vitest cases
across the 8 affected usage-logs files.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Javabcd pushed a commit to Javabcd/new-api that referenced this pull request Sep 22, 2026
GuDong2003 pushed a commit to GuDong2003/new-api that referenced this pull request Sep 25, 2026
TomJKS pushed a commit to TomJKS/new-api that referenced this pull request Sep 28, 2026
meatRoll pushed a commit to meatRoll/new-api that referenced this pull request Oct 12, 2026
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