Skip to content

Commit 23c6a2e

Browse files
committed
👌 IMPROVE: stream format
1 parent 7e28637 commit 23c6a2e

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

packages/langbase/src/pipes/pipes.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,10 @@ export class Pipe {
109109
});
110110
}
111111

112-
async streamText(options: StreamOptions): Promise<GenerateStreamResponse> {
113-
return this.request.post<GenerateStreamResponse>({
114-
endpoint: '/beta/generate',
112+
async streamText(options: StreamOptions): Promise<StreamResponse> {
113+
return this.request.post<StreamResponse>({
114+
endpoint: options.chat ? '/beta/chat' : '/beta/generate',
115115
body: {...options, stream: true},
116-
stream: true, // TODO: @ahmadbilaldev - why we need to add here as well?
117116
});
118117
}
119118
}
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)