From c4f8679bda970d6d9ed023892f6a8b4e9ad4db37 Mon Sep 17 00:00:00 2001 From: nai-degen <44111-khanon@users.noreply.gitgud.io> Date: Sun, 9 Apr 2023 00:49:14 -0500 Subject: [PATCH] exempts hosted agnai from rate limit --- src/info-page.ts | 2 +- src/proxy/rate-limit.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/info-page.ts b/src/info-page.ts index 227638e..d9839a3 100644 --- a/src/info-page.ts +++ b/src/info-page.ts @@ -19,7 +19,7 @@ function getInfoPageHtml(host: string) { uptime: process.uptime(), timestamp: Date.now(), baseUrl: host, - kobold: host + "/proxy/kobold", + kobold: host, // kobold doesn't need the suffix openai: host + "/proxy/openai", proompts: keylist.reduce((acc, k) => acc + k.promptCount, 0), ...(config.modelRateLimit ? rateLimitInfo : {}), diff --git a/src/proxy/rate-limit.ts b/src/proxy/rate-limit.ts index 58899c0..fe92498 100644 --- a/src/proxy/rate-limit.ts +++ b/src/proxy/rate-limit.ts @@ -63,6 +63,14 @@ export const ipLimiter = (req: Request, res: Response, next: NextFunction) => { return; } + // Exempt Agnai.chat from rate limiting since it's shared between a lot of + // users. Dunno how to prevent this from being abused without some sort of + // identifier sent from Agnaistic to identify specific users. + if (req.ip === "157.230.249.32") { + next(); + return; + } + const { remaining, reset } = getStatus(req.ip); res.set("X-RateLimit-Limit", config.modelRateLimit.toString()); res.set("X-RateLimit-Remaining", remaining.toString());