new(core.gbapp): Entity extraction tested and startu optmizations.

This commit is contained in:
Rodrigo Rodriguez 2020-10-23 09:55:44 -03:00
parent 0aca3853d6
commit 62ef6e5416
4 changed files with 14 additions and 59 deletions

View file

@ -508,18 +508,14 @@ export class GBConversationalService {
const topIntent = LuisRecognizer.topIntent(nlp);
if (topIntent !== undefined && nlpActive) {
const intent = topIntent;
// tslint:disable:no-unsafe-any
const firstEntity = nlp.entities && nlp.entities.length > 0 ? nlp.entities[0].entity.toUpperCase() : undefined;
// tslint:ensable:no-unsafe-any
if (intent === 'None') {
return false;
}
GBLog.info(`NLP called: ${intent} ${firstEntity}`);
GBLog.info(`NLP called: ${intent}, entities: ${nlp.entities}`);
try {
step.activeDialog.state.otptions.entities = nlp.entities;
step.activeDialog.state.options.entities = nlp.entities;
await step.replaceDialog(`/${intent}`, step.activeDialog.state.options);
return true;

View file

@ -98,7 +98,9 @@ export class GBCoreService implements IGBCoreService {
constructor() {
this.adminService = new GBAdminService(this);
}
public async ensureInstances(instances: IGBInstance[], bootInstance: any, core: IGBCoreService) {
}
/**
* Gets database config and connect to storage.
*/
@ -405,23 +407,6 @@ STORAGE_SYNC=true
return instances;
}
/**
* If instances is undefined here it's because storage has been formatted.
* Load all instances from .gbot found on deploy package directory.
* @param instances
* @param bootInstance
* @param core
*/
public async ensureInstances(instances: IGBInstance[], bootInstance: any, core: IGBCoreService) {
if (instances === undefined) {
const instance = new GuaribasInstance();
await instance.save();
instances = await core.loadInstances();
}
return instances;
}
public async loadSysPackages(core: GBCoreService): Promise<IGBPackage[]> {
// NOTE: if there is any code before this line a semicolon
// will be necessary before this line.

View file

@ -571,16 +571,6 @@ export class GBDeployer implements IGBDeployer {
throw e;
}
// Deploys all .gbot files first.
await CollectionUtil.asyncForEach(botPackages, async e => {
if (e !== 'packages\\boot.gbot') {
GBLog.info(`Deploying bot: ${e}...`);
await _this.deployBotFromLocalPath(e, GBServer.globals.publicAddress);
GBLog.info(`√ Bot: ${e} deployed...`);
}
});
// Then all remaining generalPackages are loaded.
const instances = core.loadInstances();

View file

@ -60,20 +60,18 @@ export class RootData {
public server: any; // Express reference
public sysPackages: any[]; // Loaded system package list
public appPackages: any[]; // Loaded .gbapp package list
public minService: GBMinService; // Minimalist service core
public minService: GBMinService; // Minimalist service core
public bootInstance: IGBInstance; // General Bot Interface Instance
public minInstances: any[]; //
public minBoot: GBMinInstance;
public wwwroot: string; // .gbui or a static webapp.
public entryPointDialog: string; // To replace default welcome dialog.
}
/**
* General Bots open-core entry point.
*/
export class GBServer {
public static globals: RootData;
/**
@ -81,7 +79,6 @@ export class GBServer {
*/
public static run() {
GBLog.info(`The Bot Server is in STARTING mode...`);
GBServer.globals = new RootData();
GBConfigService.init();
@ -117,7 +114,6 @@ export class GBServer {
const azureDeployer: AzureDeployerService = new AzureDeployerService(deployer);
const adminService: GBAdminService = new GBAdminService(core);
if (process.env.NODE_ENV === 'development') {
const proxy = GBConfigService.get('REVERSE_PROXY');
if (proxy !== undefined) {
@ -141,7 +137,7 @@ export class GBServer {
await core.initStorage();
} catch (error) {
GBLog.verbose(`Error initializing storage: ${error}`);
GBServer.globals.bootInstance = await core.createBootInstance(core, azureDeployer, GBServer.globals.publicAddress);
await core.createBootInstance(core, azureDeployer, GBServer.globals.publicAddress);
await core.initStorage();
}
@ -156,24 +152,12 @@ export class GBServer {
// Loads boot bot and other instances.
GBLog.info(`Publishing instances...`);
const packageInstance = await importer.importIfNotExistsBotPackage(
GBConfigService.get('BOT_ID'),
'boot.gbot',
'packages/boot.gbot'
let instances: IGBInstance[] = await core.loadAllInstances(
core,
azureDeployer,
GBServer.globals.publicAddress
);
if (GBServer.globals.bootInstance === undefined) {
GBServer.globals.bootInstance = packageInstance;
}
// tslint:disable-next-line:prefer-object-spread
const fullInstance = Object.assign(packageInstance, GBServer.globals.bootInstance);
await core.saveInstance(fullInstance);
let instances: IGBInstance[] = await core.loadAllInstances(core, azureDeployer,
GBServer.globals.publicAddress);
instances = await core.ensureInstances(instances, GBServer.globals.bootInstance, core);
if (GBServer.globals.bootInstance !== undefined) {
GBServer.globals.bootInstance = instances[0];
}
GBServer.globals.bootInstance = instances[0];
// Builds minimal service infrastructure.
@ -184,12 +168,12 @@ export class GBServer {
// Deployment of local applications for the first time.
if (GBConfigService.get("DISABLE_WEB") !== "true") {
if (GBConfigService.get('DISABLE_WEB') !== 'true') {
deployer.setupDefaultGBUI();
}
GBLog.info(`The Bot Server is in RUNNING mode...`);
// Opens Navigator.
// TODO: Config: core.openBrowserInDevelopment();