From c7f4a649dfa9322179e9e9d75196cba0dc6d8f86 Mon Sep 17 00:00:00 2001
From: Wang Lvyuan <74089601+LvyuanW@users.noreply.github.com>
Date: Fri, 27 Mar 2026 13:54:59 +0800
Subject: [PATCH 01/23] fix(admin): use custom select for ops log filters
---
.../ops/components/OpsSystemLogTable.vue | 63 +++++++++++--------
1 file changed, 36 insertions(+), 27 deletions(-)
diff --git a/frontend/src/views/admin/ops/components/OpsSystemLogTable.vue b/frontend/src/views/admin/ops/components/OpsSystemLogTable.vue
index d2aeb3ca31..bfc9397dca 100644
--- a/frontend/src/views/admin/ops/components/OpsSystemLogTable.vue
+++ b/frontend/src/views/admin/ops/components/OpsSystemLogTable.vue
@@ -2,6 +2,7 @@
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { opsAPI, type OpsRuntimeLogConfig, type OpsSystemLog, type OpsSystemLogSinkHealth } from '@/api/admin/ops'
import Pagination from '@/components/common/Pagination.vue'
+import Select from '@/components/common/Select.vue'
import { useAppStore } from '@/stores'
const appStore = useAppStore()
@@ -56,6 +57,37 @@ const filters = reactive({
q: ''
})
+const runtimeLevelOptions = [
+ { value: 'debug', label: 'debug' },
+ { value: 'info', label: 'info' },
+ { value: 'warn', label: 'warn' },
+ { value: 'error', label: 'error' }
+]
+
+const stacktraceLevelOptions = [
+ { value: 'none', label: 'none' },
+ { value: 'error', label: 'error' },
+ { value: 'fatal', label: 'fatal' }
+]
+
+const timeRangeOptions = [
+ { value: '5m', label: '5m' },
+ { value: '30m', label: '30m' },
+ { value: '1h', label: '1h' },
+ { value: '6h', label: '6h' },
+ { value: '24h', label: '24h' },
+ { value: '7d', label: '7d' },
+ { value: '30d', label: '30d' }
+]
+
+const filterLevelOptions = [
+ { value: '', label: '全部' },
+ { value: 'debug', label: 'debug' },
+ { value: 'info', label: 'info' },
+ { value: 'warn', label: 'warn' },
+ { value: 'error', label: 'error' }
+]
+
const levelBadgeClass = (level: string) => {
const v = String(level || '').toLowerCase()
if (v === 'error' || v === 'fatal') return 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300'
@@ -347,20 +379,11 @@ onMounted(async () => {
+
+
+
+
+
+
{{ t('admin.accounts.quotaControl.customBaseUrl.label') }}
+
+ {{ t('admin.accounts.quotaControl.customBaseUrl.hint') }}
+
+
+
+
+
+
+
+
@@ -3095,6 +3130,8 @@ const tlsFingerprintProfiles = ref<{ id: number; name: string }[]>([])
const sessionIdMaskingEnabled = ref(false)
const cacheTTLOverrideEnabled = ref(false)
const cacheTTLOverrideTarget = ref('5m')
+const customBaseUrlEnabled = ref(false)
+const customBaseUrl = ref('')
// Gemini tier selection (used as fallback when auto-detection is unavailable/fails)
const geminiTierGoogleOne = ref<'google_one_free' | 'google_ai_pro' | 'google_ai_ultra'>('google_one_free')
@@ -3765,6 +3802,8 @@ const resetForm = () => {
sessionIdMaskingEnabled.value = false
cacheTTLOverrideEnabled.value = false
cacheTTLOverrideTarget.value = '5m'
+ customBaseUrlEnabled.value = false
+ customBaseUrl.value = ''
allowOverages.value = false
antigravityAccountType.value = 'oauth'
upstreamBaseUrl.value = ''
@@ -4856,6 +4895,12 @@ const handleAnthropicExchange = async (authCode: string) => {
extra.cache_ttl_override_target = cacheTTLOverrideTarget.value
}
+ // Add custom base URL settings
+ if (customBaseUrlEnabled.value && customBaseUrl.value.trim()) {
+ extra.custom_base_url_enabled = true
+ extra.custom_base_url = customBaseUrl.value.trim()
+ }
+
const credentials: Record = { ...tokenInfo }
applyInterceptWarmup(credentials, interceptWarmupRequests.value, 'create')
await createAccountAndFinish(form.platform, addMethod.value as AccountType, credentials, extra)
@@ -4974,6 +5019,12 @@ const handleCookieAuth = async (sessionKey: string) => {
extra.cache_ttl_override_target = cacheTTLOverrideTarget.value
}
+ // Add custom base URL settings
+ if (customBaseUrlEnabled.value && customBaseUrl.value.trim()) {
+ extra.custom_base_url_enabled = true
+ extra.custom_base_url = customBaseUrl.value.trim()
+ }
+
const accountName = keys.length > 1 ? `${form.name} #${i + 1}` : form.name
const credentials: Record = { ...tokenInfo }
diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue
index da6c97157f..607e7a69de 100644
--- a/frontend/src/components/account/EditAccountModal.vue
+++ b/frontend/src/components/account/EditAccountModal.vue
@@ -1580,6 +1580,41 @@
+
+
+
+
+
+
{{ t('admin.accounts.quotaControl.customBaseUrl.label') }}
+
+ {{ t('admin.accounts.quotaControl.customBaseUrl.hint') }}
+
+
+
+
+
+
+
+
@@ -1854,6 +1889,8 @@ const tlsFingerprintProfiles = ref<{ id: number; name: string }[]>([])
const sessionIdMaskingEnabled = ref(false)
const cacheTTLOverrideEnabled = ref(false)
const cacheTTLOverrideTarget = ref('5m')
+const customBaseUrlEnabled = ref(false)
+const customBaseUrl = ref('')
// OpenAI 自动透传开关(OAuth/API Key)
const openaiPassthroughEnabled = ref(false)
@@ -2482,6 +2519,8 @@ function loadQuotaControlSettings(account: Account) {
sessionIdMaskingEnabled.value = false
cacheTTLOverrideEnabled.value = false
cacheTTLOverrideTarget.value = '5m'
+ customBaseUrlEnabled.value = false
+ customBaseUrl.value = ''
// Only applies to Anthropic OAuth/SetupToken accounts
if (account.platform !== 'anthropic' || (account.type !== 'oauth' && account.type !== 'setup-token')) {
@@ -2528,6 +2567,12 @@ function loadQuotaControlSettings(account: Account) {
cacheTTLOverrideEnabled.value = true
cacheTTLOverrideTarget.value = account.cache_ttl_override_target || '5m'
}
+
+ // Load custom base URL setting
+ if (account.custom_base_url_enabled === true) {
+ customBaseUrlEnabled.value = true
+ customBaseUrl.value = account.custom_base_url || ''
+ }
}
function formatTempUnschedKeywords(value: unknown) {
@@ -2980,6 +3025,15 @@ const handleSubmit = async () => {
delete newExtra.cache_ttl_override_target
}
+ // Custom base URL relay setting
+ if (customBaseUrlEnabled.value && customBaseUrl.value.trim()) {
+ newExtra.custom_base_url_enabled = true
+ newExtra.custom_base_url = customBaseUrl.value.trim()
+ } else {
+ delete newExtra.custom_base_url_enabled
+ delete newExtra.custom_base_url
+ }
+
updatePayload.extra = newExtra
}
diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts
index 07a0e63412..d1f55e58bd 100644
--- a/frontend/src/i18n/locales/en.ts
+++ b/frontend/src/i18n/locales/en.ts
@@ -2318,6 +2318,11 @@ export default {
target: 'Target TTL',
targetHint: 'Select the TTL tier for billing'
},
+ customBaseUrl: {
+ label: 'Custom Relay URL',
+ hint: 'Forward requests to a custom relay service. Proxy URL will be passed as a query parameter.',
+ urlHint: 'Relay service URL (e.g., https://relay.example.com)',
+ },
clientAffinity: {
label: 'Client Affinity Scheduling',
hint: 'When enabled, new sessions prefer accounts previously used by this client to reduce account switching'
diff --git a/frontend/src/i18n/locales/zh.ts b/frontend/src/i18n/locales/zh.ts
index a6b6e8b51a..55634bd883 100644
--- a/frontend/src/i18n/locales/zh.ts
+++ b/frontend/src/i18n/locales/zh.ts
@@ -2462,6 +2462,11 @@ export default {
target: '目标 TTL',
targetHint: '选择计费使用的 TTL 类型'
},
+ customBaseUrl: {
+ label: '自定义转发地址',
+ hint: '启用后将请求转发到自定义中继服务,代理地址将作为 URL 参数传递给中继服务',
+ urlHint: '中继服务地址(如 https://relay.example.com)',
+ },
clientAffinity: {
label: '客户端亲和调度',
hint: '启用后,新会话会优先调度到该客户端之前使用过的账号,避免频繁切换账号'
diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts
index 8ab482167c..f9425ad0a7 100644
--- a/frontend/src/types/index.ts
+++ b/frontend/src/types/index.ts
@@ -734,6 +734,10 @@ export interface Account {
cache_ttl_override_enabled?: boolean | null
cache_ttl_override_target?: string | null
+ // 自定义 Base URL 中继转发(仅 Anthropic OAuth/SetupToken 账号有效)
+ custom_base_url_enabled?: boolean | null
+ custom_base_url?: string | null
+
// 客户端亲和调度(仅 Anthropic/Antigravity 平台有效)
// 启用后新会话会优先调度到客户端之前使用过的账号
client_affinity_enabled?: boolean | null
From 61607990c82c920851e24b1603e901720629ab38 Mon Sep 17 00:00:00 2001
From: QTom
Date: Mon, 30 Mar 2026 10:32:59 +0800
Subject: [PATCH 21/23] =?UTF-8?q?fix(lifecycle):=20TokenRefreshService=20S?=
=?UTF-8?q?top()=20=E9=98=B2=E9=87=8D=E5=A4=8D=20close?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
使用 sync.Once 包裹 close(stopCh),避免多次调用 Stop() 时
触发 panic: close of closed channel。
---
backend/internal/service/token_refresh_service.go | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/backend/internal/service/token_refresh_service.go b/backend/internal/service/token_refresh_service.go
index eb3e5592c0..8f94938234 100644
--- a/backend/internal/service/token_refresh_service.go
+++ b/backend/internal/service/token_refresh_service.go
@@ -32,8 +32,9 @@ type TokenRefreshService struct {
privacyClientFactory PrivacyClientFactory
proxyRepo ProxyRepository
- stopCh chan struct{}
- wg sync.WaitGroup
+ stopCh chan struct{}
+ stopOnce sync.Once
+ wg sync.WaitGroup
}
// NewTokenRefreshService 创建token刷新服务
@@ -130,7 +131,9 @@ func (s *TokenRefreshService) Start() {
// Stop 停止刷新服务(可安全多次调用)
func (s *TokenRefreshService) Stop() {
- close(s.stopCh)
+ s.stopOnce.Do(func() {
+ close(s.stopCh)
+ })
s.wg.Wait()
slog.Info("token_refresh.service_stopped")
}
From ab3e44e4bd23265fdaaf74121db3e5f4df4458a8 Mon Sep 17 00:00:00 2001
From: shaw
Date: Mon, 30 Mar 2026 11:28:27 +0800
Subject: [PATCH 22/23] =?UTF-8?q?fix:=20=E9=80=82=E9=85=8DX-Claude-Code-Se?=
=?UTF-8?q?ssion-Id=E5=A4=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/internal/service/gateway_service.go | 20 ++++++++++++++++++++
backend/internal/service/header_util.go | 8 ++++++++
2 files changed, 28 insertions(+)
diff --git a/backend/internal/service/gateway_service.go b/backend/internal/service/gateway_service.go
index 44214b6563..b54f463bde 100644
--- a/backend/internal/service/gateway_service.go
+++ b/backend/internal/service/gateway_service.go
@@ -369,6 +369,8 @@ var allowedHeaders = map[string]bool{
"user-agent": true,
"content-type": true,
"accept-encoding": true,
+ "x-claude-code-session-id": true,
+ "x-client-request-id": true,
}
// GatewayCache 定义网关服务的缓存操作接口。
@@ -5756,6 +5758,15 @@ func (s *GatewayService) buildUpstreamRequest(ctx context.Context, c *gin.Contex
}
}
+ // 同步 X-Claude-Code-Session-Id 头:取 body 中已处理的 metadata.user_id 的 session_id 覆盖
+ if sessionHeader := getHeaderRaw(req.Header, "X-Claude-Code-Session-Id"); sessionHeader != "" {
+ if uid := gjson.GetBytes(body, "metadata.user_id").String(); uid != "" {
+ if parsed := ParseMetadataUserID(uid); parsed != nil {
+ setHeaderRaw(req.Header, "X-Claude-Code-Session-Id", parsed.SessionID)
+ }
+ }
+ }
+
// === DEBUG: 打印上游转发请求(headers + body 摘要),与 CLIENT_ORIGINAL 对比 ===
s.debugLogGatewaySnapshot("UPSTREAM_FORWARD", req.Header, body, map[string]string{
"url": req.URL.String(),
@@ -8475,6 +8486,15 @@ func (s *GatewayService) buildCountTokensRequest(ctx context.Context, c *gin.Con
}
}
+ // 同步 X-Claude-Code-Session-Id 头:取 body 中已处理的 metadata.user_id 的 session_id 覆盖
+ if sessionHeader := getHeaderRaw(req.Header, "X-Claude-Code-Session-Id"); sessionHeader != "" {
+ if uid := gjson.GetBytes(body, "metadata.user_id").String(); uid != "" {
+ if parsed := ParseMetadataUserID(uid); parsed != nil {
+ setHeaderRaw(req.Header, "X-Claude-Code-Session-Id", parsed.SessionID)
+ }
+ }
+ }
+
if c != nil && tokenType == "oauth" {
c.Set(claudeMimicDebugInfoKey, buildClaudeMimicDebugLine(req, body, account, tokenType, mimicClaudeCode))
}
diff --git a/backend/internal/service/header_util.go b/backend/internal/service/header_util.go
index 6acfee5a40..1091070df0 100644
--- a/backend/internal/service/header_util.go
+++ b/backend/internal/service/header_util.go
@@ -36,6 +36,11 @@ var headerWireCasing = map[string]string{
"sec-fetch-mode": "sec-fetch-mode",
"accept-encoding": "accept-encoding",
"authorization": "authorization",
+
+ // Claude Code 2.1.87+ 新增 header
+ "x-claude-code-session-id": "X-Claude-Code-Session-Id",
+ "x-client-request-id": "x-client-request-id",
+ "content-length": "content-length",
}
// headerWireOrder 定义真实 Claude CLI 发送 header 的顺序(基于抓包)。
@@ -55,11 +60,14 @@ var headerWireOrder = []string{
"authorization",
"x-app",
"User-Agent",
+ "X-Claude-Code-Session-Id",
"content-type",
"anthropic-beta",
+ "x-client-request-id",
"accept-language",
"sec-fetch-mode",
"accept-encoding",
+ "content-length",
"x-stainless-helper-method",
}
From 50288e6b01b806dc2ba57f31bbe5c499b50728be Mon Sep 17 00:00:00 2001
From: shaw
Date: Mon, 30 Mar 2026 15:36:53 +0800
Subject: [PATCH 23/23] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A8=A1?=
=?UTF-8?q?=E5=9E=8B=E5=AE=9A=E4=BB=B7=E6=96=87=E4=BB=B6=E6=9B=B4=E6=96=B0?=
=?UTF-8?q?url?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/internal/config/config.go | 4 +-
backend/internal/service/pricing_service.go | 96 +++++++++++++--------
deploy/config.example.yaml | 4 +-
3 files changed, 62 insertions(+), 42 deletions(-)
diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go
index d1cb76dbb7..3ee5d6cdca 100644
--- a/backend/internal/config/config.go
+++ b/backend/internal/config/config.go
@@ -1281,8 +1281,8 @@ func setDefaults() {
viper.SetDefault("rate_limit.oauth_401_cooldown_minutes", 10)
// Pricing - 从 model-price-repo 同步模型定价和上下文窗口数据(固定到 commit,避免分支漂移)
- viper.SetDefault("pricing.remote_url", "https://raw.githubusercontent.com/Wei-Shaw/model-price-repo/c7947e9871687e664180bc971d4837f1fc2784a9/model_prices_and_context_window.json")
- viper.SetDefault("pricing.hash_url", "https://raw.githubusercontent.com/Wei-Shaw/model-price-repo/c7947e9871687e664180bc971d4837f1fc2784a9/model_prices_and_context_window.sha256")
+ viper.SetDefault("pricing.remote_url", "https://raw.githubusercontent.com/Wei-Shaw/model-price-repo/main/model_prices_and_context_window.json")
+ viper.SetDefault("pricing.hash_url", "https://raw.githubusercontent.com/Wei-Shaw/model-price-repo/main/model_prices_and_context_window.sha256")
viper.SetDefault("pricing.data_dir", "./data")
viper.SetDefault("pricing.fallback_file", "./resources/model-pricing/model_prices_and_context_window.json")
viper.SetDefault("pricing.update_interval_hours", 24)
diff --git a/backend/internal/service/pricing_service.go b/backend/internal/service/pricing_service.go
index 10440c60ae..5623d4b742 100644
--- a/backend/internal/service/pricing_service.go
+++ b/backend/internal/service/pricing_service.go
@@ -189,10 +189,38 @@ func (s *PricingService) checkAndUpdatePricing() error {
return s.downloadPricingData()
}
- // 检查文件是否过期
+ // 先加载本地文件(确保服务可用),再检查是否需要更新
+ if err := s.loadPricingData(pricingFile); err != nil {
+ logger.LegacyPrintf("service.pricing", "[Pricing] Failed to load local file, downloading: %v", err)
+ return s.downloadPricingData()
+ }
+
+ // 如果配置了哈希URL,通过远程哈希检查是否有更新
+ if s.cfg.Pricing.HashURL != "" {
+ remoteHash, err := s.fetchRemoteHash()
+ if err != nil {
+ logger.LegacyPrintf("service.pricing", "[Pricing] Failed to fetch remote hash on startup: %v", err)
+ return nil // 已加载本地文件,哈希获取失败不影响启动
+ }
+
+ s.mu.RLock()
+ localHash := s.localHash
+ s.mu.RUnlock()
+
+ if localHash == "" || remoteHash != localHash {
+ logger.LegacyPrintf("service.pricing", "[Pricing] Remote hash differs on startup (local=%s remote=%s), downloading...",
+ localHash[:min(8, len(localHash))], remoteHash[:min(8, len(remoteHash))])
+ if err := s.downloadPricingData(); err != nil {
+ logger.LegacyPrintf("service.pricing", "[Pricing] Download failed, using existing file: %v", err)
+ }
+ }
+ return nil
+ }
+
+ // 没有哈希URL时,基于文件年龄检查
info, err := os.Stat(pricingFile)
if err != nil {
- return s.downloadPricingData()
+ return nil // 已加载本地文件
}
fileAge := time.Since(info.ModTime())
@@ -205,21 +233,11 @@ func (s *PricingService) checkAndUpdatePricing() error {
}
}
- // 加载本地文件
- return s.loadPricingData(pricingFile)
+ return nil
}
// syncWithRemote 与远程同步(基于哈希校验)
func (s *PricingService) syncWithRemote() error {
- pricingFile := s.getPricingFilePath()
-
- // 计算本地文件哈希
- localHash, err := s.computeFileHash(pricingFile)
- if err != nil {
- logger.LegacyPrintf("service.pricing", "[Pricing] Failed to compute local hash: %v", err)
- return s.downloadPricingData()
- }
-
// 如果配置了哈希URL,从远程获取哈希进行比对
if s.cfg.Pricing.HashURL != "" {
remoteHash, err := s.fetchRemoteHash()
@@ -228,8 +246,13 @@ func (s *PricingService) syncWithRemote() error {
return nil // 哈希获取失败不影响正常使用
}
- if remoteHash != localHash {
- logger.LegacyPrintf("service.pricing", "%s", "[Pricing] Remote hash differs, downloading new version...")
+ s.mu.RLock()
+ localHash := s.localHash
+ s.mu.RUnlock()
+
+ if localHash == "" || remoteHash != localHash {
+ logger.LegacyPrintf("service.pricing", "[Pricing] Remote hash differs (local=%s remote=%s), downloading new version...",
+ localHash[:min(8, len(localHash))], remoteHash[:min(8, len(remoteHash))])
return s.downloadPricingData()
}
logger.LegacyPrintf("service.pricing", "%s", "[Pricing] Hash check passed, no update needed")
@@ -237,6 +260,7 @@ func (s *PricingService) syncWithRemote() error {
}
// 没有哈希URL时,基于时间检查
+ pricingFile := s.getPricingFilePath()
info, err := os.Stat(pricingFile)
if err != nil {
return s.downloadPricingData()
@@ -264,11 +288,12 @@ func (s *PricingService) downloadPricingData() error {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
- var expectedHash string
+ // 获取远程哈希(用于同步锚点,不作为完整性校验)
+ var remoteHash string
if strings.TrimSpace(s.cfg.Pricing.HashURL) != "" {
- expectedHash, err = s.fetchRemoteHash()
+ remoteHash, err = s.fetchRemoteHash()
if err != nil {
- return fmt.Errorf("fetch remote hash: %w", err)
+ logger.LegacyPrintf("service.pricing", "[Pricing] Failed to fetch remote hash (continuing): %v", err)
}
}
@@ -277,11 +302,13 @@ func (s *PricingService) downloadPricingData() error {
return fmt.Errorf("download failed: %w", err)
}
- if expectedHash != "" {
- actualHash := sha256.Sum256(body)
- if !strings.EqualFold(expectedHash, hex.EncodeToString(actualHash[:])) {
- return fmt.Errorf("pricing hash mismatch")
- }
+ // 哈希校验:不匹配时仅告警,不阻止更新
+ // 远程哈希文件可能与数据文件不同步(如维护者更新了数据但未更新哈希文件)
+ dataHash := sha256.Sum256(body)
+ dataHashStr := hex.EncodeToString(dataHash[:])
+ if remoteHash != "" && !strings.EqualFold(remoteHash, dataHashStr) {
+ logger.LegacyPrintf("service.pricing", "[Pricing] Hash mismatch warning: remote=%s data=%s (hash file may be out of sync)",
+ remoteHash[:min(8, len(remoteHash))], dataHashStr[:8])
}
// 解析JSON数据(使用灵活的解析方式)
@@ -296,11 +323,14 @@ func (s *PricingService) downloadPricingData() error {
logger.LegacyPrintf("service.pricing", "[Pricing] Failed to save file: %v", err)
}
- // 保存哈希
- hash := sha256.Sum256(body)
- hashStr := hex.EncodeToString(hash[:])
+ // 使用远程哈希作为同步锚点,防止重复下载
+ // 当远程哈希不可用时,回退到数据本身的哈希
+ syncHash := dataHashStr
+ if remoteHash != "" {
+ syncHash = remoteHash
+ }
hashFile := s.getHashFilePath()
- if err := os.WriteFile(hashFile, []byte(hashStr+"\n"), 0644); err != nil {
+ if err := os.WriteFile(hashFile, []byte(syncHash+"\n"), 0644); err != nil {
logger.LegacyPrintf("service.pricing", "[Pricing] Failed to save hash: %v", err)
}
@@ -308,7 +338,7 @@ func (s *PricingService) downloadPricingData() error {
s.mu.Lock()
s.pricingData = data
s.lastUpdated = time.Now()
- s.localHash = hashStr
+ s.localHash = syncHash
s.mu.Unlock()
logger.LegacyPrintf("service.pricing", "[Pricing] Downloaded %d models successfully", len(data))
@@ -486,16 +516,6 @@ func (s *PricingService) validatePricingURL(raw string) (string, error) {
return normalized, nil
}
-// computeFileHash 计算文件哈希
-func (s *PricingService) computeFileHash(filePath string) (string, error) {
- data, err := os.ReadFile(filePath)
- if err != nil {
- return "", err
- }
- hash := sha256.Sum256(data)
- return hex.EncodeToString(hash[:]), nil
-}
-
// GetModelPricing 获取模型价格(带模糊匹配)
func (s *PricingService) GetModelPricing(modelName string) *LiteLLMModelPricing {
s.mu.RLock()
diff --git a/deploy/config.example.yaml b/deploy/config.example.yaml
index 2058ced170..8f60acd5ed 100644
--- a/deploy/config.example.yaml
+++ b/deploy/config.example.yaml
@@ -865,10 +865,10 @@ rate_limit:
pricing:
# URL to fetch model pricing data (default: pinned model-price-repo commit)
# 获取模型定价数据的 URL(默认:固定 commit 的 model-price-repo)
- remote_url: "https://raw.githubusercontent.com/Wei-Shaw/model-price-repo/c7947e9871687e664180bc971d4837f1fc2784a9/model_prices_and_context_window.json"
+ remote_url: "https://raw.githubusercontent.com/Wei-Shaw/model-price-repo/refs/heads/main//model_prices_and_context_window.json"
# Hash verification URL (optional)
# 哈希校验 URL(可选)
- hash_url: "https://raw.githubusercontent.com/Wei-Shaw/model-price-repo/c7947e9871687e664180bc971d4837f1fc2784a9/model_prices_and_context_window.sha256"
+ hash_url: "https://raw.githubusercontent.com/Wei-Shaw/model-price-repo/refs/heads/main//model_prices_and_context_window.sha256"
# Local data directory for caching
# 本地数据缓存目录
data_dir: "./data"