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