Skip to content

Commit 7e28637

Browse files
committed
📦 NEW: helper fn to printStreamToStdout
1 parent d00a840 commit 7e28637

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/langbase/src/pipes/pipes.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,16 @@ export class Pipe {
117117
});
118118
}
119119
}
120+
121+
/**
122+
* Print stream to standard output (console).
123+
* @param stream The stream to print
124+
*/
125+
export const printStreamToStdout = async (
126+
stream: StreamText,
127+
): Promise<void> => {
128+
for await (const chunk of stream) {
129+
const textPart = chunk.choices[0]?.delta?.content || '';
130+
process.stdout.write(textPart);
131+
}
132+
};

0 commit comments

Comments
 (0)