Spaces:
Paused
Paused
fix anthropic RWPX
Browse files
internal/handler/anthropic.go
CHANGED
|
@@ -28,8 +28,12 @@ func HandleMessages(w http.ResponseWriter, r *http.Request) {
|
|
| 28 |
writeAnthropicError(w, http.StatusUnauthorized, "authentication_error", "Missing API key")
|
| 29 |
return
|
| 30 |
}
|
| 31 |
-
|
| 32 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
anonymousToken, err := auth.GetAnonymousToken()
|
| 34 |
if err != nil {
|
| 35 |
logger.LogError("Failed to get anonymous token: %v", err)
|
|
|
|
| 28 |
writeAnthropicError(w, http.StatusUnauthorized, "authentication_error", "Missing API key")
|
| 29 |
return
|
| 30 |
}
|
| 31 |
+
ok, reason := CheckAndTrack(token, 0)
|
| 32 |
+
if !ok {
|
| 33 |
+
writeAnthropicError(w, http.StatusTooManyRequests, "rate_limit_error", reason)
|
| 34 |
+
return
|
| 35 |
+
}
|
| 36 |
+
if token == "free" || strings.HasPrefix(token, "RWPX-") {
|
| 37 |
anonymousToken, err := auth.GetAnonymousToken()
|
| 38 |
if err != nil {
|
| 39 |
logger.LogError("Failed to get anonymous token: %v", err)
|