langchainjs使用stream流式

2024-04-30 08:51:24 阅读:3 编辑
const stream = await chat.stream(
    "福建厦门的土特产有哪些?,列出3个,字数不超过30个字"
);
const chunks = [];
for await (const chunk of stream) {
    chunks.push(chunk);
    console.log(`${chunk.content}|`);
}