feat(ollama): 支持 Cloud 官方用量自动刷新

This commit is contained in:
alfadb committed 2026-07-23 15:50:44 +08:00
1 parent 2c76506e07
commit 5ac4a9fac2
47 files changed
+5571 -85

No files matched your search

@@ -173,6 +173,55 @@ export default {
hint: 'Displayed as "group / base score / sticky bonus". The base score is computed within the current filtered candidate set and includes priority, load, queue depth, error rate, first-token latency, reset window, quota headroom, billing rate, and related factors. The sticky bonus applies only when sticky weighting is enabled for previous_response_id or session_hash. Higher scores are preferred.'
},
usageWindowsHint: '"5h / 7d" are the upstream account\'s official rolling usage windows (e.g. OpenAI ChatGPT, Claude). They are imposed by the upstream provider on the account itself — not configured by sub2api, and unrelated to the models you map. Usage resets automatically once each window rolls over, and the limit cannot be lifted from within sub2api.',
ollamaCloud: {
title: 'Ollama Cloud usage',
sessionSecurityHint: 'The browser session is encrypted at rest and sent only to the fixed official settings URL.',
configured: 'Configured',
notConfigured: 'Not configured',
notRefreshed: 'Not refreshed',
encryptionKeyRequired: 'Set a persistent TOTP_ENCRYPTION_KEY before storing a browser session.',
sessionLabel: 'Ollama browser Cookie',
sessionPlaceholder: 'wos-session=...; __Secure-authjs.session-token.0=...',
writeOnlyHint: 'Write-only. The saved value cannot be viewed and an empty value never replaces it.',
deleteSession: 'Delete session',
deleteConfirm: 'Delete the stored Ollama browser session and its usage snapshot?',
refreshNow: 'Refresh usage',
autoRefresh: 'Automatic usage refresh',
autoRefreshHint: 'Runs only when the account switch and the global switch are both enabled.',
plan: 'Plan',
fiveHour: '5 hour',
fiveHourShort: '5h',
sevenDay: '7 day',
sevenDayShort: '7d',
balance: 'Balance',
models: 'Models',
status: 'Status',
updatedAt: 'Updated',
ok: 'Current',
unauthorized: 'Session expired',
failed: 'Refresh failed',
windowWithReset: '{percent} used, resets {reset}',
loadFailed: 'Failed to load Ollama Cloud usage settings',
sessionSaved: 'Ollama browser session saved',
sessionSaveFailed: 'Failed to save Ollama browser session',
sessionDeleted: 'Ollama browser session deleted',
sessionDeleteFailed: 'Failed to delete Ollama browser session',
autoRefreshFailed: 'Failed to update automatic usage refresh',
refreshSuccess: 'Ollama Cloud usage refreshed',
refreshFailed: 'Failed to refresh Ollama Cloud usage',
errors: {
request_failed: 'Request failed',
empty_response: 'Empty response',
response_host_mismatch: 'Unexpected response host',
redirect_blocked: 'Official settings redirected the request',
unauthorized: 'Browser session expired',
http_error: 'Official settings returned an error',
response_read_failed: 'Failed to read the response',
response_too_large: 'Settings page exceeded the response limit',
invalid_html: 'Settings page format was not recognized',
OLLAMA_CLOUD_USAGE_REFRESH_RATE_LIMITED: 'Refresh is limited. Try again in {retry_after_seconds} seconds.'
}
},
upstreamBilling: {
trustWarning: 'This rate is declared by the upstream site for the current API key. Sub2API cannot verify that it matches actual charges. The upstream site or an intermediary may return forged, stale, or modified data. Verify it against bills, balance changes, and actual usage.',
autoProbe: 'Automatically probe upstream declared rate',
@@ -333,6 +333,16 @@ export default {
saved: 'Upstream rate auto detection settings saved',
saveFailed: 'Failed to save upstream rate auto detection settings'
},
ollamaCloudUsage: {
title: 'Ollama Cloud Usage Refresh',
description: 'Periodically refresh official Ollama settings-page usage for individually opted-in accounts. Disabled by default.',
enabled: 'Enable global automatic refresh',
enabledHint: 'Only accounts with a stored browser session and their own automatic refresh switch enabled are refreshed. Manual refresh remains available.',
intervalMinutes: 'Refresh interval (minutes)',
intervalHint: 'Range: 15–1440 minutes. Failures use bounded exponential backoff.',
saved: 'Ollama Cloud usage refresh settings saved',
saveFailed: 'Failed to save Ollama Cloud usage refresh settings'
},
gatewayForwarding: {
title: 'Request Forwarding',
description: 'Control how requests are forwarded to upstream OAuth accounts',
@@ -126,6 +126,55 @@ export default {
hint: '显示格式为“分组名 / 基础分 / 粘性加分”。基础分按当前筛选条件限定的候选账号计算,包含优先级、负载、排队、错误率、首包延迟、重置窗口、额度余量、计费倍率等因子;粘性加分只在开启粘性加权时用于 previous_response_id 或 session_hash。分数越大越优先。'
},
usageWindowsHint: '“5h / 7d”是上游账号(如 OpenAI ChatGPT、Claude)官方的滚动用量窗口限制,由上游对账号设定,并非 sub2api 配置,也与你映射的模型无关。窗口滚动到期后用量会自动重置,无法在 sub2api 端解除该限制。',
ollamaCloud: {
title: 'Ollama Cloud 用量',
sessionSecurityHint: '浏览器会话会加密落库,且只发送到固定的 Ollama 官方设置页。',
configured: '已配置',
notConfigured: '未配置',
notRefreshed: '尚未刷新',
encryptionKeyRequired: '请先配置持久 TOTP_ENCRYPTION_KEY,再保存浏览器会话。',
sessionLabel: 'Ollama 浏览器 Cookie',
sessionPlaceholder: 'wos-session=...; __Secure-authjs.session-token.0=...',
writeOnlyHint: '仅写入。已保存内容不可查看,留空不会覆盖。',
deleteSession: '删除会话',
deleteConfirm: '确定删除已保存的 Ollama 浏览器会话及其用量快照?',
refreshNow: '刷新用量',
autoRefresh: '自动刷新用量',
autoRefreshHint: '只有账号开关和全局开关同时启用时才会定时刷新。',
plan: '套餐',
fiveHour: '5 小时',
fiveHourShort: '5h',
sevenDay: '7 天',
sevenDayShort: '7d',
balance: '余额',
models: '模型',
status: '状态',
updatedAt: '更新时间',
ok: '正常',
unauthorized: '会话已过期',
failed: '刷新失败',
windowWithReset: '已用 {percent},{reset} 重置',
loadFailed: '加载 Ollama Cloud 用量设置失败',
sessionSaved: 'Ollama 浏览器会话已保存',
sessionSaveFailed: '保存 Ollama 浏览器会话失败',
sessionDeleted: 'Ollama 浏览器会话已删除',
sessionDeleteFailed: '删除 Ollama 浏览器会话失败',
autoRefreshFailed: '更新自动刷新设置失败',
refreshSuccess: 'Ollama Cloud 用量已刷新',
refreshFailed: '刷新 Ollama Cloud 用量失败',
errors: {
request_failed: '请求失败',
empty_response: '响应为空',
response_host_mismatch: '响应主机不符合安全边界',
redirect_blocked: '官方设置页发生重定向',
unauthorized: '浏览器会话已过期',
http_error: '官方设置页返回错误',
response_read_failed: '读取响应失败',
response_too_large: '设置页超过响应大小限制',
invalid_html: '无法识别设置页格式',
OLLAMA_CLOUD_USAGE_REFRESH_RATE_LIMITED: '刷新过于频繁,请在 {retry_after_seconds} 秒后重试。'
}
},
upstreamBilling: {
trustWarning: '此倍率由上游站点针对当前 API Key 自行声明。Sub2API 无法验证该值是否与实际扣费一致;上游站点或中间代理可能返回伪造、过期或被篡改的数据。请结合账单、余额变化和实际用量自行核验。',
autoProbe: '自动探测上游声明倍率',
@@ -326,6 +326,16 @@ export default {
saved: '上游倍率自动探测设置已保存',
saveFailed: '保存上游倍率自动探测设置失败'
},
ollamaCloudUsage: {
title: 'Ollama Cloud 用量刷新',
description: '定期刷新账号在 Ollama 官方设置页展示的用量;默认关闭。',
enabled: '启用全局自动刷新',
enabledHint: '仅刷新已保存浏览器会话且账号自身也开启自动刷新的账号;手动刷新不受影响。',
intervalMinutes: '刷新周期(分钟)',
intervalHint: '范围 15–1440 分钟。失败后按有上限的指数退避重试。',
saved: 'Ollama Cloud 用量刷新设置已保存',
saveFailed: '保存 Ollama Cloud 用量刷新设置失败'
},
gatewayForwarding: {
title: '请求转发行为',
description: '控制请求转发到上游 OAuth 账号时的行为',