我正在尝试使用 Amazon Lex V2 创建一个聊天机器人,我计划使用他们的 Javascript v3 SDK 来使用 steaming API。
我试过以下
import { LexRuntimeV2 } from '@aws-sdk/client-lex-runtime-v2'
const client = new LexRuntimeV2(config);
const conversation = await client.startConversation({
BotId: 'my-bot-id',
BotAliasId: 'bot-alias-id',
requestEventStream: myStream,
...moreOptions
});
// Code never reaches here
for await (const event of conversation.responseEventStream) {
console.log(event);
}
他们的API建议使用
responseEventStream
来消费入站事件,但是它忙于消费requestEventStream
,而且都是AsyncIterable
类型