fix(all): TRUE multicloud.
This commit is contained in:
parent
21ed20dcf0
commit
7d459d5579
12 changed files with 160 additions and 109 deletions
|
@ -782,7 +782,7 @@ export class DialogKeywords {
|
||||||
*/
|
*/
|
||||||
public async getConfig({ pid, name }) {
|
public async getConfig({ pid, name }) {
|
||||||
let { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
let { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
||||||
return min.core.getParam(min.instance, name, null);
|
return min.core.getParam(min.instance, name, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -221,6 +221,72 @@ export class GBVMService extends GBService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async loadConnections(min) {
|
||||||
|
|
||||||
|
|
||||||
|
// Loads storage custom connections.
|
||||||
|
const path = DialogKeywords.getGBAIPath(min.botId, null);
|
||||||
|
const filePath = Path.join('work', path, 'connections.json');
|
||||||
|
let connections = [];
|
||||||
|
if (Fs.existsSync(filePath)) {
|
||||||
|
connections = JSON.parse(Fs.readFileSync(filePath, 'utf8'));
|
||||||
|
}
|
||||||
|
|
||||||
|
connections.forEach(async con => {
|
||||||
|
const connectionName = con['name'];
|
||||||
|
|
||||||
|
const dialect = con['storageDriver'];
|
||||||
|
const host = con['storageServer'];
|
||||||
|
const port = con['storagePort'];
|
||||||
|
const storageName = con['storageName'];
|
||||||
|
const username = con['storageUsername'];
|
||||||
|
const password = con['storagePassword'];
|
||||||
|
|
||||||
|
const logging: boolean | Function =
|
||||||
|
GBConfigService.get('STORAGE_LOGGING') === 'true'
|
||||||
|
? (str: string): void => {
|
||||||
|
GBLogEx.info(min, str);
|
||||||
|
}
|
||||||
|
: false;
|
||||||
|
|
||||||
|
const encrypt: boolean = GBConfigService.get('STORAGE_ENCRYPT') === 'true';
|
||||||
|
const acquire = parseInt(GBConfigService.get('STORAGE_ACQUIRE_TIMEOUT'));
|
||||||
|
const sequelizeOptions = {
|
||||||
|
define: {
|
||||||
|
charset: 'utf8',
|
||||||
|
collate: 'utf8_general_ci',
|
||||||
|
freezeTableName: true,
|
||||||
|
timestamps: false
|
||||||
|
},
|
||||||
|
host: host,
|
||||||
|
port: port,
|
||||||
|
logging: logging as boolean,
|
||||||
|
dialect: dialect,
|
||||||
|
quoteIdentifiers: false, // set case-insensitive
|
||||||
|
dialectOptions: {
|
||||||
|
options: {
|
||||||
|
trustServerCertificate: true,
|
||||||
|
encrypt: encrypt,
|
||||||
|
requestTimeout: 120 * 1000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pool: {
|
||||||
|
max: 5,
|
||||||
|
min: 0,
|
||||||
|
idle: 10000,
|
||||||
|
evict: 10000,
|
||||||
|
acquire: acquire
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!min[connectionName]) {
|
||||||
|
GBLogEx.info(min, `Loading custom connection ${connectionName}...`);
|
||||||
|
min[connectionName] = new Sequelize(storageName, username, password, sequelizeOptions);
|
||||||
|
min[connectionName]['gbconnection'] = con;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private syncStorageFromTABLE(folder: string, filename: string, min: GBMinInstance, mainName: string) {
|
private syncStorageFromTABLE(folder: string, filename: string, min: GBMinInstance, mainName: string) {
|
||||||
const tablesFile = urlJoin(folder, `${filename}.tables.json`);
|
const tablesFile = urlJoin(folder, `${filename}.tables.json`);
|
||||||
let sync = false;
|
let sync = false;
|
||||||
|
@ -282,68 +348,6 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
const associations = [];
|
const associations = [];
|
||||||
|
|
||||||
// Loads storage custom connections.
|
|
||||||
const path = DialogKeywords.getGBAIPath(min.botId, null);
|
|
||||||
const filePath = Path.join('work', path, 'connections.json');
|
|
||||||
let connections = [];
|
|
||||||
if (Fs.existsSync(filePath)) {
|
|
||||||
connections = JSON.parse(Fs.readFileSync(filePath, 'utf8'));
|
|
||||||
}
|
|
||||||
|
|
||||||
connections.forEach(async con => {
|
|
||||||
const connectionName = con['name'];
|
|
||||||
|
|
||||||
const dialect = con['storageDriver'];
|
|
||||||
const host = con['storageServer'];
|
|
||||||
const port = con['storagePort'];
|
|
||||||
const storageName = con['storageName'];
|
|
||||||
const username = con['storageUsername'];
|
|
||||||
const password = con['storagePassword'];
|
|
||||||
|
|
||||||
const logging: boolean | Function =
|
|
||||||
GBConfigService.get('STORAGE_LOGGING') === 'true'
|
|
||||||
? (str: string): void => {
|
|
||||||
GBLogEx.info(min, str);
|
|
||||||
}
|
|
||||||
: false;
|
|
||||||
|
|
||||||
const encrypt: boolean = GBConfigService.get('STORAGE_ENCRYPT') === 'true';
|
|
||||||
const acquire = parseInt(GBConfigService.get('STORAGE_ACQUIRE_TIMEOUT'));
|
|
||||||
const sequelizeOptions = {
|
|
||||||
define: {
|
|
||||||
charset: 'utf8',
|
|
||||||
collate: 'utf8_general_ci',
|
|
||||||
freezeTableName: true,
|
|
||||||
timestamps: false
|
|
||||||
},
|
|
||||||
host: host,
|
|
||||||
port: port,
|
|
||||||
logging: logging as boolean,
|
|
||||||
dialect: dialect,
|
|
||||||
quoteIdentifiers: false, // set case-insensitive
|
|
||||||
dialectOptions: {
|
|
||||||
options: {
|
|
||||||
trustServerCertificate: true,
|
|
||||||
encrypt: encrypt,
|
|
||||||
requestTimeout: 120 * 1000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
pool: {
|
|
||||||
max: 5,
|
|
||||||
min: 0,
|
|
||||||
idle: 10000,
|
|
||||||
evict: 10000,
|
|
||||||
acquire: acquire
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!min[connectionName]) {
|
|
||||||
GBLogEx.info(min, `Loading custom connection ${connectionName}...`);
|
|
||||||
min[connectionName] = new Sequelize(storageName, username, password, sequelizeOptions);
|
|
||||||
min[connectionName]['gbconnection'] = con;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const shouldSync = min.core.getParam<boolean>(min.instance, 'Synchronize Database', false);
|
const shouldSync = min.core.getParam<boolean>(min.instance, 'Synchronize Database', false);
|
||||||
|
|
||||||
tableDef.forEach(async t => {
|
tableDef.forEach(async t => {
|
||||||
|
@ -1144,7 +1148,6 @@ export class GBVMService extends GBService {
|
||||||
});
|
});
|
||||||
const s = new VMScript(code, { filename: scriptPath });
|
const s = new VMScript(code, { filename: scriptPath });
|
||||||
result = vm1.run(s);
|
result = vm1.run(s);
|
||||||
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -724,7 +724,7 @@ ENDPOINT_UPDATE=true
|
||||||
* @param name Name of param to get from instance.
|
* @param name Name of param to get from instance.
|
||||||
* @param defaultValue Value returned when no param is defined in Config.xlsx.
|
* @param defaultValue Value returned when no param is defined in Config.xlsx.
|
||||||
*/
|
*/
|
||||||
public getParam<T>(instance: IGBInstance, name: string, defaultValue?: T): any {
|
public getParam<T>(instance: IGBInstance, name: string, defaultValue?: T, platform=false): any {
|
||||||
let value = null;
|
let value = null;
|
||||||
let params;
|
let params;
|
||||||
name = name.trim();
|
name = name.trim();
|
||||||
|
@ -774,6 +774,10 @@ ENDPOINT_UPDATE=true
|
||||||
value = null;
|
value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!value && platform){
|
||||||
|
value = process.env[name.replace(/ /g, "_").toUpperCase()];
|
||||||
|
}
|
||||||
|
|
||||||
if (value && typeof defaultValue === 'boolean') {
|
if (value && typeof defaultValue === 'boolean') {
|
||||||
return new Boolean(value ? value.toString().toLowerCase() === 'true' : defaultValue).valueOf();
|
return new Boolean(value ? value.toString().toLowerCase() === 'true' : defaultValue).valueOf();
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,7 +447,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
rows.shift();
|
rows.shift();
|
||||||
}
|
}
|
||||||
} else if (Fs.existsSync(csv)) {
|
} else if (Fs.existsSync(csv)) {
|
||||||
await workbook.csv.readFile(filePath);
|
await workbook.csv.readFile(csv);
|
||||||
let worksheet = workbook.worksheets[0]; // Assuming the CSV file has only one sheet
|
let worksheet = workbook.worksheets[0]; // Assuming the CSV file has only one sheet
|
||||||
rows = worksheet.getSheetValues();
|
rows = worksheet.getSheetValues();
|
||||||
|
|
||||||
|
@ -636,12 +636,23 @@ export class GBDeployer implements IGBDeployer {
|
||||||
const connectionName = t.replace(strFind, '');
|
const connectionName = t.replace(strFind, '');
|
||||||
let con = {};
|
let con = {};
|
||||||
con['name'] = connectionName;
|
con['name'] = connectionName;
|
||||||
con['storageServer'] = min.core.getParam<string>(min.instance, `${connectionName} Server`, null);
|
|
||||||
con['storageUsername'] = min.core.getParam<string>(min.instance, `${connectionName} Username`, null);
|
|
||||||
con['storageName'] = min.core.getParam<string>(min.instance, `${connectionName} Name`, null);
|
|
||||||
con['storagePort'] = min.core.getParam<string>(min.instance, `${connectionName} Port`, null);
|
|
||||||
con['storagePassword'] = min.core.getParam<string>(min.instance, `${connectionName} Password`, null);
|
|
||||||
con['storageDriver'] = min.core.getParam<string>(min.instance, `${connectionName} Driver`, null);
|
con['storageDriver'] = min.core.getParam<string>(min.instance, `${connectionName} Driver`, null);
|
||||||
|
const storageName = min.core.getParam<string>(min.instance, `${connectionName} Name`, null);
|
||||||
|
|
||||||
|
let file = min.core.getParam<string>(min.instance, `${connectionName} File`, null);
|
||||||
|
|
||||||
|
if (storageName) {
|
||||||
|
con['storageName'] = storageName;
|
||||||
|
con['storageServer'] = min.core.getParam<string>(min.instance, `${connectionName} Server`, null);
|
||||||
|
con['storageUsername'] = min.core.getParam<string>(min.instance, `${connectionName} Username`, null);
|
||||||
|
con['storagePort'] = min.core.getParam<string>(min.instance, `${connectionName} Port`, null);
|
||||||
|
con['storagePassword'] = min.core.getParam<string>(min.instance, `${connectionName} Password`, null);
|
||||||
|
} else if (file) {
|
||||||
|
const path = DialogKeywords.getGBAIPath(min.botId, 'gbdata');
|
||||||
|
con['storageFile'] = Path.join(GBConfigService.get('STORAGE_LIBRARY'), path, file);
|
||||||
|
} else {
|
||||||
|
GBLogEx.debug(min, `No storage information found for ${connectionName}, missing storage name or file.`);
|
||||||
|
}
|
||||||
connections.push(con);
|
connections.push(con);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -377,8 +377,8 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
GBLog.verbose(`GeneralBots(${instance.engineName}) listening on: ${url}.`);
|
|
||||||
|
|
||||||
|
GBLog.verbose(`GeneralBots(${instance.engineName}) listening on: ${url}.`);
|
||||||
|
|
||||||
// Generates MS Teams manifest.
|
// Generates MS Teams manifest.
|
||||||
|
|
||||||
|
@ -390,7 +390,9 @@ export class GBMinService {
|
||||||
Fs.writeFileSync(packageTeams, data);
|
Fs.writeFileSync(packageTeams, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serves individual URL for each bot user interface.
|
await GBVMService.loadConnections(min);
|
||||||
|
|
||||||
|
// Serves individual URL for each bot user interface.
|
||||||
|
|
||||||
if (process.env.DISABLE_WEB !== 'true') {
|
if (process.env.DISABLE_WEB !== 'true') {
|
||||||
const uiUrl = `/${instance.botId}`;
|
const uiUrl = `/${instance.botId}`;
|
||||||
|
|
|
@ -1061,7 +1061,7 @@ export class KBService implements IGBKBService {
|
||||||
let logo = await this.getLogoByPage(min, page);
|
let logo = await this.getLogoByPage(min, page);
|
||||||
if (logo) {
|
if (logo) {
|
||||||
path = DialogKeywords.getGBAIPath(min.botId);
|
path = DialogKeywords.getGBAIPath(min.botId);
|
||||||
const logoPath = Path.join(process.env.PWD, 'work', path, 'cache');
|
|
||||||
const baseUrl = page.url().split('/').slice(0, 3).join('/');
|
const baseUrl = page.url().split('/').slice(0, 3).join('/');
|
||||||
logo = logo.startsWith('https') ? logo : urlJoin(baseUrl, logo);
|
logo = logo.startsWith('https') ? logo : urlJoin(baseUrl, logo);
|
||||||
|
|
||||||
|
|
|
@ -294,28 +294,29 @@ export class ChatServices {
|
||||||
|
|
||||||
let model;
|
let model;
|
||||||
|
|
||||||
const azureOpenAIKey = await min.core.getParam(min.instance, 'Azure Open AI Key', null);
|
const azureOpenAIKey = await (min.core as any)['getParam'](min.instance, 'Azure Open AI Key', null, true);
|
||||||
const azureOpenAIGPTModel = await min.core.getParam(min.instance, 'Azure Open AI GPT Model', null);
|
const azureOpenAIGPTModel = await (min.core as any)['getParam'](
|
||||||
const azureOpenAIVersion = await min.core.getParam(min.instance, 'Azure Open AI Version', null);
|
min.instance,
|
||||||
const azureOpenAIApiInstanceName = await min.core.getParam(min.instance, 'Azure Open AI Instance', null);
|
'Azure Open AI GPT Model',
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
const azureOpenAIVersion = await (min.core as any)['getParam'](min.instance, 'Azure Open AI Version', null, true);
|
||||||
|
const azureOpenAIApiInstanceName = await (min.core as any)['getParam'](
|
||||||
|
min.instance,
|
||||||
|
'Azure Open AI Instance',
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
if (azureOpenAIKey) {
|
model = new ChatOpenAI({
|
||||||
model = new ChatOpenAI({
|
azureOpenAIApiKey: azureOpenAIKey,
|
||||||
azureOpenAIApiKey: azureOpenAIKey,
|
azureOpenAIApiInstanceName: azureOpenAIApiInstanceName,
|
||||||
azureOpenAIApiInstanceName: azureOpenAIApiInstanceName,
|
azureOpenAIApiDeploymentName: azureOpenAIGPTModel,
|
||||||
azureOpenAIApiDeploymentName: azureOpenAIGPTModel,
|
azureOpenAIApiVersion: azureOpenAIVersion,
|
||||||
azureOpenAIApiVersion: azureOpenAIVersion,
|
temperature: 0,
|
||||||
temperature: 0,
|
callbacks: [logHandler]
|
||||||
callbacks: [logHandler]
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
model = new ChatOpenAI({
|
|
||||||
openAIApiKey: process.env.OPENAI_API_KEY,
|
|
||||||
modelName: 'gpt-3.5-turbo-0125',
|
|
||||||
temperature: 0,
|
|
||||||
callbacks: [logHandler]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let tools = await ChatServices.getTools(min);
|
let tools = await ChatServices.getTools(min);
|
||||||
let toolsAsText = ChatServices.getToolsAsText(tools);
|
let toolsAsText = ChatServices.getToolsAsText(tools);
|
||||||
|
@ -478,19 +479,22 @@ export class ChatServices {
|
||||||
const con = min[`llm`]['gbconnection'];
|
const con = min[`llm`]['gbconnection'];
|
||||||
|
|
||||||
const dialect = con['storageDriver'];
|
const dialect = con['storageDriver'];
|
||||||
const host = con['storageServer'];
|
|
||||||
const port = con['storagePort'];
|
|
||||||
const storageName = con['storageName'];
|
|
||||||
const username = con['storageUsername'];
|
|
||||||
const password = con['storagePassword'];
|
|
||||||
|
|
||||||
let dataSource;
|
let dataSource;
|
||||||
if (dialect === 'sqlite') {
|
if (dialect === 'sqlite') {
|
||||||
dataSource = new DataSource({
|
dataSource = new DataSource({
|
||||||
type: 'sqlite',
|
type: 'sqlite',
|
||||||
database: storageName
|
database: con['storageFile'],
|
||||||
|
synchronize: false,
|
||||||
|
logging: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
const host = con['storageServer'];
|
||||||
|
const port = con['storagePort'];
|
||||||
|
const storageName = con['storageName'];
|
||||||
|
const username = con['storageUsername'];
|
||||||
|
const password = con['storagePassword'];
|
||||||
|
|
||||||
dataSource = new DataSource({
|
dataSource = new DataSource({
|
||||||
type: dialect as any,
|
type: dialect as any,
|
||||||
host: host,
|
host: host,
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
REM SET SCHEDULE "* 8 * * * *"
|
|
||||||
user = “user@domain.com”
|
|
||||||
pass= "*************"
|
|
||||||
o =get "https://oooooooooo"
|
|
||||||
caption = REWRITE "Crie um post sobre hotmart e seus produtos, no estilo dica do dia incluíndo 10 hashtags, estilo instagram o texto! Importante, retorne só a saída de texto pronta"
|
|
||||||
image = GET IMAGE caption
|
|
||||||
POST username, password, image, caption
|
|
20
templates/marketing.gbai/marketing.gbdialog/poster.bas
Normal file
20
templates/marketing.gbai/marketing.gbdialog/poster.bas
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
REM SET SCHEDULE "* 8 * * * *"
|
||||||
|
|
||||||
|
user = "user@domain.com"
|
||||||
|
pass = "*************"
|
||||||
|
o = get "https://oooooooooo"
|
||||||
|
|
||||||
|
# Criar a legenda para o post
|
||||||
|
caption = REWRITE "Crie um post sobre Hotmart e seus produtos, no estilo dica do dia, incluindo 10 hashtags, estilo Instagram o texto! Importante, retorne só a saída de texto pronta"
|
||||||
|
|
||||||
|
# Obter uma imagem relacionada ao conteúdo
|
||||||
|
image = GET IMAGE caption
|
||||||
|
|
||||||
|
# Postar no Instagram
|
||||||
|
POST TO INSTAGRAM username, password, image, caption
|
||||||
|
|
||||||
|
# Postar no Facebook
|
||||||
|
POST TO FACEBOOK username, password, image, caption
|
||||||
|
|
||||||
|
# Postar no Twitter
|
||||||
|
TWEET username, password, image, caption
|
Binary file not shown.
10
templates/talk-to-data.gbai/talk-to-data.gbialog/start.bas
Normal file
10
templates/talk-to-data.gbai/talk-to-data.gbialog/start.bas
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
data = FIND "products.csv"
|
||||||
|
BEGIN SYSTEM PROMPT
|
||||||
|
Engage users effectively as if you're a sales assistant in the virtual store.
|
||||||
|
Begin by welcoming them warmly and encouraging them to explore our range of products.
|
||||||
|
Provide clear instructions on how to inquire about specific items or browse
|
||||||
|
categories. Ensure the tone is friendly, helpful, and inviting to encourage
|
||||||
|
interaction. Use prompts to guide users through the purchasing process and offer
|
||||||
|
assistance whenever needed. Offer them this products: ${ TOJSON (data) }
|
||||||
|
END SYSTEM PROMPT
|
4
templates/talk-to-data.gbai/talk-to-data.gbot/config.csv
Normal file
4
templates/talk-to-data.gbai/talk-to-data.gbot/config.csv
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
name,value
|
||||||
|
Answer Mode,sql
|
||||||
|
llm File,northwind.db
|
||||||
|
llm Driver,sqlite
|
|
Loading…
Add table
Reference in a new issue