node.js - 从另一个文件(Node.js)中的子对话框获取 Luis“topIntent”
问题描述
我让 Luis 在我的主要 bot.js 文件中工作以获取顶级意图。但我想从他们自己的文件中的其他对话框访问 Luis,由 bot.js 调用:
bot.js:
const { InitialDialog } = require('./dialogs/initial');
const INITIAL_DIALOG = 'initialDialog';
const START_INTENT = 'Start';
然后在机器人的类中:
this.dialogs.add(
new InitialDialog(
INITIAL_DIALOG,
this.userProfileAccessor,
botConfig
)
);
最后,如果检测到“开始意图”,我们将启动对话框:
await dc.beginDialog(InitialDialog);
在 dialogs/initial/index.js 中:
class Initial extends ComponentDialog {
constructor(dialogId, userProfileAccessor, botConfig) {
super(dialogId);
}
这就是问题所在:当我尝试打电话给 Luis 时:
// Perform a call to LUIS to retrieve results for the user's message.
const results: RecognizerResult = await this.luisRecognizer.recognize(turnContext);
// Since the LuisRecognizer was configured to include the raw results, get the `topScoringIntent` as specified by LUIS.
const topIntent = results.luisResult.topScoringIntent;
我收到一个错误:
[onTurnError]: TypeError: Cannot read property 'recognize' of undefined
知道我在这里做错了什么吗?
解决方案
需要创建luisRecognizer :
const luisApplication = {
applicationId: luisConfig.appId,
endpointKey: luisConfig.subscriptionKey || luisConfig.authoringKey,
endpoint: luisConfig.getEndpoint()
};
// Create configuration for LuisRecognizer's runtime behavior.
const luisPredictionOptions = {
includeAllIntents: true,
log: true,
staging: false
};
this.luisRecognizer = new LuisRecognizer(luisApplication, luisPredictionOptions , true);
可以在此处找到使用 LUIS 的示例: https ://github.com/Microsoft/BotBuilder-Samples/blob/master/samples/javascript_nodejs/12.nlp-with-luis
推荐阅读
- android - 为什么我无法从视图模型类中获取值?
- javascript - VueJS如何过滤分页列表中的搜索
- apache - SetEnvIfNoCase 未正确设置变量值
- c - 如何在不使用#ifdef 的情况下测试是否定义了宏标识符?
- wso2 - 用于 SSO 的 WSO2 IS 服务提供商分组
- google-cloud-platform - 如何在 GCP/DigitalOcean Linux Instance 中启用 KVM?
- excel - 基于多个标准提取唯一值
- reporting-services - ssrs:条形图不显示垂直轴上的所有标签
- firebase - 从 Firebase 文档获取时间戳/创建日期,它不是手动保存的?
- icalendar - webcal:// 协议 - 在 Chrome iOS 上创建 ical 提醒 - 从提示中隐藏订阅的 URL?