nodejs 版本22.14
window11
const stream = await client.chat({
messages: [
{
"role": "user",
"content": "你好"
},
],
// 流式输出
stream: true
}, 'ERNIE-Speed-128K')
try {
for await (const chunk of stream as AsyncIterableIterator<any>) {
let content = chunk.result || chunk.choices?.[0]?.delta?.result;
// 如果内容是 Base64 编码
if (typeof content === 'string' && /[A-Za-z0-9+/=]/.test(content)) {
content = Buffer.from(content, 'base64').toString('utf-8');
}
console.log(content); // 输出内容
}
} catch (error) {
console.error('Error during streaming:', error);
}
// 流式输出固定方法
for await (const chunk of stream as AsyncIterableIterator<any>) {
console.log(chunk);
}
console.log(stream)

根据文档修改和ai修改出来的都是乱码,文档内没找到乱码的解决办法
文心一言/通义千问/Deepseek/ Claude/Cursor与Vue3、Electron
了解课程