fix(kb.gbapp): #276 use of NLP.js upgrade to v4.
This commit is contained in:
parent
01cf2803a0
commit
5c48d39620
6 changed files with 25 additions and 32 deletions
|
@ -65,6 +65,7 @@
|
|||
"@google-cloud/translate": "7.0.4",
|
||||
"@hubspot/api-client": "7.1.2",
|
||||
"@microsoft/microsoft-graph-client": "3.0.4",
|
||||
"@nlpjs/basic": "4.26.1",
|
||||
"@nosferatu500/textract": "3.1.2",
|
||||
"@semantic-release/changelog": "5.0.1",
|
||||
"@semantic-release/exec": "5.0.0",
|
||||
|
@ -89,6 +90,7 @@
|
|||
"botframework-connector": "4.18.0",
|
||||
"botlib": "3.0.9",
|
||||
"c3-chart-maker": "0.2.8",
|
||||
"cd": "^0.3.3",
|
||||
"chatgpt": "2.4.2",
|
||||
"chrome-remote-interface": "0.31.3",
|
||||
"cli-progress": "3.11.2",
|
||||
|
@ -120,7 +122,7 @@
|
|||
"nexmo": "2.9.1",
|
||||
"node-cron": "3.0.2",
|
||||
"node-html-parser": "6.1.5",
|
||||
"node-nlp": "4.24.0",
|
||||
"node-nlp": "4.26.1",
|
||||
"node-tesseract-ocr": "2.2.1",
|
||||
"open": "8.4.0",
|
||||
"open-docxtemplater-image-module": "1.0.3",
|
||||
|
|
|
@ -343,18 +343,17 @@ export class GBVMService extends GBService {
|
|||
GBConfigService.get('DEFAULT_CONTENT_LANGUAGE')
|
||||
);
|
||||
|
||||
// TODO: https://github.com/GeneralBots/BotServer/issues/217
|
||||
// Auto-NLP generates BASIC variables related to entities.
|
||||
|
||||
// if (step && step.context.activity['originalText'] && min['nerEngine']) {
|
||||
// const entities = await min['nerEngine'].findEntities(step.context.activity['originalText'], contentLocale);
|
||||
if (text && min['nerEngine']) {
|
||||
const result = await min['nerEngine'].process(text);
|
||||
|
||||
// for (let i = 0; i < entities.length; i++) {
|
||||
// const v = entities[i];
|
||||
// const variableName = `${v.entity}`;
|
||||
// sandbox[variableName] = v.option;
|
||||
// }
|
||||
// }
|
||||
for (let i = 0; i < result.entities.length; i++) {
|
||||
const v = result.entities[i];
|
||||
const variableName = `${v.entity}`;
|
||||
sandbox[variableName] = v.option;
|
||||
}
|
||||
}
|
||||
|
||||
const botId = min.botId;
|
||||
const gbdialogPath = urlJoin(process.cwd(), 'work', `${botId}.gbai`, `${botId}.gbdialog`);
|
||||
|
|
|
@ -633,7 +633,7 @@ ENDPOINT_UPDATE=true
|
|||
|
||||
/**
|
||||
* Get a dynamic param from instance. Dynamic params are defined in Config.xlsx
|
||||
* and loaded into the work folder from /publish command.
|
||||
* and loaded into the work folder from comida command.
|
||||
*
|
||||
* @param name Name of param to get from instance.
|
||||
* @param defaultValue Value returned when no param is defined in Config.xlsx.
|
||||
|
|
|
@ -47,7 +47,7 @@ import path from 'path';
|
|||
import mkdirp from 'mkdirp';
|
||||
import Fs from 'fs';
|
||||
import arrayBufferToBuffer from 'arraybuffer-to-buffer';
|
||||
|
||||
import { NlpManager } from 'node-nlp';
|
||||
import {
|
||||
AutoSaveStateMiddleware,
|
||||
BotFrameworkAdapter,
|
||||
|
@ -85,7 +85,6 @@ import { GBDeployer } from './GBDeployer.js';
|
|||
import urlJoin from 'url-join';
|
||||
import { GoogleChatDirectLine } from '../../google-chat.gblib/services/GoogleChatDirectLine.js';
|
||||
import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords.js';
|
||||
import * as nlp from 'node-nlp';
|
||||
import Path from 'path';
|
||||
import { GBSSR } from './GBSSR.js';
|
||||
|
||||
|
@ -249,20 +248,13 @@ export class GBMinService {
|
|||
GBLog.verbose(`Bot UI ${GBMinService.uiPackage} accessible at custom domain: ${domain}.`);
|
||||
}
|
||||
|
||||
|
||||
GBServer.globals.httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmounts the bot web site (default.gbui) secure domain, if any.
|
||||
*/
|
||||
public async unloadDomain(instance: IGBInstance) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async unloadDomain(instance: IGBInstance) {}
|
||||
|
||||
/**
|
||||
* Mount the instance by creating an BOT Framework bot object,
|
||||
|
@ -325,8 +317,7 @@ export class GBMinService {
|
|||
|
||||
// Loads Named Entity data for this bot.
|
||||
|
||||
// https://github.com/GeneralBots/BotServer/issues/217
|
||||
// await KBService.RefreshNER(min);
|
||||
await KBService.RefreshNER(min);
|
||||
|
||||
// Calls the loadBot context.activity for all packages.
|
||||
|
||||
|
@ -376,7 +367,6 @@ export class GBMinService {
|
|||
};
|
||||
|
||||
await CollectionUtil.asyncForEach(steps, async step => {
|
||||
|
||||
client.apis.Conversations.Conversations_PostActivity({
|
||||
conversationId: conversationId,
|
||||
activity: {
|
||||
|
@ -619,7 +609,6 @@ export class GBMinService {
|
|||
* Gets a Speech to Text / Text to Speech token from the provider.
|
||||
*/
|
||||
private async getSTSToken(instance: any) {
|
||||
|
||||
const options = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -628,8 +617,7 @@ export class GBMinService {
|
|||
};
|
||||
|
||||
try {
|
||||
|
||||
const res = await fetch(instance.speechEndpoint, options)
|
||||
const res = await fetch(instance.speechEndpoint, options);
|
||||
return res.text();
|
||||
} catch (error) {
|
||||
const msg = `Error calling Speech to Text client. Error is: ${error}.`;
|
||||
|
@ -674,10 +662,14 @@ export class GBMinService {
|
|||
min.sandBoxMap = {};
|
||||
min['scheduleMap'] = {};
|
||||
min['conversationWelcomed'] = {};
|
||||
min['nerEngine'] = new nlp.NlpManager(); // https://github.com/GeneralBots/BotServer/issues/217
|
||||
min.packages = sysPackages;
|
||||
min.appPackages = appPackages;
|
||||
|
||||
// NLP Manager.
|
||||
|
||||
const manager = new NlpManager({ languages: ['en'], forceNER: true });
|
||||
min['nerEngine'] = manager;
|
||||
|
||||
if (GBServer.globals.minBoot === undefined) {
|
||||
GBServer.globals.minBoot = min;
|
||||
}
|
||||
|
|
|
@ -175,14 +175,14 @@ export class GBSSR {
|
|||
});
|
||||
};
|
||||
|
||||
await sleep(15000);
|
||||
await sleep(6000);
|
||||
|
||||
// Inject <base> on page to relative resources load properly.
|
||||
|
||||
await page.evaluate(url => {
|
||||
const base = document.createElement('base');
|
||||
base.href = url;
|
||||
// Add to top of head, beeeEEEfore all other resources.
|
||||
// Add to top of head, before all other resources.
|
||||
document.head.prepend(base);
|
||||
}, url);
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ export class KBService implements IGBKBService {
|
|||
}
|
||||
|
||||
public async getAnswerById(instanceId: number, answerId: number): Promise<GuaribasAnswer> {
|
||||
return GuaribasAnswer.findOne({
|
||||
return await GuaribasAnswer.findOne({
|
||||
where: {
|
||||
instanceId: instanceId,
|
||||
answerId: answerId
|
||||
|
@ -332,7 +332,7 @@ export class KBService implements IGBKBService {
|
|||
return { answer: value, questionId: result.document.questionId };
|
||||
} else {
|
||||
GBLog.info(
|
||||
`SEARCH WILL NOT be used as answerId ${result.document.answerId} was not found in database,
|
||||
`Index problem. SEARCH WILL NOT be used as answerId ${result.document.answerId} was not found in database,
|
||||
returnedScore: ${returnedScore} < required (searchScore): ${searchScore}`
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue