如何从 Lex V2 获取 responseEventStream

问题描述 投票:0回答:0

我正在尝试使用 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

类型
amazon-lex aws-sdk-js-v3 async-iterator
© www.soinside.com 2019 - 2024. All rights reserved.