Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add limits on messages, conversations, assistants and messages/minute * Add max message length limit * remove rate limits from public config * add `RATE_LIMITS` to secrets * Add `MESSAGES_BEFORE_LOGIN` to secrets * replace `RATE_LIMITS` by `USAGE_LIMITS` * replace `RateLimits` by `usageLimits` and only get nEvents if needed * rename schema too * replace \r\n by \n
- Loading branch information
Showing
10 changed files
with
90 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { z } from "zod"; | ||
import { USAGE_LIMITS, RATE_LIMIT } from "$env/static/private"; | ||
import JSON5 from "json5"; | ||
|
||
// RATE_LIMIT is the legacy way to define messages per minute limit | ||
export const usageLimitsSchema = z | ||
.object({ | ||
conversations: z.coerce.number().optional(), // how many conversations | ||
messages: z.coerce.number().optional(), // how many messages in a conversation | ||
assistants: z.coerce.number().optional(), // how many assistants | ||
messageLength: z.coerce.number().optional(), // how long can a message be before we cut it off | ||
messagesPerMinute: z | ||
.preprocess((val) => { | ||
if (val === undefined) { | ||
return RATE_LIMIT; | ||
} | ||
return val; | ||
}, z.coerce.number().optional()) | ||
.optional(), // how many messages per minute | ||
}) | ||
.optional(); | ||
|
||
export const usageLimits = usageLimitsSchema.parse(JSON5.parse(USAGE_LIMITS)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters