From 5238aff3786001ea92dae379f7b849721b0fcfa3 Mon Sep 17 00:00:00 2001 From: nai-degen <44111-khanon@users.noreply.gitgud.io> Date: Thu, 11 May 2023 20:35:28 -0500 Subject: [PATCH] reverts default quotaDisplay to partial; removes rejectSampleRate --- .env.example | 1 - src/config.ts | 9 +++------ src/info-page.ts | 4 ++-- src/proxy/middleware/request/language-filter.ts | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index 95eac7f..8c58666 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,6 @@ # LOG_LEVEL=info # REJECT_DISALLOWED=false # REJECT_MESSAGE="This content violates /aicg/'s acceptable use policy." -# REJECT_SAMPLE_RATE=0.2 # CHECK_KEYS=false # QUOTA_DISPLAY_MODE=full # QUEUE_MODE=fair diff --git a/src/config.ts b/src/config.ts index 7c727d5..d8c8c9d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -19,8 +19,6 @@ type Config = { maxOutputTokens: number; /** Whether requests containing disallowed characters should be rejected. */ rejectDisallowed?: boolean; - /** Rejection sample rate (0 - 1). Higher values are more strict but increase server load. */ - rejectSampleRate?: number; /** Message to return when rejecting requests. */ rejectMessage?: string; /** Pino log level. */ @@ -38,10 +36,10 @@ type Config = { /** * How to display quota information on the info page. * 'none' - Hide quota information - * 'simple' - Display quota information as a percentage + * 'partial' - Display quota information only as a percentage * 'full' - Display quota information as usage against total capacity */ - quotaDisplayMode: "none" | "simple" | "full"; + quotaDisplayMode: "none" | "partial" | "full"; /** * Which request queueing strategy to use when keys are over their rate limit. * 'fair' - Requests are serviced in the order they were received (default) @@ -60,14 +58,13 @@ export const config: Config = { modelRateLimit: getEnvWithDefault("MODEL_RATE_LIMIT", 4), maxOutputTokens: getEnvWithDefault("MAX_OUTPUT_TOKENS", 300), rejectDisallowed: getEnvWithDefault("REJECT_DISALLOWED", false), - rejectSampleRate: getEnvWithDefault("REJECT_SAMPLE_RATE", 0.2), rejectMessage: getEnvWithDefault( "REJECT_MESSAGE", "This content violates /aicg/'s acceptable use policy." ), logLevel: getEnvWithDefault("LOG_LEVEL", "info"), checkKeys: getEnvWithDefault("CHECK_KEYS", !isDev), - quotaDisplayMode: getEnvWithDefault("QUOTA_DISPLAY_MODE", "full"), + quotaDisplayMode: getEnvWithDefault("QUOTA_DISPLAY_MODE", "partial"), promptLogging: getEnvWithDefault("PROMPT_LOGGING", false), promptLoggingBackend: getEnvWithDefault("PROMPT_LOGGING_BACKEND", undefined), googleSheetsKey: getEnvWithDefault("GOOGLE_SHEETS_KEY", undefined), diff --git a/src/info-page.ts b/src/info-page.ts index 3370f49..22309d4 100644 --- a/src/info-page.ts +++ b/src/info-page.ts @@ -155,7 +155,7 @@ function getQueueInformation() { (waitMs % 60000) / 1000 )}sec`; return { - proomptersWaiting: getQueueLength(), - estimatedWaitTime: waitMs > 1000 ? waitTime : "no wait", + proomptersInQueue: getQueueLength(), + estimatedQueueTime: waitMs > 2000 ? waitTime : "no wait", }; } diff --git a/src/proxy/middleware/request/language-filter.ts b/src/proxy/middleware/request/language-filter.ts index 8d3a7e6..709ec02 100644 --- a/src/proxy/middleware/request/language-filter.ts +++ b/src/proxy/middleware/request/language-filter.ts @@ -9,7 +9,7 @@ const DISALLOWED_REGEX = // each 15k character request ten times a second. So we'll just sample 20% of // the characters and hope that's enough. const containsDisallowedCharacters = (text: string) => { - const sampleSize = Math.ceil(text.length * (config.rejectSampleRate || 0.2)); + const sampleSize = Math.ceil(text.length * 0.2); const sample = text .split("") .sort(() => 0.5 - Math.random())