gpt4 book ai didi

node.js - 如何在单个 Node.js 机器人中集成 LUIS 和 QnA Maker 服务?

转载 作者:搜寻专家 更新时间:2023-10-31 22:44:30 25 4
gpt4 key购买 nike

我正在使用 Microsoft Bot Framework 和 Node.js SDK 开发聊天机器人。我已经集成了 LUIS 和 QnA maker,但如果可能的话,我想创建这个场景。以下面的例子 link特别是本节:

There are a few ways that a bot may implement a hybrid of LUIS and QnA Maker: Call LUIS first, and if no intent meets a specific threshold score, i.e., "None" intent is triggered, then call QnA Maker. Alternatively, create a LUIS intent for QnA Maker, feeding your LUIS model with example QnA questions that map to "QnAIntent."

举个例子:我有我的 QnA 知识库,其中有一对:“你是谁?”/“嗨,我是你的机器人!”。然后我有我的 Luis 应用程序可以识别这个名为 "common" 的意图。所以,如果我写信给我的机器人:“你是谁?”它会回答“嗨,我是你的机器人!”相反,如果我写“告诉我你是谁”,它会识别与问题相关的 LUIS 意图,但不会像我想象的那样回答“嗨,我是你的机器人!”。

所以我想象的是:我问“告诉我你是谁”这个问题 --> 机器人触发通用意图 (LUIS) --> 然后我希望机器人会回答我查看 QnA KB - -> “嗨,我是你的机器人!”

这可能吗?

希望这段代码能有所帮助:

var intents = new builder.IntentDialog({ recognizers[luisRecognizer,qnarecognizer] });

bot.dialog('/', intents);

intents.matches('common_question', [
function (session, args, next) {
session.send('Intent common');
qnarecognizer.recognize(session, function (error, result) {
session.send('answerEntity.entity');
});
}
]);

最佳答案

您必须将用户消息从与 LUIS 检测到的意图关联的方法/对话框转发到 QnaMaker。查看这篇文章 ( https://blog.botframework.com/2017/11/17/qna-maker-node-js-bots/),了解如何在 Node.js

中实现 QnAMaker

类似于:

var recognizer = new cognitiveservices.QnAMakerRecognizer({
knowledgeBaseId: 'set your kbid here',
subscriptionKey: 'set your subscription key here'});

var context = session.toRecognizeContext();

recognizer.recognize(context, function (error, result) { // your code... }

您还应该探索示例并尝试理解一切是如何工作的:https://github.com/Microsoft/BotBuilder-CognitiveServices/tree/master/Node/samples/QnAMaker

如果您的问题变化很大; QnA 可能无法检测到您预期的问题,在这种情况下,您将不得不更多地训练知识库(就像您在 LUIS 中使用话语/意图所做的那样)

关于node.js - 如何在单个 Node.js 机器人中集成 LUIS 和 QnA Maker 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48190871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com