mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-14 23:00:27 +00:00
feat: now use token as the unit of quota (close #33)
This commit is contained in:
@@ -110,7 +110,17 @@ func TokenAuth() func(c *gin.Context) {
|
||||
}
|
||||
c.Set("id", token.UserId)
|
||||
c.Set("token_id", token.Id)
|
||||
c.Set("unlimited_quota", token.UnlimitedQuota)
|
||||
requestURL := c.Request.URL.String()
|
||||
consumeQuota := false
|
||||
switch requestURL {
|
||||
case "/v1/chat/completions":
|
||||
consumeQuota = !token.UnlimitedQuota
|
||||
case "/v1/completions":
|
||||
consumeQuota = !token.UnlimitedQuota
|
||||
case "/v1/edits":
|
||||
consumeQuota = !token.UnlimitedQuota
|
||||
}
|
||||
c.Set("consume_quota", consumeQuota)
|
||||
if len(parts) > 1 {
|
||||
if model.IsAdmin(token.UserId) {
|
||||
c.Set("channelId", parts[1])
|
||||
|
Reference in New Issue
Block a user