Skip to content

feat: one-click release, global model alias pre-mapping, channel failover - #8

Merged
ItzPlana merged 4 commits into
mainfrom
feat/release-alias-failover
Aug 12, 2026
Merged

feat: one-click release, global model alias pre-mapping, channel failover#8
ItzPlana merged 4 commits into
mainfrom
feat/release-alias-failover

Conversation

@ItzPlana

@ItzPlana ItzPlana commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

📝 变更描述 / Description

  1. Release 一键发布release.yml 支持 workflow_dispatch 输入版本号 → 自动建 tag、构建三平台产物、创建 GitHub Release(自动 notes、prerelease 判定)。保留 tag push 路径。注意:dispatch 发布不会连带触发 docker workflow,需手动。
  2. 全局模型别名(前置映射):请求进入时在渠道选择前把别名解析为真实模型(如 cinax → cinax-pro),路由/计费/日志全按真实模型;日志附注原始别名。配置入口:系统设置 → 模型设置 → 全局模型别名。支持链式映射+环检测,pass-through 也会改写 body。
  3. 渠道故障转移开关:运营设置 → 行为,默认关。开启后失败自动转移到同分组同模型的其他渠道(真正排除已失败渠道),独立于 RetryTimes;候选用尽返回最后一次上游错误。

🚀 变更类型 / Type of change

  • ✨ 新功能 (New feature)

✅ 提交前检查项 / Checklist

  • 人工确认: 本 PR 由 AI 生成(见下方标记)
  • 变更理解 / 范围聚焦 / 本地验证 / 安全合规

📸 运行证明 / Proof of Work

  • go build ./... 通过;go test(-vet=off)26 个包全部通过
  • 新增测试:setting/model_setting/model_alias_test.gomodel/channel_cache_failover_test.go 全绿
  • 前端 bun run typecheck 通过,bun --bun run build 构建成功,i18n 7 语言已同步

🤖 Generated with Claude Code · Model: Fable 5 (claude-fable-5)

ItzPlana and others added 3 commits July 26, 2026 01:11
workflow_dispatch now takes a required version input; a prepare job
validates the version format and rejects existing tags, the three build
jobs only upload artifacts, and a single publish job creates the tag +
GitHub Release (auto-generated notes, prerelease when the version
contains "-") and uploads all platform binaries. Tag-push triggered
behavior is preserved.

🤖 Generated with Claude Code (Fable 5)

Co-Authored-By: Claude <noreply@anthropic.com>
Global model alias (model_alias_setting.mapping): resolve aliases to the
real model inside the distributor before token validation and channel
selection, so routing, billing and log model names all use the real
model. Supports chained mappings with cycle detection, rewrites the JSON
body model field so pass-through requests never leak the alias upstream,
and keeps the originally requested alias as a log annotation
(requested_model_alias). Admin UI: System Settings -> Models -> Global
Model Alias, reusing the visual model-mapping editor; saving validates
against self-mapping and cycles.

Channel failover (ChannelFailoverEnabled, default off, Operations ->
Behavior): when a request fails with a retryable error, move it to
another channel serving the same model in the same group. Failed
channels are excluded on both the memory-cache and DB selection paths,
the loop is independent of RetryTimes and terminates when candidates are
exhausted, returning the last upstream error instead of "no channel
available". Token-pinned channels and locked-channel task resumes never
fail over; with the switch off every path behaves exactly as before.

Tests: alias resolution/validation table tests and channel selection
exclusion tests (priority-index compatibility, exclusion fallback,
exhaustion, retry-index bypass, cache immutability).

🤖 Generated with Claude Code (Fable 5)

Co-Authored-By: Claude <noreply@anthropic.com>
@plana-autoreview

Copy link
Copy Markdown

Mira PR Walkthrough

🔍 Reviewing this PR…

@ItzArona ItzArona self-assigned this Jul 25, 2026
@ItzPlana
ItzPlana merged commit 81d86e3 into main Aug 12, 2026
0 of 2 checks passed
@ItzPlana
ItzPlana deleted the feat/release-alias-failover branch August 12, 2026 12:41
ItzPlana added a commit that referenced this pull request Aug 12, 2026
…pact suffix refs

Merge origin/main into feat/error-message-override. Resolved conflicts in
5 files by keeping both feature additions (error override settings and the
channel failover / model alias settings) side by side:
- model/option.go (ErrorOverrideEnabled + ChannelFailoverEnabled cases)
- system-behavior-section.tsx (both FormField blocks)
- operations/index.tsx, section-registry.tsx, types.ts (both fields)

While validating the merge, found that main's refactor bb234ff (QuantumNous#6770)
removed ratio_setting.CompactModelSuffix / WithCompactModelSuffix but the
failover/alias code merged in #8 still referenced them:
- setting/model_setting/model_alias.go: ResolveModelAlias stripped and
  re-added the compact suffix around alias resolution. Now resolves the
  requested name verbatim, matching QuantumNous#6770's removal of compact-suffix
  special-casing. Updated the compact test case to assert verbatim
  aliasing of a compact-suffixed name instead.
- middleware/distributor.go: dropped the strings.TrimSuffix(resolvedModel,
  ratio_setting.CompactModelSuffix) call so the rewritten request body
  model matches the resolved alias exactly.

Also fixed two pre-existing build/vet breakages from the #8 merge that
surfaced once compact-suffix references compiled:
- controller/relay.go: shouldRetryTaskRelay gained a failoverEnabled
  bool parameter on the call site (line 637) but the definition was not
  updated; added the parameter to the signature and removed the stale
  reference to the unqualified failoverEnabled identifier.
- model/channel_cache_failover_test.go: imported AdvancedCustomConfig
  from the root dto package, but it lives in relaykit/dto; switched the
  import alias accordingly.

Verified: go build ./... + go vet ./... pass, relaykit builds standalone
(GOWORK=off), and ./setting/operation_setting, ./service, ./model,
./setting/model_setting, relaykit/types tests all pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants