Skip to content

Commit 8bb0fcc

Browse files
[Penify]: Documentation for commit - fdcc926
1 parent fdcc926 commit 8bb0fcc

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

next-app/app/api/chat/stream/route.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ function* fakeStream(text: string) {
1010

1111
import { preFilter, steerPrompt, postModerate } from '@/lib/safety/pipeline';
1212

13+
/**
14+
* Streams a message as a server-sent event.
15+
*
16+
* This function creates a ReadableStream that processes a given message through several stages:
17+
* it applies pre-filtering, steering, and post-moderation to generate a reply. The stream emits
18+
* metadata and each chunk of the reply as events, handling errors by sending an error event if
19+
* any exceptions occur during processing.
20+
*
21+
* @param message - The input message to be processed and streamed.
22+
*/
1323
function streamForMessage(message: string) {
1424
const ctrl = new AbortController();
1525
const stream = new ReadableStream<Uint8Array>({

0 commit comments

Comments
 (0)