Cleaning and KB improvements.
This commit is contained in:
parent
538996abfb
commit
fcbbcf1965
12 changed files with 50 additions and 103 deletions
10
.env
10
.env
|
@ -1,5 +1,5 @@
|
||||||
ADMIN_PASS=
|
ADMIN_PASS=am!dslfkj82
|
||||||
ADDITIONAL_DEPLOY_PATH=
|
ADDITIONAL_DEPLOY_PATH=C:\Sources\pragmatismo.io\pgma-website
|
||||||
DATABASE_DIALECT=sqlite
|
DATABASE_DIALECT=
|
||||||
DATABASE_OBJECT_PREFIX=env1-
|
DATABASE_OBJECT_PREFIX=
|
||||||
DATABASE_SYNC=false
|
DATABASE_SYNC=
|
16
.vscode/tasks.json
vendored
16
.vscode/tasks.json
vendored
|
@ -1,16 +0,0 @@
|
||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"type": "typescript",
|
|
||||||
"tsconfig": "tsconfig.json",
|
|
||||||
"problemMatcher": [
|
|
||||||
"$tsc"
|
|
||||||
],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||

|

|
||||||
|
|
||||||
Welcome to General Bots Community Edition!
|
Welcome to General Bots Community Edition!
|
||||||
-------
|
-------
|
||||||
|
@ -29,6 +29,13 @@ Office tools like Word or Excel to edit your Bot - using code (JavaScript or Typ
|
||||||
How To
|
How To
|
||||||
------
|
------
|
||||||
|
|
||||||
|
### Run the server
|
||||||
|
|
||||||
|
1. `git clone https://github.com/pragmatismo-io/BotServer.git` or just download the files to a folder;
|
||||||
|
2. Run `npm install` on that folder;
|
||||||
|
3. Enter './deploy/default.gbui' folder and run `npm install` folled by `npm run build` (To build default Bot UI);
|
||||||
|
4. On the downloaded folder (../..), run the bot server by `npm start`.
|
||||||
|
|
||||||
### Updating the Bot Knoledge Base (.gbkb folder)
|
### Updating the Bot Knoledge Base (.gbkb folder)
|
||||||
|
|
||||||
The subjects.json file contains all information related to the subject tree and can be used to build the menu carrousel as well give a set of words to be used as subject catcher in the conversation. A hierarchy can be specified.
|
The subjects.json file contains all information related to the subject tree and can be used to build the menu carrousel as well give a set of words to be used as subject catcher in the conversation. A hierarchy can be specified.
|
||||||
|
|
|
@ -150,8 +150,12 @@ export class AdminDialog extends IGBDialog {
|
||||||
) {
|
) {
|
||||||
let packageName = text.split(" ")[1];
|
let packageName = text.split(" ")[1];
|
||||||
session.send(`Deploying package ${packageName}... (It may take a few seconds)`);
|
session.send(`Deploying package ${packageName}... (It may take a few seconds)`);
|
||||||
|
|
||||||
|
// TODO: Find packages in all posible locations.
|
||||||
|
let additionalPath = GBConfigService.get("ADDITIONAL_DEPLOY_PATH");
|
||||||
|
|
||||||
deployer.deployPackageFromLocalPath(
|
deployer.deployPackageFromLocalPath(
|
||||||
UrlJoin("deploy", packageName),
|
UrlJoin(additionalPath, packageName),
|
||||||
(data, err) => {
|
(data, err) => {
|
||||||
session.send(`Package ${packageName} deployed... Please run rebuildIndex command.`);
|
session.send(`Package ${packageName} deployed... Please run rebuildIndex command.`);
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,9 @@ export class GBMinService {
|
||||||
min.botId = instance.botId;
|
min.botId = instance.botId;
|
||||||
min.core = _this.core;
|
min.core = _this.core;
|
||||||
min.conversationalService = _this.conversationalService;
|
min.conversationalService = _this.conversationalService;
|
||||||
|
_this.core.loadInstance(min.botId, (data, err) => {
|
||||||
|
min.instance = data;
|
||||||
|
});
|
||||||
|
|
||||||
let connector = new gBuilder.ChatConnector({
|
let connector = new gBuilder.ChatConnector({
|
||||||
appId: instance.marketplaceId,
|
appId: instance.marketplaceId,
|
||||||
|
@ -196,20 +199,20 @@ export class GBMinService {
|
||||||
botbuilder: (session, next) => {
|
botbuilder: (session, next) => {
|
||||||
if (!session.privateConversationData.loaded) {
|
if (!session.privateConversationData.loaded) {
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() =>
|
() => {
|
||||||
`Sending loading instance to client ${min.instance.ui}.`,
|
|
||||||
min.conversationalService.sendEvent(
|
min.conversationalService.sendEvent(
|
||||||
session,
|
session,
|
||||||
"loadInstance",
|
"loadInstance",
|
||||||
min.instance // TODO: Send a new thiner object.
|
min.instance // TODO: Send a new thiner object.
|
||||||
),
|
)
|
||||||
500
|
},
|
||||||
|
1500
|
||||||
);
|
);
|
||||||
session.privateConversationData.loaded = true;
|
session.privateConversationData.loaded = true;
|
||||||
appPackages.forEach(e => {
|
appPackages.forEach(e => {
|
||||||
e.onNewSession(min, session)
|
e.onNewSession(min, session)
|
||||||
});
|
});
|
||||||
// PACKAGE: min.subjects = [];
|
session.userData.subjects = [];
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
<link rel="stylesheet" type="text/css" href="./css/botchat.css" />
|
<link rel="stylesheet" type="text/css" href="./css/botchat.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="./css/pragmatismo.css" />
|
<link rel="stylesheet" type="text/css" href="./css/pragmatismo.css" />
|
||||||
<script type="text/javascript" src="./js/adal.min.js"></script>
|
|
||||||
<script src="./js/botchat.js"></script>
|
<script src="./js/botchat.js"></script>
|
||||||
<title>General Bots Community Edition | pragmatismo.io</title>
|
<title>General Bots Community Edition | pragmatismo.io</title>
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
// TODO: runWithAdal(authContext, () => {
|
import React from "react";
|
||||||
require('./indexApp');
|
import ReactDOM from "react-dom";
|
||||||
// DISABLED: });
|
import GBUIApp from "./GBUIApp";
|
||||||
|
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<GBUIApp head={document.getElementsByTagName("head")[0]} />,
|
||||||
|
document.getElementById("root")
|
||||||
|
);
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*****************************************************************************\
|
|
||||||
| ( )_ _ |
|
|
||||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
|
||||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
|
||||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
|
||||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
|
||||||
| | | ( )_) | |
|
|
||||||
| (_) \___/' |
|
|
||||||
| |
|
|
||||||
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
|
|
||||||
| Licensed under the AGPL-3.0. |
|
|
||||||
| |
|
|
||||||
| According to our dual licensing model, this program can be used either |
|
|
||||||
| under the terms of the GNU Affero General Public License, version 3, |
|
|
||||||
| or under a proprietary license. |
|
|
||||||
| |
|
|
||||||
| The texts of the GNU Affero General Public License with an additional |
|
|
||||||
| permission and of our proprietary license can be found at and |
|
|
||||||
| in the LICENSE file you have received along with this program. |
|
|
||||||
| |
|
|
||||||
| This program is distributed in the hope that it will be useful, |
|
|
||||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
||||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
||||||
| GNU Affero General Public License for more details. |
|
|
||||||
| |
|
|
||||||
| "General Bots" is a registered trademark of Pragmatismo.io. |
|
|
||||||
| The licensing of the program under the AGPLv3 does not imply a |
|
|
||||||
| trademark license. Therefore any rights, title and interest in |
|
|
||||||
| our trademarks remain entirely with us. |
|
|
||||||
| |
|
|
||||||
\*****************************************************************************/
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import ReactDOM from "react-dom";
|
|
||||||
import GBUIApp from "./GBUIApp";
|
|
||||||
|
|
||||||
|
|
||||||
ReactDOM.render(
|
|
||||||
<GBUIApp head={document.getElementsByTagName("head")[0]} />,
|
|
||||||
document.getElementById("root")
|
|
||||||
);
|
|
|
@ -31,7 +31,6 @@
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import {ReactPlayer} from 'react-player';
|
|
||||||
|
|
||||||
class GBVideoPlayer extends Component {
|
class GBVideoPlayer extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -62,7 +62,7 @@ export class MenuDialog extends IGBDialog {
|
||||||
.dialog("/menu", [
|
.dialog("/menu", [
|
||||||
(session, args) => {
|
(session, args) => {
|
||||||
var rootSubjectId = null;
|
var rootSubjectId = null;
|
||||||
var botId = min.instance.botId;
|
var botId = min.botId;
|
||||||
|
|
||||||
var msg = session.message;
|
var msg = session.message;
|
||||||
if (msg.attachments && msg.attachments.length > 0) {
|
if (msg.attachments && msg.attachments.length > 0) {
|
||||||
|
@ -146,7 +146,7 @@ export class MenuDialog extends IGBDialog {
|
||||||
"/kb",
|
"/kb",
|
||||||
min.instance.kb,
|
min.instance.kb,
|
||||||
"subjects",
|
"subjects",
|
||||||
"subject.png" // TODO: subject.internalId + ".png" or fallback to subject.png
|
subject.internalId + ".png" // TODO: or fallback to subject.png
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
]) // Using public dir of ui.
|
]) // Using public dir of ui.
|
||||||
|
|
|
@ -40,7 +40,7 @@ const Walk = require("fs-walk");
|
||||||
const WaitUntil = require("wait-until");
|
const WaitUntil = require("wait-until");
|
||||||
const marked = require("marked");
|
const marked = require("marked");
|
||||||
|
|
||||||
import { GuaribasQuestion, GuaribasAnswer, GuaribasSubject }from "../models";
|
import { GuaribasQuestion, GuaribasAnswer, GuaribasSubject } from "../models";
|
||||||
import { GBServiceCallback, IGBCoreService, IGBConversationalService, IGBInstance } from "botlib";
|
import { GBServiceCallback, IGBCoreService, IGBConversationalService, IGBInstance } from "botlib";
|
||||||
import { AzureSearch } from "pragmatismo-io-framework";
|
import { AzureSearch } from "pragmatismo-io-framework";
|
||||||
import { GBCoreService } from 'deploy/core.gbapp/services/GBCoreService';
|
import { GBCoreService } from 'deploy/core.gbapp/services/GBCoreService';
|
||||||
|
@ -74,16 +74,16 @@ export class KBService {
|
||||||
GuaribasQuestion.findOne({
|
GuaribasQuestion.findOne({
|
||||||
where: {
|
where: {
|
||||||
instanceId: instanceId,
|
instanceId: instanceId,
|
||||||
content: text
|
content: `${text.trim()}?`
|
||||||
}
|
}
|
||||||
}).then((question: GuaribasQuestion) => {
|
}).then((question: GuaribasQuestion) => {
|
||||||
GuaribasAnswer.findOne({
|
GuaribasAnswer.findAll({
|
||||||
where: {
|
where: {
|
||||||
instanceId: instanceId,
|
instanceId: instanceId,
|
||||||
answerId: question.answerId
|
answerId: question.answerId
|
||||||
}
|
}
|
||||||
}).then((answer: GuaribasAnswer) => {
|
}).then((answer: GuaribasAnswer[]) => {
|
||||||
cb({ question: question, answer: answer }, null);
|
cb({ question: question, answer: answer[0] }, null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -104,10 +104,6 @@ export class KBService {
|
||||||
subjects: GuaribasSubject[],
|
subjects: GuaribasSubject[],
|
||||||
cb: GBServiceCallback<any>
|
cb: GBServiceCallback<any>
|
||||||
) {
|
) {
|
||||||
if (instance.searchKey === "") {
|
|
||||||
cb(null, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Builds search query.
|
// Builds search query.
|
||||||
|
|
||||||
|
@ -463,7 +459,7 @@ export class KBService {
|
||||||
playerType: "video",
|
playerType: "video",
|
||||||
data: answer.content
|
data: answer.content
|
||||||
});
|
});
|
||||||
}else if (answer.content.length > 140) {
|
} else if (answer.content.length > 140) {
|
||||||
let msgs = [
|
let msgs = [
|
||||||
"Vou te responder na tela para melhor visualização...",
|
"Vou te responder na tela para melhor visualização...",
|
||||||
"A resposta está na tela...",
|
"A resposta está na tela...",
|
||||||
|
@ -592,21 +588,11 @@ export class KBService {
|
||||||
GuaribasPackage.destroy({
|
GuaribasPackage.destroy({
|
||||||
where: { instanceId: instance.instanceId, packageId: packageId }
|
where: { instanceId: instance.instanceId, packageId: packageId }
|
||||||
}).then(value => {
|
}).then(value => {
|
||||||
var search = new AzureSearch(
|
|
||||||
instance.searchKey,
|
|
||||||
instance.searchHost,
|
|
||||||
instance.searchIndex,
|
|
||||||
instance.searchIndexer
|
|
||||||
);
|
|
||||||
logger.trace("rebuildIndex called.");
|
|
||||||
search.rebuildIndex(() => {
|
|
||||||
logger.trace("rebuildIndex done.");
|
|
||||||
cb(null, null);
|
cb(null, null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "botserver",
|
"name": "botserver",
|
||||||
"version": "0.0.11",
|
"version": "0.0.14",
|
||||||
"description": "General Bots Community Edition open-core server.",
|
"description": "General Bots Community Edition open-core server.",
|
||||||
"author": "me@rodrigorodriguez.com",
|
"author": "me@rodrigorodriguez.com",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
"express": "^4.16.2",
|
"express": "^4.16.2",
|
||||||
"fs-walk": "0.0.1",
|
"fs-walk": "0.0.1",
|
||||||
"marked": "^0.3.12",
|
"marked": "^0.3.12",
|
||||||
"pragmatismo-io-framework": "^1.0.3",
|
"pragmatismo-io-framework": "^1.0.4",
|
||||||
"reflect-metadata": "^0.1.12",
|
"reflect-metadata": "^0.1.12",
|
||||||
"request-promise-native": "^1.0.5",
|
"request-promise-native": "^1.0.5",
|
||||||
"sequelize": "^4.37.6",
|
"sequelize": "^4.37.6",
|
||||||
|
|
Loading…
Add table
Reference in a new issue