mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-20 08:57:57 +00:00
feat: proactive rate limiting (RPM) + 429 short cooldown for sources
- config.go: Source add RPM field (requests-per-minute cap, 0=unlimited) - provider.go: RecordRateLimit() — 429 uses fixed 30s cooldown, not exponential - provider.go: Throttle() — token-bucket proactive rate limiter, spaces requests at 60s/RPM interval, respects context cancellation - provider.go: ReportStatus() — 429 -> RecordRateLimit, 5xx -> RecordFailure - provider.go: Chat/ChatStream — wire Throttle after TryAcquire - api.go: sourcePayload + RPM, buildSource passes RPM through - ui/index.html: add RPM input field in source editor, bilingual i18n labels - deploy.sh: backup old binary + rollback on healthcheck failure - provider_test.go: TestModelStateRateLimitShortCooldown, TestThrottleSpacingAndCancel - config.yaml: sensenova rpm: 12
This commit is contained in:
@ -847,6 +847,7 @@
|
||||
mEp: "聊天端点",
|
||||
mImgEp: "生图端点",
|
||||
mConc: "并发上限",
|
||||
mRPM: "RPM 限速 (0=不限)",
|
||||
mTemp: "温度",
|
||||
mModels: "模型列表",
|
||||
mAddModel: "+ 模型",
|
||||
@ -1067,6 +1068,7 @@
|
||||
mEp: "Chat endpoint",
|
||||
mImgEp: "Image endpoint",
|
||||
mConc: "Max concurrency",
|
||||
mRPM: "RPM limit (0 = unlimited)",
|
||||
mTemp: "Temperature",
|
||||
mModels: "Models",
|
||||
mAddModel: "+ model",
|
||||
@ -2479,6 +2481,10 @@
|
||||
<div><label>${t("mConc")}</label><input id="s-conc" type="number" value="${s.max_concurrent || 8}"></div>
|
||||
<div><label>${t("mTemp")}</label><input id="s-temp" type="number" step="0.1" value="${s.temperature ?? 0.7}"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div><label>${t("mRPM")}</label><input id="s-rpm" type="number" min="0" placeholder="0 = 不限" value="${s.rpm || 0}"></div>
|
||||
<div></div>
|
||||
</div>
|
||||
<label>${t("mModels")}</label>
|
||||
<div id="s-models"></div>
|
||||
<button class="ghost small" onclick="addModelRow()">${t("mAddModel")}</button>
|
||||
@ -2537,6 +2543,7 @@
|
||||
endpoint: $("#s-ep").value.trim(),
|
||||
image_endpoint: $("#s-img").value.trim(),
|
||||
max_concurrent: parseInt($("#s-conc").value) || 8,
|
||||
rpm: parseInt($("#s-rpm").value) || 0,
|
||||
temperature: parseFloat($("#s-temp").value) || 0,
|
||||
models,
|
||||
meta,
|
||||
|
||||
Reference in New Issue
Block a user