From e2b602fd52c4ab0c159b12708cd8aad837e49983 Mon Sep 17 00:00:00 2001 From: user Date: Tue, 31 Dec 2024 08:23:45 +0000 Subject: [PATCH] Adjust chunked transfer to send 4KB (CF's buffer size) of data every 49 seconds --- src/proxy/openai.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/proxy/openai.ts b/src/proxy/openai.ts index 317c79e..4d1f484 100644 --- a/src/proxy/openai.ts +++ b/src/proxy/openai.ts @@ -196,15 +196,15 @@ const setupChunkedTransfer: RequestHandler = (req, res, next) => { // Higher values are required - otherwise Cloudflare will buffer and not pass // the separate chunks, which means that a >100s response will get terminated anyway const keepAlive = setInterval(() => { - res.write(' '.repeat(512)); - }, 5_000); + res.write(' '.repeat(4096)); + }, 49_000); (req as any)._keepAliveInterval = keepAlive; } next(); }; - +// General chat completion endpoint. Turbo-instruct is not supported here. openaiRouter.post( "/v1/chat/completions", ipLimiter,