MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / main

Function main

examples/nodejs/examples/pipe.stream.text.ts:7–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5const pipe = new Pipe(pipeSummary());
6
7async 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
34main();

Callers 1

Calls 3

getRunnerFunction · 0.90
runMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected