()
| 5 | const pipe = new Pipe(pipeSummary()); |
| 6 | |
| 7 | async function main() { |
| 8 | const {stream, threadId, rawResponse} = await pipe.run({ |
| 9 | messages: [{role: 'user', content: 'Hello'}], |
| 10 | stream: true, |
| 11 | }); |
| 12 | |
| 13 | // Convert the stream to a stream runner. |
| 14 | const runner = getRunner(stream); |
| 15 | |
| 16 | // Method 1: Using event listeners |
| 17 | runner.on('connect', () => { |
| 18 | console.log('Stream started.\n'); |
| 19 | }); |
| 20 | |
| 21 | runner.on('content', content => { |
| 22 | process.stdout.write(content); |
| 23 | }); |
| 24 | |
| 25 | runner.on('end', () => { |
| 26 | console.log('\nStream ended.'); |
| 27 | }); |
| 28 | |
| 29 | runner.on('error', error => { |
| 30 | console.error('Error:', error); |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | main(); |
no test coverage detected