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=
|
||||
ADDITIONAL_DEPLOY_PATH=
|
||||
DATABASE_DIALECT=sqlite
|
||||
DATABASE_OBJECT_PREFIX=env1-
|
||||
DATABASE_SYNC=false
|
||||
ADMIN_PASS=am!dslfkj82
|
||||
ADDITIONAL_DEPLOY_PATH=C:\Sources\pragmatismo.io\pgma-website
|
||||
DATABASE_DIALECT=
|
||||
DATABASE_OBJECT_PREFIX=
|
||||
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!
|
||||
-------
|
||||
|
@ -29,6 +29,13 @@ Office tools like Word or Excel to edit your Bot - using code (JavaScript or Typ
|
|||
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)
|
||||
|
||||
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];
|
||||
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(
|
||||
UrlJoin("deploy", packageName),
|
||||
UrlJoin(additionalPath, packageName),
|
||||
(data, err) => {
|
||||
session.send(`Package ${packageName} deployed... Please run rebuildIndex command.`);
|
||||
|
||||
|
|
|
@ -154,6 +154,9 @@ export class GBMinService {
|
|||
min.botId = instance.botId;
|
||||
min.core = _this.core;
|
||||
min.conversationalService = _this.conversationalService;
|
||||
_this.core.loadInstance(min.botId, (data, err) => {
|
||||
min.instance = data;
|
||||
});
|
||||
|
||||
let connector = new gBuilder.ChatConnector({
|
||||
appId: instance.marketplaceId,
|
||||
|
@ -196,20 +199,20 @@ export class GBMinService {
|
|||
botbuilder: (session, next) => {
|
||||
if (!session.privateConversationData.loaded) {
|
||||
setTimeout(
|
||||
() =>
|
||||
`Sending loading instance to client ${min.instance.ui}.`,
|
||||
min.conversationalService.sendEvent(
|
||||
session,
|
||||
"loadInstance",
|
||||
min.instance // TODO: Send a new thiner object.
|
||||
),
|
||||
500
|
||||
() => {
|
||||
min.conversationalService.sendEvent(
|
||||
session,
|
||||
"loadInstance",
|
||||
min.instance // TODO: Send a new thiner object.
|
||||
)
|
||||
},
|
||||
1500
|
||||
);
|
||||
session.privateConversationData.loaded = true;
|
||||
appPackages.forEach(e => {
|
||||
e.onNewSession(min, session)
|
||||
});
|
||||
// PACKAGE: min.subjects = [];
|
||||
session.userData.subjects = [];
|
||||
}
|
||||
next();
|
||||
},
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
<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/pragmatismo.css" />
|
||||
<script type="text/javascript" src="./js/adal.min.js"></script>
|
||||
<script src="./js/botchat.js"></script>
|
||||
<title>General Bots Community Edition | pragmatismo.io</title>
|
||||
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
// TODO: runWithAdal(authContext, () => {
|
||||
require('./indexApp');
|
||||
// DISABLED: });
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
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 {ReactPlayer} from 'react-player';
|
||||
|
||||
class GBVideoPlayer extends Component {
|
||||
constructor() {
|
||||
|
|
|
@ -62,7 +62,7 @@ export class MenuDialog extends IGBDialog {
|
|||
.dialog("/menu", [
|
||||
(session, args) => {
|
||||
var rootSubjectId = null;
|
||||
var botId = min.instance.botId;
|
||||
var botId = min.botId;
|
||||
|
||||
var msg = session.message;
|
||||
if (msg.attachments && msg.attachments.length > 0) {
|
||||
|
@ -146,7 +146,7 @@ export class MenuDialog extends IGBDialog {
|
|||
"/kb",
|
||||
min.instance.kb,
|
||||
"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.
|
||||
|
|
|
@ -40,7 +40,7 @@ const Walk = require("fs-walk");
|
|||
const WaitUntil = require("wait-until");
|
||||
const marked = require("marked");
|
||||
|
||||
import { GuaribasQuestion, GuaribasAnswer, GuaribasSubject }from "../models";
|
||||
import { GuaribasQuestion, GuaribasAnswer, GuaribasSubject } from "../models";
|
||||
import { GBServiceCallback, IGBCoreService, IGBConversationalService, IGBInstance } from "botlib";
|
||||
import { AzureSearch } from "pragmatismo-io-framework";
|
||||
import { GBCoreService } from 'deploy/core.gbapp/services/GBCoreService';
|
||||
|
@ -74,16 +74,16 @@ export class KBService {
|
|||
GuaribasQuestion.findOne({
|
||||
where: {
|
||||
instanceId: instanceId,
|
||||
content: text
|
||||
content: `${text.trim()}?`
|
||||
}
|
||||
}).then((question: GuaribasQuestion) => {
|
||||
GuaribasAnswer.findOne({
|
||||
GuaribasAnswer.findAll({
|
||||
where: {
|
||||
instanceId: instanceId,
|
||||
answerId: question.answerId
|
||||
}
|
||||
}).then((answer: GuaribasAnswer) => {
|
||||
cb({ question: question, answer: answer }, null);
|
||||
}).then((answer: GuaribasAnswer[]) => {
|
||||
cb({ question: question, answer: answer[0] }, null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -104,10 +104,6 @@ export class KBService {
|
|||
subjects: GuaribasSubject[],
|
||||
cb: GBServiceCallback<any>
|
||||
) {
|
||||
if (instance.searchKey === "") {
|
||||
cb(null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Builds search query.
|
||||
|
||||
|
@ -463,7 +459,7 @@ export class KBService {
|
|||
playerType: "video",
|
||||
data: answer.content
|
||||
});
|
||||
}else if (answer.content.length > 140) {
|
||||
} else if (answer.content.length > 140) {
|
||||
let msgs = [
|
||||
"Vou te responder na tela para melhor visualização...",
|
||||
"A resposta está na tela...",
|
||||
|
@ -592,17 +588,7 @@ export class KBService {
|
|||
GuaribasPackage.destroy({
|
||||
where: { instanceId: instance.instanceId, packageId: packageId }
|
||||
}).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",
|
||||
"version": "0.0.11",
|
||||
"version": "0.0.14",
|
||||
"description": "General Bots Community Edition open-core server.",
|
||||
"author": "me@rodrigorodriguez.com",
|
||||
"license": "AGPL-3.0",
|
||||
|
@ -28,7 +28,7 @@
|
|||
"express": "^4.16.2",
|
||||
"fs-walk": "0.0.1",
|
||||
"marked": "^0.3.12",
|
||||
"pragmatismo-io-framework": "^1.0.3",
|
||||
"pragmatismo-io-framework": "^1.0.4",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"sequelize": "^4.37.6",
|
||||
|
|
Loading…
Add table
Reference in a new issue