fix(composite): pass the requested model through when a prefix route leaves upstream_model empty

Composite model routes support a match_type: prefix mode with an optional
upstream_model. Leaving upstream_model empty is meant to pass the concrete
requested model through to the upstream, but every request matching the prefix
collapsed to the route's public_model instead. A route with
public_model=deepseek-v4, match_type=prefix and an empty upstream_model
forwarded both deepseek-v4-flash and deepseek-v4-pro upstream as deepseek-v4.

Root cause: normalizeCompositeRouteInput backfilled an empty upstream_model with
public_model at save time, so CompositeRouteResolver.Resolve never reached its
"upstreamModel == '' -> concrete requested model" fallback.

- Skip the backfill for prefix routes only; an empty upstream_model stays empty
  and Resolve passes the concrete requested model through.
- exact routes keep the backfill (model == public_model, so persisted/display
  contract is unchanged).
- Explicit upstream_model still forwards that fixed model in every mode.
- Frontend: add an upstream_model hint (zh/en) documenting empty = passthrough.
This commit is contained in:
visa2
2026-07-25 10:20:50 +08:00
parent cb24522dd5
commit 386b57bb77
6 changed files with 93 additions and 2 deletions
@@ -1031,6 +1031,7 @@ export default {
endpoint: 'Endpoint',
targetPlatform: 'Target Platform',
upstreamModel: 'Upstream Model',
upstreamModelHint: 'Leave empty to pass the original requested model through: under prefix match each matched model forwards verbatim (e.g. deepseek-v4-flash and deepseek-v4-pro each forwarded as-is); set a value to forward every matched request to that fixed model.',
notes: 'Notes',
enabled: 'Enabled',
preview: 'Preview',
@@ -1028,6 +1028,7 @@ export default {
endpoint: '端点',
targetPlatform: '目标平台',
upstreamModel: '上游模型',
upstreamModelHint: '留空表示透传原始请求模型:前缀匹配下每个命中模型各自原样转发(如 deepseek-v4-flash、deepseek-v4-pro 分别转发);填写则所有命中请求都固定转发该模型。',
notes: '备注',
enabled: '启用',
preview: '预览',
+3
View File
@@ -3809,6 +3809,9 @@
class="input"
placeholder="gpt-5"
/>
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
{{ t("admin.groups.compositeRoutes.upstreamModelHint") }}
</p>
</div>
<div>