From 8afcb479fa544b0b2b82250d6f36a3ad8179e6f8 Mon Sep 17 00:00:00 2001 From: hex2077 Date: Fri, 10 Apr 2026 15:55:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(api-potluck):=20=E4=BF=AE=E5=A4=8D=E4=BB=A4?= =?UTF-8?q?=E7=89=8C=E8=AE=A1=E6=95=B0=E5=9B=9E=E9=80=80=E5=B9=B6=E6=94=B9?= =?UTF-8?q?=E8=BF=9B=E6=98=BE=E7=A4=BA=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 normalizeUsageCandidate 中添加缺失的令牌计数回退字段(inputTokenCount/outputTokenCount) - 确保凭证切换重试上下文始终可用 - 为令牌数量添加紧凑格式化函数(K/M/G 单位),在多个统计页面中应用 - 更新版本号至 2.13.4 --- VERSION | 2 +- src/plugins/api-potluck/index.js | 6 ++++-- src/utils/common.js | 2 +- static/model-usage-stats.html | 10 +++++----- static/potluck-user.html | 24 +++++++++++++++++++++--- static/potluck.html | 28 +++++++++++++++++++++++----- 6 files changed, 55 insertions(+), 17 deletions(-) diff --git a/VERSION b/VERSION index a1a4224..965a689 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.13.3 +2.13.4 diff --git a/src/plugins/api-potluck/index.js b/src/plugins/api-potluck/index.js index 48a9eb9..4839cfd 100644 --- a/src/plugins/api-potluck/index.js +++ b/src/plugins/api-potluck/index.js @@ -51,13 +51,15 @@ function normalizeUsageCandidate(candidate) { candidate.prompt_tokens ?? usage?.prompt_tokens ?? usage?.input_tokens ?? - usage?.promptTokenCount + usage?.promptTokenCount ?? + usage?.inputTokenCount ); const completionTokens = toNumber( candidate.completion_tokens ?? usage?.completion_tokens ?? usage?.output_tokens ?? - usage?.candidatesTokenCount + usage?.candidatesTokenCount ?? + usage?.outputTokenCount ); const totalTokens = toNumber( candidate.total_tokens ?? diff --git a/src/utils/common.js b/src/utils/common.js index b65929d..b8d50ae 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -1025,7 +1025,7 @@ export async function handleContentGenerationRequest(req, res, service, endpoint // - 凭证切换重试:凭证被标记不健康后切换到其他凭证 // 当没有不同的健康凭证可用时,重试会自动停止 const credentialSwitchMaxRetries = CONFIG.CREDENTIAL_SWITCH_MAX_RETRIES || 5; - const retryContext = providerPoolManager ? { CONFIG, currentRetry: 0, maxRetries: credentialSwitchMaxRetries } : null; + const retryContext = { CONFIG, currentRetry: 0, maxRetries: credentialSwitchMaxRetries }; if (isStream) { await handleStreamRequest(res, service, model, processedRequestBody, fromProvider, toProvider, CONFIG.PROMPT_LOG_MODE, PROMPT_LOG_FILENAME, providerPoolManager, actualUuid, actualCustomName, retryContext); diff --git a/static/model-usage-stats.html b/static/model-usage-stats.html index 28b64a7..6a9b33e 100644 --- a/static/model-usage-stats.html +++ b/static/model-usage-stats.html @@ -103,7 +103,7 @@ import{initThemeSwitcher,setTheme,getCurrentTheme}from'./app/theme-switcher.js';setTheme(getCurrentTheme());initThemeSwitcher('themeToggle');