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 }) {
|
||||
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,66 +221,8 @@ export class GBVMService extends GBService {
|
|||
}
|
||||
}
|
||||
|
||||
private syncStorageFromTABLE(folder: string, filename: string, min: GBMinInstance, mainName: string) {
|
||||
const tablesFile = urlJoin(folder, `${filename}.tables.json`);
|
||||
let sync = false;
|
||||
public static async loadConnections(min) {
|
||||
|
||||
if (Fs.existsSync(tablesFile)) {
|
||||
const minBoot = GBServer.globals.minBoot;
|
||||
|
||||
const tableDef = JSON.parse(Fs.readFileSync(tablesFile, 'utf8')) as any;
|
||||
|
||||
const getTypeBasedOnCondition = (t, size) => {
|
||||
if (1) {
|
||||
switch (t) {
|
||||
case 'string':
|
||||
return `varchar(${size})`;
|
||||
case 'guid':
|
||||
return 'UUID';
|
||||
case 'key':
|
||||
return `varchar(${size})`;
|
||||
case 'number':
|
||||
return 'BIGINT';
|
||||
case 'integer':
|
||||
return 'INTEGER';
|
||||
case 'double':
|
||||
return 'FLOAT';
|
||||
case 'float':
|
||||
return 'FLOAT';
|
||||
case 'date':
|
||||
return 'DATE';
|
||||
case 'boolean':
|
||||
return 'BOOLEAN';
|
||||
default:
|
||||
return { type: 'TABLE', name: t };
|
||||
}
|
||||
} else {
|
||||
switch (t) {
|
||||
case 'string':
|
||||
return { key: 'STRING' };
|
||||
case 'guid':
|
||||
return { key: 'UUID' };
|
||||
case 'key':
|
||||
return { key: 'STRING' }; // Assuming key is a string data type
|
||||
case 'number':
|
||||
return { key: 'BIGINT' };
|
||||
case 'integer':
|
||||
return { key: 'INTEGER' };
|
||||
case 'double':
|
||||
return { key: 'FLOAT' };
|
||||
case 'float':
|
||||
return { key: 'FLOAT' };
|
||||
case 'date':
|
||||
return { key: 'DATE' };
|
||||
case 'boolean':
|
||||
return { key: 'BOOLEAN' };
|
||||
default:
|
||||
return { key: 'TABLE', name: t };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const associations = [];
|
||||
|
||||
// Loads storage custom connections.
|
||||
const path = DialogKeywords.getGBAIPath(min.botId, null);
|
||||
|
@ -343,6 +285,68 @@ export class GBVMService extends GBService {
|
|||
min[connectionName]['gbconnection'] = con;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private syncStorageFromTABLE(folder: string, filename: string, min: GBMinInstance, mainName: string) {
|
||||
const tablesFile = urlJoin(folder, `${filename}.tables.json`);
|
||||
let sync = false;
|
||||
|
||||
if (Fs.existsSync(tablesFile)) {
|
||||
const minBoot = GBServer.globals.minBoot;
|
||||
|
||||
const tableDef = JSON.parse(Fs.readFileSync(tablesFile, 'utf8')) as any;
|
||||
|
||||
const getTypeBasedOnCondition = (t, size) => {
|
||||
if (1) {
|
||||
switch (t) {
|
||||
case 'string':
|
||||
return `varchar(${size})`;
|
||||
case 'guid':
|
||||
return 'UUID';
|
||||
case 'key':
|
||||
return `varchar(${size})`;
|
||||
case 'number':
|
||||
return 'BIGINT';
|
||||
case 'integer':
|
||||
return 'INTEGER';
|
||||
case 'double':
|
||||
return 'FLOAT';
|
||||
case 'float':
|
||||
return 'FLOAT';
|
||||
case 'date':
|
||||
return 'DATE';
|
||||
case 'boolean':
|
||||
return 'BOOLEAN';
|
||||
default:
|
||||
return { type: 'TABLE', name: t };
|
||||
}
|
||||
} else {
|
||||
switch (t) {
|
||||
case 'string':
|
||||
return { key: 'STRING' };
|
||||
case 'guid':
|
||||
return { key: 'UUID' };
|
||||
case 'key':
|
||||
return { key: 'STRING' }; // Assuming key is a string data type
|
||||
case 'number':
|
||||
return { key: 'BIGINT' };
|
||||
case 'integer':
|
||||
return { key: 'INTEGER' };
|
||||
case 'double':
|
||||
return { key: 'FLOAT' };
|
||||
case 'float':
|
||||
return { key: 'FLOAT' };
|
||||
case 'date':
|
||||
return { key: 'DATE' };
|
||||
case 'boolean':
|
||||
return { key: 'BOOLEAN' };
|
||||
default:
|
||||
return { key: 'TABLE', name: t };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const associations = [];
|
||||
|
||||
const shouldSync = min.core.getParam<boolean>(min.instance, 'Synchronize Database', false);
|
||||
|
||||
|
@ -1144,7 +1148,6 @@ export class GBVMService extends GBService {
|
|||
});
|
||||
const s = new VMScript(code, { filename: scriptPath });
|
||||
result = vm1.run(s);
|
||||
|
||||
});
|
||||
})();
|
||||
} else {
|
||||
|
|
|
@ -724,7 +724,7 @@ ENDPOINT_UPDATE=true
|
|||
* @param name Name of param to get from instance.
|
||||
* @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 params;
|
||||
name = name.trim();
|
||||
|
@ -774,6 +774,10 @@ ENDPOINT_UPDATE=true
|
|||
value = null;
|
||||
}
|
||||
|
||||
if (!value && platform){
|
||||
value = process.env[name.replace(/ /g, "_").toUpperCase()];
|
||||
}
|
||||
|
||||
if (value && typeof defaultValue === 'boolean') {
|
||||
return new Boolean(value ? value.toString().toLowerCase() === 'true' : defaultValue).valueOf();
|
||||
}
|
||||
|
|
|
@ -447,7 +447,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
rows.shift();
|
||||
}
|
||||
} 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
|
||||
rows = worksheet.getSheetValues();
|
||||
|
||||
|
@ -636,12 +636,23 @@ export class GBDeployer implements IGBDeployer {
|
|||
const connectionName = t.replace(strFind, '');
|
||||
let con = {};
|
||||
con['name'] = connectionName;
|
||||
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['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);
|
||||
} 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);
|
||||
});
|
||||
|
||||
|
|
|
@ -377,8 +377,8 @@ export class GBMinService {
|
|||
}
|
||||
res.end();
|
||||
});
|
||||
GBLog.verbose(`GeneralBots(${instance.engineName}) listening on: ${url}.`);
|
||||
|
||||
GBLog.verbose(`GeneralBots(${instance.engineName}) listening on: ${url}.`);
|
||||
|
||||
// Generates MS Teams manifest.
|
||||
|
||||
|
@ -390,6 +390,8 @@ export class GBMinService {
|
|||
Fs.writeFileSync(packageTeams, data);
|
||||
}
|
||||
|
||||
await GBVMService.loadConnections(min);
|
||||
|
||||
// Serves individual URL for each bot user interface.
|
||||
|
||||
if (process.env.DISABLE_WEB !== 'true') {
|
||||
|
|
|
@ -1061,7 +1061,7 @@ export class KBService implements IGBKBService {
|
|||
let logo = await this.getLogoByPage(min, page);
|
||||
if (logo) {
|
||||
path = DialogKeywords.getGBAIPath(min.botId);
|
||||
const logoPath = Path.join(process.env.PWD, 'work', path, 'cache');
|
||||
|
||||
const baseUrl = page.url().split('/').slice(0, 3).join('/');
|
||||
logo = logo.startsWith('https') ? logo : urlJoin(baseUrl, logo);
|
||||
|
||||
|
|
|
@ -294,12 +294,21 @@ export class ChatServices {
|
|||
|
||||
let model;
|
||||
|
||||
const azureOpenAIKey = await min.core.getParam(min.instance, 'Azure Open AI Key', null);
|
||||
const azureOpenAIGPTModel = await min.core.getParam(min.instance, 'Azure Open AI GPT Model', null);
|
||||
const azureOpenAIVersion = await min.core.getParam(min.instance, 'Azure Open AI Version', null);
|
||||
const azureOpenAIApiInstanceName = await min.core.getParam(min.instance, 'Azure Open AI Instance', null);
|
||||
const azureOpenAIKey = await (min.core as any)['getParam'](min.instance, 'Azure Open AI Key', null, true);
|
||||
const azureOpenAIGPTModel = await (min.core as any)['getParam'](
|
||||
min.instance,
|
||||
'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({
|
||||
azureOpenAIApiKey: azureOpenAIKey,
|
||||
azureOpenAIApiInstanceName: azureOpenAIApiInstanceName,
|
||||
|
@ -308,14 +317,6 @@ export class ChatServices {
|
|||
temperature: 0,
|
||||
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 toolsAsText = ChatServices.getToolsAsText(tools);
|
||||
|
@ -478,19 +479,22 @@ export class ChatServices {
|
|||
const con = min[`llm`]['gbconnection'];
|
||||
|
||||
const dialect = con['storageDriver'];
|
||||
|
||||
let dataSource;
|
||||
if (dialect === 'sqlite') {
|
||||
dataSource = new DataSource({
|
||||
type: 'sqlite',
|
||||
database: con['storageFile'],
|
||||
synchronize: false,
|
||||
logging: true
|
||||
});
|
||||
} else {
|
||||
const host = con['storageServer'];
|
||||
const port = con['storagePort'];
|
||||
const storageName = con['storageName'];
|
||||
const username = con['storageUsername'];
|
||||
const password = con['storagePassword'];
|
||||
|
||||
let dataSource;
|
||||
if (dialect === 'sqlite') {
|
||||
dataSource = new DataSource({
|
||||
type: 'sqlite',
|
||||
database: storageName
|
||||
});
|
||||
} else {
|
||||
dataSource = new DataSource({
|
||||
type: dialect as any,
|
||||
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