File tree Expand file tree Collapse file tree
next-app/app/api/chat/stream Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,16 @@ function* fakeStream(text: string) {
1010
1111import { 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+ */
1323function streamForMessage ( message : string ) {
1424 const ctrl = new AbortController ( ) ;
1525 const stream = new ReadableStream < Uint8Array > ( {
You can’t perform that action at this time.
0 commit comments