From 62ef6e5416e329be1a9076bab57ba05a478c37cb Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Fri, 23 Oct 2020 09:55:44 -0300 Subject: [PATCH] new(core.gbapp): Entity extraction tested and startu optmizations. --- .../services/GBConversationalService.ts | 8 ++--- packages/core.gbapp/services/GBCoreService.ts | 21 ++---------- packages/core.gbapp/services/GBDeployer.ts | 10 ------ src/app.ts | 34 +++++-------------- 4 files changed, 14 insertions(+), 59 deletions(-) diff --git a/packages/core.gbapp/services/GBConversationalService.ts b/packages/core.gbapp/services/GBConversationalService.ts index 9782584b..f7aa8c18 100644 --- a/packages/core.gbapp/services/GBConversationalService.ts +++ b/packages/core.gbapp/services/GBConversationalService.ts @@ -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; diff --git a/packages/core.gbapp/services/GBCoreService.ts b/packages/core.gbapp/services/GBCoreService.ts index 8a6fe292..3fe31bab 100644 --- a/packages/core.gbapp/services/GBCoreService.ts +++ b/packages/core.gbapp/services/GBCoreService.ts @@ -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 { // NOTE: if there is any code before this line a semicolon // will be necessary before this line. diff --git a/packages/core.gbapp/services/GBDeployer.ts b/packages/core.gbapp/services/GBDeployer.ts index 82afc0b2..28f577d7 100644 --- a/packages/core.gbapp/services/GBDeployer.ts +++ b/packages/core.gbapp/services/GBDeployer.ts @@ -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(); diff --git a/src/app.ts b/src/app.ts index 65b030dd..162192df 100644 --- a/src/app.ts +++ b/src/app.ts @@ -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();