fix(models): 系统渠道模型 - 上游 ID 重命名级联价格档并补管理端可见性
根因:价格档 provider_model_key 非空时优先于模型级上游键发往供应商,统一价格档曾把当时的顶层上游键固化为档位显式值,模型级重命名后被旧值静默遮蔽,任务请求继续发往旧上游模型(Agent 及其他入口共用该解析路径)。 - SaveAdminChannelModel 在模型级上游键变更时,把与旧值相同的档位键级联为新值;管理员显式配置的其他上游 SKU 不受影响 - 编辑无价格档旧模型不再预填顶层上游键;统一价格档检测到与模型级不一致的存量上游键时展示告警并支持一键清除恢复跟随模型默认;模型身份区提示档位独立上游键数量,比较口径统一剥 models/ 前缀 - 新增后端级联与请求解析回归测试、前端价格档表单单测 - 同步 backend-database.mdx 价格档语义与 pending-test.mdx 待验收项
This commit is contained in:
1 parent
9868f5e8b8
commit
25e78fe4f8
8 files changed
+222
-5
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import { Button, Form, Input, InputNumber, Segmented, Select, Switch, type FormInstance } from "antd";
|
||||
import { Alert, Button, Form, Input, InputNumber, Segmented, Select, Switch, type FormInstance } from "antd";
|
||||
import { Trash2 } from "lucide-react";
|
||||
import type { ModelCapabilityConfig } from "@/lib/model-capabilities";
|
||||
import { modelProtocolSupportsTokenBilling, type ModelProtocol } from "@/lib/model-protocols";
|
||||
import type { ModelCapabilityChoice as EditableCapability } from "@/components/model-protocol-picker";
|
||||
import type { ChannelModelFormValues as FormValues } from "./channel-model-editor-form";
|
||||
import { normalizeUpstreamModelKey } from "./channel-model-price-tier-form";
|
||||
|
||||
export function PriceTierFields({
|
||||
index,
|
||||
@@ -12,6 +13,7 @@ export function PriceTierFields({
|
||||
capability,
|
||||
protocol,
|
||||
capabilityConfig,
|
||||
modelUpstream,
|
||||
onDirty,
|
||||
onRemove,
|
||||
}: {
|
||||
@@ -21,6 +23,7 @@ export function PriceTierFields({
|
||||
capability: EditableCapability | undefined;
|
||||
protocol: ModelProtocol | undefined;
|
||||
capabilityConfig?: ModelCapabilityConfig;
|
||||
modelUpstream: string;
|
||||
onDirty: () => void;
|
||||
onRemove: () => void;
|
||||
}) {
|
||||
@@ -28,6 +31,10 @@ export function PriceTierFields({
|
||||
const matchMode = Form.useWatch(["priceTiers", index, "matchMode"], form) || "default";
|
||||
const priceConfigured = Form.useWatch(["priceTiers", index, "priceConfigured"], form) !== false;
|
||||
const tierEnabled = Form.useWatch(["priceTiers", index, "enabled"], form) !== false;
|
||||
const tierUpstream = normalizeUpstreamModelKey(Form.useWatch(["priceTiers", index, "providerModelKey"], form));
|
||||
// 统一价格档不展示上游键输入,但历史数据可能固化了独立键;它与模型级不一致时会
|
||||
// 静默改变实际发往供应商的模型,必须显式提示并允许一键恢复“跟随模型默认”。
|
||||
const staleTierUpstream = matchMode === "default" && tierUpstream && modelUpstream && tierUpstream !== modelUpstream ? tierUpstream : "";
|
||||
const video = capabilityConfig?.video;
|
||||
const resolutionOptions = video?.resolutions || [];
|
||||
const durationOptions = video?.duration.selection === "enum" ? video.duration.values || [] : [];
|
||||
@@ -155,6 +162,25 @@ export function PriceTierFields({
|
||||
</Form.Item>
|
||||
</div>
|
||||
)}
|
||||
{staleTierUpstream ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
title="该统一价格档仍指向独立上游模型 ID"
|
||||
description={`命中此档的请求会优先使用「${staleTierUpstream}」,而不是模型默认上游「${modelUpstream}」。`}
|
||||
action={
|
||||
<Button
|
||||
size="small"
|
||||
onClick={() => {
|
||||
onDirty();
|
||||
form.setFieldValue(["priceTiers", index, "providerModelKey"], "");
|
||||
}}
|
||||
>
|
||||
清除并跟随模型
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user