获得路易斯"topIntent".从另一个文件(Node.js)内的子对话框中 [英] Getting the Luis "topIntent" from a child dialog inside another file (Node.js)
问题描述
我的主要bot.js文件中有Luis用于顶层意图.但是我想从bot.js调用的其他对话框中访问Luis:
I have Luis working in my main bot.js file for top level intents. But i'd like to access Luis from other dialogs that are in their own files, called by 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
)
);
最后,如果检测到开始意图",我们将启动对话框:
and finally, if the "Start intent" is detected we start the dialog:
await dc.beginDialog(InitialDialog);
在dialogs/initial/index.js中:
In dialogs/initial/index.js:
class Initial extends ComponentDialog {
constructor(dialogId, userProfileAccessor, botConfig) {
super(dialogId);
}
问题就出在这里:当我尝试打电话给路易斯时:
Here's where it gets problematic: when I try and call 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
你知道我在做什么错吗?
Any idea what I'm doing wrong here?
推荐答案
需要创建 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
A sample using LUIS can be found here: https://github.com/Microsoft/BotBuilder-Samples/blob/master/samples/javascript_nodejs/12.nlp-with-luis
这篇关于获得路易斯"topIntent".从另一个文件(Node.js)内的子对话框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!