fix: move cacheRead/cacheWriteSum to outer scope to fix build error
Variables were defined inside if block but referenced outside in gopool.Go closure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -194,9 +194,9 @@ func RecordConsumeLog(c *gin.Context, userId int, params RecordConsumeLogParams)
|
||||
}
|
||||
if common.DataExportEnabled {
|
||||
// 从 Other 中提取缓存 token
|
||||
cacheTokens := 0
|
||||
cacheRead := 0
|
||||
cacheWriteSum := 0
|
||||
if params.Other != nil {
|
||||
cacheRead := 0
|
||||
if v, ok := params.Other["cache_tokens"]; ok {
|
||||
if n, ok := v.(int); ok {
|
||||
cacheRead = n
|
||||
@@ -230,13 +230,12 @@ func RecordConsumeLog(c *gin.Context, userId int, params RecordConsumeLogParams)
|
||||
}
|
||||
// cache_creation_tokens 已经是总的缓存写入 token,5m 和 1h 是细分
|
||||
// 取 max(cache_creation_tokens, cache_creation_tokens_5m + cache_creation_tokens_1h)
|
||||
cacheWriteSum := cacheWrite5m + cacheWrite1h
|
||||
cacheWriteSum = cacheWrite5m + cacheWrite1h
|
||||
if cacheWrite > cacheWriteSum {
|
||||
cacheWriteSum = cacheWrite
|
||||
}
|
||||
cacheTokens = cacheRead + cacheWriteSum
|
||||
}
|
||||
totalTokens := params.PromptTokens + params.CompletionTokens + cacheTokens
|
||||
totalTokens := params.PromptTokens + params.CompletionTokens + cacheRead + cacheWriteSum
|
||||
promptTokens := params.PromptTokens
|
||||
completionTokens := params.CompletionTokens
|
||||
gopool.Go(func() {
|
||||
|
||||
Reference in New Issue
Block a user