feat: multi-feature update
This commit is contained in:
@@ -59,6 +59,7 @@ type CustomOAuthProvider struct {
|
||||
// Advanced options
|
||||
WellKnown string `json:"well_known" gorm:"type:varchar(512)"` // OIDC discovery endpoint (optional)
|
||||
AuthStyle int `json:"auth_style" gorm:"default:0"` // 0=auto, 1=params, 2=header (Basic Auth)
|
||||
PKCEEnabled bool `json:"pkce_enabled" gorm:"default:false"` // Enable PKCE (Proof Key for Code Exchange)
|
||||
AccessPolicy string `json:"access_policy" gorm:"type:text"` // JSON policy for access control based on user info
|
||||
AccessDeniedMessage string `json:"access_denied_message" gorm:"type:varchar(512)"` // Custom error message template when access is denied
|
||||
|
||||
|
||||
@@ -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