fixes rate limiter always using IMAGE_MODEL_RATE_LIMIT

This commit is contained in:
nai-degen
2023-11-15 13:07:58 -06:00
parent 5fabe1d1f8
commit 3aca9e90f0
+4 -2
View File
@@ -83,7 +83,7 @@ export const refundLastAttempt = (req: Request) => {
const key = req.user?.token || req.risuToken || req.ip;
const attempts = lastAttempts.get(key) || [];
attempts.pop();
}
};
export const ipLimiter = async (
req: Request,
@@ -109,7 +109,9 @@ export const ipLimiter = async (
return next();
}
const type = req.baseUrl + req.path ? "image" : "text";
const type = (req.baseUrl + req.path).includes("openai-image")
? "image"
: "text";
const limit = type === "image" ? imageLimit : textLimit;
// If user is authenticated, key rate limiting by their token. Otherwise, key