feat: multi-feature update
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user