fix(basic.gblib): Fixes /answer bug.
This commit is contained in:
parent
943546a8a0
commit
339e8501a9
2 changed files with 43 additions and 33 deletions
|
@ -1255,10 +1255,12 @@ export class GBMinService {
|
||||||
user: user ? user.dataValues : null
|
user: user ? user.dataValues : null
|
||||||
};
|
};
|
||||||
await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => {
|
await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => {
|
||||||
|
if (!nextDialog) {
|
||||||
nextDialog = await e.onExchangeData(min, 'handleAnswer', data);
|
nextDialog = await e.onExchangeData(min, 'handleAnswer', data);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
data.step = null;
|
data.step = null;
|
||||||
GBLog.info(`/answer being called from processMessageActivity.`);
|
GBLog.info(`/answer being called from processMessageActivity (nextDialog=${nextDialog}).`);
|
||||||
await step.beginDialog(nextDialog ? nextDialog : '/answer', {
|
await step.beginDialog(nextDialog ? nextDialog : '/answer', {
|
||||||
data: data,
|
data: data,
|
||||||
query: text,
|
query: text,
|
||||||
|
|
|
@ -248,11 +248,19 @@ export class AskDialog extends IGBDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Answers using Search or NLP responses.
|
// Try to answer by search.
|
||||||
|
|
||||||
if (answer) {
|
if (answer) {
|
||||||
return await AskDialog.handleAnswer(service, min, step, answer);
|
return await AskDialog.handleAnswer(service, min, step, answer);
|
||||||
} else if (!(await min.conversationalService.routeNLP(step, min, text))) {
|
}
|
||||||
|
|
||||||
|
// Tries to answer by NLP.
|
||||||
|
|
||||||
|
if (await min.conversationalService.routeNLP(step, min, text)) {
|
||||||
|
return await step.replaceDialog('/ask', { isReturning: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tries to answer by Reading Comprehension.
|
||||||
|
|
||||||
if (process.env.GBMODELS_SERVER) {
|
if (process.env.GBMODELS_SERVER) {
|
||||||
text = await min.conversationalService.translate(min, text, 'en');
|
text = await min.conversationalService.translate(min, text, 'en');
|
||||||
|
@ -277,14 +285,14 @@ export class AskDialog extends IGBDialog {
|
||||||
return await step.replaceDialog('/ask', { isReturning: true });
|
return await step.replaceDialog('/ask', { isReturning: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not found.
|
||||||
|
|
||||||
} else {
|
|
||||||
const message = min.core.getParam<string>(min.instance, 'Not Found Message',
|
const message = min.core.getParam<string>(min.instance, 'Not Found Message',
|
||||||
Messages[locale].did_not_find);
|
Messages[locale].did_not_find);
|
||||||
|
|
||||||
await min.conversationalService.sendText(min, step, message);
|
await min.conversationalService.sendText(min, step, message);
|
||||||
return await step.replaceDialog('/ask', { isReturning: true });
|
return await step.replaceDialog('/ask', { isReturning: true });
|
||||||
}
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue