Skip to content

Commit

Permalink
✨ copilot auth limit
Browse files Browse the repository at this point in the history
  • Loading branch information
v_frgfeng committed Apr 8, 2024
1 parent a18736a commit 8da84df
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/copilot/copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ func (co *CopilotApi) TokenHandler(c *gin.Context) {
return
}

day := time.Now().Format("2006-01-02")
if dayCount, ok := AuthCount[day]; ok {
if authCount, ok := dayCount[TypeAuthToken]; ok && authCount > 200 {
global.SugarLog.Errorw("TokenHandler get auth token err, authorization limit > 200")
response.FailWithOpenAIError(http.StatusUnauthorized, "exceeded authorization limit", c)
return
}
}

tokenRawCache, err := GetTokenRawInfoCache(token)
if err == nil && len(tokenRawCache) > 0 {
global.SugarLog.Infow("TokenHandler get token raw cache", "token", token)
Expand Down

0 comments on commit 8da84df

Please sign in to comment.