const stream = agent.stream({
prompt: '北京今天天气怎么样?',
})
for await (const event of stream) {
switch (event.type) {
case 'text-delta':
process.stdout.write(event.textDelta)
break
case 'tool-call':
console.log(`\n调用工具: ${event.toolCalls.map(t => t.function.name).join(', ')}`)
break
case 'step':
console.log(`\n步骤 ${event.step}`)
break
case 'finish':
console.log('\n完成!')
break
}
}