feat: multi-feature update

This commit is contained in:
chaos
2026-06-15 06:16:16 +08:00
parent 6f415428d3
commit 04d30f9dd1
58 changed files with 4610 additions and 419 deletions
+18
View File
@@ -531,6 +531,24 @@ func SumUsedToken(logType int, startTimestamp int64, endTimestamp int64, modelNa
return token
}
func SumTotalConsumeTokens() (int64, error) {
type tokenStat struct {
PromptTokens int64
CompletionTokens int64
}
var stat tokenStat
err := LOG_DB.Model(&Log{}).
Select("sum(prompt_tokens) as prompt_tokens, sum(completion_tokens) as completion_tokens").
Where("type = ?", LogTypeConsume).
Scan(&stat).Error
if err != nil {
return 0, err
}
return stat.PromptTokens + stat.CompletionTokens, nil
}
func DeleteOldLog(ctx context.Context, targetTimestamp int64, limit int) (int64, error) {
var total int64 = 0