fix(kb.gbapp): New params from root bot.

This commit is contained in:
Rodrigo Rodriguez 2020-06-03 16:43:35 -03:00
parent 7f3c9fa223
commit f3a32d04b4
2 changed files with 15 additions and 10 deletions

View file

@ -166,7 +166,8 @@ export class AskDialog extends IGBDialog {
await min.conversationalService.sendText(min, step, Messages[locale].going_answer);
}
// Spells check the input text before sending Search or NLP.
if (min.instance.spellcheckerKey !== undefined) {
const key = min.instance.spellcheckerKey ? minBoot.instance.spellcheckerKey : min.instance.spellcheckerKey;
if ( key) {
const data = await AzureText.getSpelledText(min.instance.spellcheckerKey, text);
if (data !== text) {
GBLog.info(`Spelling corrected: ${data}`);
@ -174,10 +175,11 @@ export class AskDialog extends IGBDialog {
}
}
const searchScore = min.instance.searchScore? min.instance.searchScore: minBoot.instance.searchScore;
// Searches KB for the first time.
user.lastQuestion = text;
await min.userProfile.set(step.context, user);
const resultsA = await service.ask(min.instance, text, min.instance.searchScore, user.subjects);
const resultsA = await service.ask(min.instance, text, searchScore, user.subjects);
// If there is some result, answer immediately.
if (resultsA !== undefined && resultsA.answer !== undefined) {
@ -192,7 +194,7 @@ export class AskDialog extends IGBDialog {
} else {
// Second time running Search, now with no filter.
const resultsB = await service.ask(min.instance, text, min.instance.searchScore, undefined);
const resultsB = await service.ask(min.instance, text, searchScore, undefined);
// If there is some result, answer immediately.
if (resultsB !== undefined && resultsB.answer !== undefined) {

View file

@ -57,6 +57,7 @@ import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
import { CSService } from '../../customer-satisfaction.gbapp/services/CSService';
import { SecService } from '../../security.gblib/services/SecService';
import { CollectionUtil } from 'pragmatismo-io-framework';
import { try } from 'bluebird';
/**
* Result for quey on KB data.
@ -286,12 +287,11 @@ export class KBService implements IGBKBService {
line._cells[4] !== undefined) {
// Extracts values from columns in the current line.
const subjectsText = line._cells[0].value;
const from = line._cells[1].value;
const to = line._cells[2].value;
const question = line._cells[3].value;
let answer = line._cells[4].value;
const subjectsText = line._cells[0].text;
const from = line._cells[1].text;
const to = line._cells[2].text;
const question = line._cells[3].text;
let answer = line._cells[4].text;
if (!(subjectsText === 'subjects' && from === 'from')
&& (answer !== null && question !== null)) {
@ -302,7 +302,10 @@ export class KBService implements IGBKBService {
let media = null;
if (answer.indexOf('.md') > -1) {
if (!answer) {
GBLog.info(`[GBImporter] Answer is NULL related to Question '${question}'.`);
answer = 'Existe um problema na base de conhecimento. Fui treinado para entender sua pergunta, avise a quem me criou que a resposta não foi informada para esta pergunta.';
} else if (answer.indexOf('.md') > -1) {
const mediaFilename = urlJoin(path.dirname(filePath), '..', 'articles', answer);
if (Fs.existsSync(mediaFilename)) {
answer = Fs.readFileSync(mediaFilename, 'utf8');