fix(rate-limits): treat empty policies as unlimited

This commit is contained in:
2026-05-24 22:28:25 +08:00
parent 6d99e26e2a
commit 71950d2b4f
9 changed files with 168 additions and 45 deletions
@@ -343,10 +343,10 @@ export function PlatformManagementPanel(props: {
</FormSection>
<FormSection icon={<ShieldCheck size={16} />} title="限流策略">
<Label>RPM / <Input value={form.rpmLimit} placeholder="不填不限" inputMode="numeric" onChange={(event) => setForm({ ...form, rpmLimit: event.target.value })} /></Label>
<Label>RPS / <Input value={form.rpsLimit} placeholder="不填不限" inputMode="numeric" onChange={(event) => setForm({ ...form, rpsLimit: event.target.value })} /></Label>
<Label>TPM / Token<Input value={form.tpmLimit} placeholder="不填不限" inputMode="numeric" onChange={(event) => setForm({ ...form, tpmLimit: event.target.value })} /></Label>
<Label><Input value={form.concurrencyLimit} placeholder="不填不限" inputMode="numeric" onChange={(event) => setForm({ ...form, concurrencyLimit: event.target.value })} /></Label>
<Label>RPM / <Input value={form.rpmLimit} placeholder="不填或负数为不限" inputMode="numeric" onChange={(event) => setForm({ ...form, rpmLimit: event.target.value })} /></Label>
<Label>RPS / <Input value={form.rpsLimit} placeholder="不填或负数为不限" inputMode="numeric" onChange={(event) => setForm({ ...form, rpsLimit: event.target.value })} /></Label>
<Label>TPM / Token<Input value={form.tpmLimit} placeholder="不填或负数为不限" inputMode="numeric" onChange={(event) => setForm({ ...form, tpmLimit: event.target.value })} /></Label>
<Label><Input value={form.concurrencyLimit} placeholder="不填或负数为不限" inputMode="numeric" onChange={(event) => setForm({ ...form, concurrencyLimit: event.target.value })} /></Label>
<div className="platformTogglePair">
<ToggleField checked={form.supportBase64Input} label="支持 Base64 输入" onChange={(checked) => setForm({ ...form, supportBase64Input: checked })} />
<ToggleField checked={form.supportUrlInput} label="支持 URL 输入" onChange={(checked) => setForm({ ...form, supportUrlInput: checked })} />
@@ -1172,13 +1172,13 @@ function formatDiscountFactor(value: number | undefined) {
function platformRateLimitSummary(policy: IntegrationPlatform['rateLimitPolicy']) {
const rules = Array.isArray(policy?.rules) ? policy.rules : [];
if (!rules.length) {
return { title: '未设置', subtitle: '跟随全局或模型策略' };
return { title: '不限', subtitle: '未配置限流上限' };
}
const labels = rules
.filter((rule) => typeof rule.limit === 'number' && Number.isFinite(rule.limit))
.filter((rule) => typeof rule.limit === 'number' && Number.isFinite(rule.limit) && rule.limit > 0)
.map((rule) => `${rateLimitMetricText(rule.metric)} ${formatLimit(rule.limit)}`);
if (!labels.length) {
return { title: '未设置', subtitle: '跟随全局或模型策略' };
return { title: '不限', subtitle: '未配置限流上限' };
}
return {
title: labels.slice(0, 2).join(' · '),