From a00bb3063dbd3fee191c115353698ae5dedc83fa Mon Sep 17 00:00:00 2001 From: Dhravya Date: Mon, 1 Apr 2024 00:00:17 -0700 Subject: [PATCH] gracefully end stream --- apps/cf-ai-backend/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts index 429d5f9b..f4843601 100644 --- a/apps/cf-ai-backend/src/index.ts +++ b/apps/cf-ai-backend/src/index.ts @@ -136,7 +136,7 @@ export default { const encodedChunk = converter.encode("data: " + JSON.stringify({ "response": chunkText }) + "\n\n"); controller.enqueue(encodedChunk); } - const doneChunk = converter.encode("[DONE]"); + const doneChunk = converter.encode("data: [DONE]"); controller.enqueue(doneChunk); controller.close(); } @@ -167,7 +167,7 @@ export default { const encodedChunk = converter.encode("data: " + JSON.stringify({ "response": chunkText }) + "\n\n"); controller.enqueue(encodedChunk); } - const doneChunk = converter.encode("[DONE]"); + const doneChunk = converter.encode("data: [DONE]"); controller.enqueue(doneChunk); controller.close(); }