feat(compute): 模型能力检测改为手动按钮(去掉失焦自动)

- 移除 actual_model 失焦自动检测; 能力区加「检测支持能力」按钮, 点击按当前模型预填能力
This commit is contained in:
Pine
2026-08-25 13:19:58 +08:00
parent 1948434110
commit 02d390646e
+9 -3
View File
@@ -123,11 +123,14 @@ function ModelFormDialog({ open, row, onClose, onDone }: { open: boolean; row: R
const channel = channels.find((c) => c.id === Number(f.vendor_id));
const avail = channelModels(channel);
const set = (k: string, v: any) => setF((p) => ({ ...p, [k]: v }));
const [detecting, setDetecting] = React.useState(false);
// 选中模型后自动检测能力(视觉/图像/音频/视频)并预填
// 动检测能力(视觉/图像/音频/视频)并预填
const detectCaps = async (mid: string) => {
if (!mid) return;
setDetecting(true);
const out = await computeAction<any>("POST", "model/capabilities", { model: mid });
setDetecting(false);
if (out.ok && out.data) {
const c = out.data;
setF((p) => ({ ...p, vision_support: !!c.vision_support, image_support: !!c.image_support,
@@ -185,7 +188,6 @@ function ModelFormDialog({ open, row, onClose, onDone }: { open: boolean; row: R
<Field label="实际使用的模型" full>
<Input list="model-suggest" value={f.actual_model || f.model_name}
onChange={(e) => set("actual_model", e.target.value)}
onBlur={(e) => detectCaps(e.target.value)}
placeholder="选择或输入上游模型名" />
<datalist id="model-suggest">
{avail.map((m) => <option key={m} value={m} />)}
@@ -198,7 +200,7 @@ function ModelFormDialog({ open, row, onClose, onDone }: { open: boolean; row: R
<Field label="缓存命中价格(¥)"><Input type="number" value={f.cache_hit_price} onChange={(e) => set("cache_hit_price", e.target.value)} /></Field>
<Field label="标签"><Input value={f.tags || ""} onChange={(e) => set("tags", e.target.value)} /></Field>
<Field label="描述" full><Input value={f.description || ""} onChange={(e) => set("description", e.target.value)} /></Field>
<Field label="支持能力(选中模型自动检测)" full>
<Field label="支持能力" full>
<div className="flex flex-wrap gap-4 text-sm">
{[
["vision_support", "视觉理解"],
@@ -211,6 +213,10 @@ function ModelFormDialog({ open, row, onClose, onDone }: { open: boolean; row: R
</label>
))}
</div>
<Button type="button" variant="outline" size="sm" className="mt-2"
onClick={() => detectCaps(f.actual_model || f.model_name)}>
<Loader2 className={detecting ? "animate-spin" : ""} />
</Button>
</Field>
<Field label="状态"><Select value={String(f.status ?? 1)} onValueChange={(v) => set("status", Number(v))}>
<SelectTrigger><SelectValue /></SelectTrigger><SelectContent>