mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-10 20:40:36 +00:00
This commit is contained in:
parent
e41843eaf7
commit
a4ab1408eb
2 changed files with 8 additions and 3 deletions
|
|
@ -116,7 +116,7 @@ export async function handler(
|
|||
const trialProviders = await trialLimiter?.check()
|
||||
const rateLimiter = modelInfo.allowAnonymous
|
||||
? createIpRateLimiter(modelInfo.id, modelInfo.rateLimit, ip, input.request)
|
||||
: createKeyRateLimiter(modelInfo.id, zenApiKey, input.request)
|
||||
: createKeyRateLimiter(modelInfo.id, modelInfo.rateLimit, zenApiKey, input.request)
|
||||
await rateLimiter?.check()
|
||||
const stickyTracker = createStickyTracker(modelInfo.stickyProvider, sessionId)
|
||||
const stickyProvider = await stickyTracker?.get()
|
||||
|
|
|
|||
|
|
@ -4,11 +4,16 @@ import { RateLimitError } from "./error"
|
|||
import { i18n } from "~/i18n"
|
||||
import { localeFromRequest } from "~/lib/language"
|
||||
|
||||
export function createRateLimiter(modelId: string, zenApiKey: string | undefined, request: Request) {
|
||||
export function createRateLimiter(
|
||||
modelId: string,
|
||||
rateLimit: number | undefined,
|
||||
zenApiKey: string | undefined,
|
||||
request: Request,
|
||||
) {
|
||||
if (!zenApiKey) return
|
||||
const dict = i18n(localeFromRequest(request))
|
||||
|
||||
const LIMIT = 300
|
||||
const LIMIT = rateLimit ?? 300
|
||||
const yyyyMMddHHmm = new Date(Date.now())
|
||||
.toISOString()
|
||||
.replace(/[^0-9]/g, "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue