Skip to content

feat(channels): refine fetched model categorization - #6632

Merged
seefs001 merged 3 commits into
QuantumNous:mainfrom
seefs001:fix/model-list-category
Aug 7, 2026
Merged

feat(channels): refine fetched model categorization#6632
seefs001 merged 3 commits into
QuantumNous:mainfrom
seefs001:fix/model-list-category

Conversation

@seefs001

@seefs001 seefs001 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

完善获取模型列表的厂商分类

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

Summary by CodeRabbit

  • New Features

    • Available models are automatically categorized by provider.
    • Models are grouped consistently while preserving their original order.
    • Improved model fetching and normalization across supported channels.
  • Improvements

    • Streamlined the model selection dialog while preserving loading, search, filtering, tab, and selection behavior.
    • Improved empty-state and descriptive messaging for clearer model selection.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ad1940e-bafe-4481-9846-5e9be7cecd0a

📥 Commits

Reviewing files that changed from the base of the PR and between 58ed9a8 and 22601dc.

📒 Files selected for processing (1)
  • web/src/features/channels/lib/model-categories.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/features/channels/lib/model-categories.ts

Walkthrough

The change adds shared provider-based model categorization utilities and updates the fetch-models dialog to use them. Dialog fetching, filtering, tab selection, and conditional rendering are reorganized while preserving existing interaction states.

Changes

Model fetch dialog

Layer / File(s) Summary
Model categorization utilities
web/src/features/channels/lib/model-categories.ts, web/src/features/channels/lib/index.ts
Added ordered provider rules, getModelCategory, categorizeModels, licensing, and the library re-export.
Dialog model processing
web/src/features/channels/components/dialogs/fetch-models-dialog.tsx
Updated model normalization, upstream fetching, deduplication, filtering, and memoized category grouping.
Dialog rendering states
web/src/features/channels/components/dialogs/fetch-models-dialog.tsx
Extracted the description, default tab, and conditional body into computed ReactNode values. Updated tooltip trigger syntax.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

A rabbit sorts models in a neat little row,
Provider rules classify each name they know.
The dialog fetches, filters, and shows,
Through loading and empty states, it flows.
“Hop!” says the rabbit, “The categories grow.”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: refining fetched model categorization for channels.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/features/channels/lib/model-categories.ts`:
- Line 151: Update getModelCategory to return the stable identifier 'other'
instead of the display label 'Other'. In the dialog, translate this identifier
with t('Other') when rendering the category heading, and update the special
sorting condition to compare against 'other'.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 56b49cae-5d18-445a-a9f8-53d71aa97da8

📥 Commits

Reviewing files that changed from the base of the PR and between 0ab0202 and 8321ef1.

📒 Files selected for processing (3)
  • web/src/features/channels/components/dialogs/fetch-models-dialog.tsx
  • web/src/features/channels/lib/index.ts
  • web/src/features/channels/lib/model-categories.ts

}
}

return 'Other'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep category identifiers separate from localized labels.

getModelCategory returns 'Other', and the dialog renders this value as a category heading. Users therefore see untranslated text.

Return a stable identifier such as 'other'. Map that identifier to t('Other') in the dialog. Update the special sort check to use the identifier.

As per coding guidelines, “Frontend user-facing text must use i18next/react-i18next.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/features/channels/lib/model-categories.ts` at line 151, Update
getModelCategory to return the stable identifier 'other' instead of the display
label 'Other'. In the dialog, translate this identifier with t('Other') when
rendering the category heading, and update the special sorting condition to
compare against 'other'.

Source: Coding guidelines

@seefs001
seefs001 merged commit c9bc038 into QuantumNous:main Aug 7, 2026
2 of 3 checks passed
yiranxiaohui added a commit to yiranxiaohui/new-api that referenced this pull request Aug 7, 2026
Brings in from QuantumNous/new-api:
- fix: 修复兑换码额度精度损失 (QuantumNous#6685)
- feat(rate-limit): user critical rate limit for access token and aff transfer routes
- fix: test Claude/Gemini endpoints with native request format (QuantumNous#6698)
- feat(channels): refine fetched model categorization (QuantumNous#6632)
- security: atomic access-token rotation and aff updates (merge commit from fork)
- refactor(relay): move replay metadata onto request bodies
- fix(relay): set Request.GetBody for transparent HTTP/2 retry (QuantumNous#6249)
- Feat/auto group (QuantumNous#6590)
- fix(aws): cancel Bedrock requests on client disconnect (QuantumNous#6589)

Conflicts resolved:
- controller/model.go: adopt upstream's unified group-model loop with
  FormatMatchingModelName token-limit matching; keep fork's
  hiddenMappedModels filter inside the loop
- model/user.go: keep fork's BatchDeleteUsers; adopt upstream's atomic
  gorm.Expr-based inviteUser
- relay/channel/task/sora/adaptor_test.go: keep both fork's New API
  Video channel tests and upstream's replayable-body test

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ZteapnbTWdP52n7wZ6NsN
0401lucky pushed a commit to 0401lucky/new-api that referenced this pull request Aug 7, 2026
* feat(channels): refine fetched model categorization

* fix: channel category

* fix: hy3 category
0401lucky added a commit to 0401lucky/new-api that referenced this pull request Aug 7, 2026
- fix(relay): set Request.GetBody so HTTP/2 can transparently retry after upstream stream reset (QuantumNous#6249)
- refactor(relay): move replay metadata onto request bodies (适配 fork: 保留 types.PriceData)
- feat(channels): refine fetched model categorization (QuantumNous#6632)
- fix: test Claude/Gemini endpoints with native request format (QuantumNous#6698)
- feat(rate-limit): add user critical rate limit middleware (access-token / aff-transfer 路由)
- fix: 修复兑换码额度精度损失 (QuantumNous#6685) (保留 fork 随机额度/下载/100000 批量特性)

跳过: relaykit 模块重构系列(86ac0f7 等, 按 fork 策略), GitCode 发布 CI 工作流, 已同步的 24 个 cherry-pick 副本
latioswang added a commit to trycortexai/new-api that referenced this pull request Aug 10, 2026
* fix(relay): set Request.GetBody so the HTTP/2 transport can transparently retry after an upstream stream reset (QuantumNous#6249)

* fix(relay): set Request.GetBody so the HTTP/2 transport can transparently retry after an upstream stream reset

The outbound request body is a type-erased io.Reader over BodyStorage, so
net/http cannot derive Request.GetBody (it only does so for *bytes.Reader,
*bytes.Buffer and *strings.Reader). With GetBody nil, the HTTP/2 transport
cannot transparently retry a request once the body has been written and the
upstream resets the stream with a retryable error (REFUSED_STREAM, or a
connection-level GOAWAY); the relay request then fails with:

    http2: Transport: cannot retry err [...] after Request.Body was written;
    define Request.GetBody to avoid this error

This affects every relay path that goes through DoApiRequest (chat, claude,
gemini, responses, embedding, image, rerank).

BodyStorage (memory and disk) already implements io.Seeker, so replay support
only needed wiring:

- NewOutboundJSONBody additionally returns a getBody that rewinds the storage
  and hands out a fresh non-closing reader. The transport only calls GetBody
  after the previous attempt's body has been abandoned, so the rewind cannot
  race an in-flight read.
- RelayInfo carries it in the new UpstreamRequestGetBody field, set alongside
  UpstreamRequestBodySize by the handlers that build storage-backed bodies.
- applyUpstreamGetBody (symmetric with applyUpstreamContentLength) wires it
  into DoApiRequest/DoFormRequest/DoTaskApiRequest, only when req.GetBody is
  still nil.

Also remove the hand-rolled GetBody override in DoTaskApiRequest: it returned
the same already-consumed reader, so any transport-level replay would have
silently sent an empty body, and it clobbered the correct snapshot-based
GetBody that net/http derives from the *bytes.Reader bodies the task adaptors
pass in. For non-replayable bodies GetBody now stays nil, so a retry fails
loudly instead of corrupting the request.

Covered by unit tests plus an end-to-end raw-frame HTTP/2 test that resets
the first stream with REFUSED_STREAM after the body is written and asserts
the transport transparently retries with the complete body.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(relay): hand out independent readers from GetBody (address review)

Per the http.Request.GetBody contract ("returns a new copy of Body"),
each call must yield a reader with its own cursor. The previous
implementation rewound and reused the shared BodyStorage, so two
consecutive GetBody readers would interfere with each other, and a
replay could disturb the primary body's offset under extreme transport
timing (e.g. attempt N's body write not yet fully abandoned when the
transport builds attempt N+1).

Instead of snapshotting the payload (an extra copy), add
BodyStorage.NewReader, which returns an independent zero-copy reader:

- memory mode: a fresh bytes.Reader over the same immutable backing
  array;
- disk mode: a separate file descriptor over the cache file, so the
  transport closing a replayed body only closes that descriptor.

NewOutboundJSONBody's getBody now simply hands out storage.NewReader,
and once the handler releases the storage, GetBody fails with
ErrStorageClosed instead of replaying stale data.

Tests: interleaved reads across two replay readers and the primary
body each observe exactly their own byte stream, for both the memory
and the disk-backed storage; the existing GetBody and HTTP/2 retry
suites still pass (h2 e2e tests flake-free with -count=20).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(relay): bind replayable metadata on pass-through requests

* fix(relay): reset upstream body metadata between channels

* test(relay): cover replay across retries and channel attempts

* fix(relay): stop following upstream redirects

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* refactor(relay): move replay metadata onto request bodies

* Merge commit from fork

* feat(channels): refine fetched model categorization (QuantumNous#6632)

* feat(channels): refine fetched model categorization

* fix: channel category

* fix: hy3 category

* fix: test Claude/Gemini endpoints with native request format (QuantumNous#6698)

* feat(rate-limit): add user critical rate limit middleware for access token and aff transfer routes

* fix: 修复兑换码额度精度损失 (QuantumNous#6685)

* fix: 修复兑换码额度精度损失(QuantumNous#6680)

* fix(redemption): guard update data integrity

* CI: enhance release synchronization workflow with optional file syncing

* fix(ali): stop injecting top_p into requests that omit it (QuantumNous#6674)

* fix(channels): classify Qwen TTS models correctly (QuantumNous#6711)

* feat(channels): add auto-disable-only channel test mode (QuantumNous#6728)

* perf(web): debounce server and large-list searches (QuantumNous#6727)

* fix: record reasoning effort consistently in usage logs (QuantumNous#6641)

* feat(relay): expose user and group context to parameter overrides (QuantumNous#6534)

* fix(ollama): preserve reasoning and tool-call context (QuantumNous#6605)

* fix: backend length validation (QuantumNous#5548)

* feat(billing): highlight matched conditional multipliers in logs (QuantumNous#6561)

* feat(billing): highlight matched conditional multipliers in usage logs

* fix(billing): make request rule tracing stable and type-safe

* fix(web): require confirmation before rotating access token (QuantumNous#6749)

---------

Co-authored-by: Lucas <hepo.lucas@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: CaIon <i@caion.me>
Co-authored-by: RedwindA <128586631+RedwindA@users.noreply.github.com>
Co-authored-by: Seefs <40468931+seefs001@users.noreply.github.com>
Co-authored-by: lihu-001 <lihu9048@gmail.com>
Co-authored-by: ENCHIGO <38551565+ENCHIGO@users.noreply.github.com>
2hot4you pushed a commit to 2hot4you/new-api that referenced this pull request Aug 13, 2026
* feat(channels): refine fetched model categorization

* fix: channel category

* fix: hy3 category

(cherry picked from commit c9bc038)
yuqiyi pushed a commit to yuqiyi/new-api that referenced this pull request Aug 16, 2026
* v1.0.0-rc.24: (117 commits)
  CI: enhance release synchronization workflow with optional file syncing
  fix: 修复兑换码额度精度损失 (QuantumNous#6685)
  feat(rate-limit): add user critical rate limit middleware for access token and aff transfer routes
  fix: test Claude/Gemini endpoints with native request format (QuantumNous#6698)
  feat(channels): refine fetched model categorization (QuantumNous#6632)
  Merge commit from fork
  refactor(relay): move replay metadata onto request bodies
  fix(relay): set Request.GetBody so the HTTP/2 transport can transparently retry after an upstream stream reset (QuantumNous#6249)
  Feat/auto group (QuantumNous#6590)
  fix(aws): cancel Bedrock requests on client disconnect (QuantumNous#6589)
  fix(billing): harden tiered retry group-switch billing (QuantumNous#6570)
  fix(billing): settle tiered retries with final group (QuantumNous#6518)
  feat: deepseek responses api (QuantumNous#6562)
  style: use text-sm for public header nav links to match other nav components (QuantumNous#6557)
  fix(oauth): stop treating a foreign window.opener as a bind flow (QuantumNous#6425)
  fix(relay): preserve multipart image edits for New API channels (QuantumNous#6559)
  feat(logs): expose stream status to log owners (QuantumNous#6558)
  feat: support zstd request decompression (QuantumNous#6545)
  fix: preserve Qwen thinking_budget passthrough (QuantumNous#5836)
  feat(oidc): 支持自定义 OIDC 登录显示名称 (QuantumNous#6012)
  ...

# Conflicts:
#	service/text_quota.go
#	web/src/features/models/components/drawers/model-mutate-drawer.tsx
#	web/src/features/pricing/components/model-details.tsx
#	web/src/features/pricing/lib/price.ts
DayFliggy pushed a commit to DayFliggy/Ren2Hub that referenced this pull request Aug 17, 2026
* feat(channels): refine fetched model categorization

* fix: channel category

* fix: hy3 category
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
* feat(channels): refine fetched model categorization

* fix: channel category

* fix: hy3 category
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