fix (all): path and fs normalization.
This commit is contained in:
parent
698df5a830
commit
27ebf35579
15 changed files with 116 additions and 116 deletions
|
@ -152,8 +152,8 @@ export class GBAdminService implements IGBAdminService {
|
||||||
const packageName = text.split(' ')[1];
|
const packageName = text.split(' ')[1];
|
||||||
const importer = new GBImporter(min.core);
|
const importer = new GBImporter(min.core);
|
||||||
const deployer = new GBDeployer(min.core, importer);
|
const deployer = new GBDeployer(min.core, importer);
|
||||||
const path = GBUtil.getGBAIPath(min.botId, null, packageName);
|
const packagePath = GBUtil.getGBAIPath(min.botId, null, packageName);
|
||||||
const localFolder = path.join('work', path);
|
const localFolder = path.join('work', packagePath);
|
||||||
await deployer.undeployPackageFromLocalPath(min.instance, localFolder);
|
await deployer.undeployPackageFromLocalPath(min.instance, localFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1035,7 +1035,7 @@ export class DialogKeywords {
|
||||||
|
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
const path = GBUtil.getGBAIPath(botId);
|
const packagePath = GBUtil.getGBAIPath(botId);
|
||||||
let url = `${baseUrl}/drive/root:/${path}:/children`;
|
let url = `${baseUrl}/drive/root:/${path}:/children`;
|
||||||
|
|
||||||
GBLogEx.info(min, `Loading HEAR AS .xlsx options from Sheet: ${url}`);
|
GBLogEx.info(min, `Loading HEAR AS .xlsx options from Sheet: ${url}`);
|
||||||
|
|
|
@ -224,8 +224,8 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
public static async loadConnections(min) {
|
public static async loadConnections(min) {
|
||||||
// Loads storage custom connections.
|
// Loads storage custom connections.
|
||||||
const path = GBUtil.getGBAIPath(min.botId, null);
|
const packagePath = GBUtil.getGBAIPath(min.botId, null);
|
||||||
const filePath = path.join('work', path, 'connections.json');
|
const filePath = path.join('work', packagePath, 'connections.json');
|
||||||
let connections = [];
|
let connections = [];
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
connections = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
connections = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||||
|
@ -756,11 +756,11 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
private async getTextFromWord(folder: string, filename: string) {
|
private async getTextFromWord(folder: string, filename: string) {
|
||||||
return new Promise<string>(async (resolve, reject) => {
|
return new Promise<string>(async (resolve, reject) => {
|
||||||
const path = urlJoin(folder, filename);
|
const filePath = urlJoin(folder, filename);
|
||||||
textract.fromFileWithPath(path, { preserveLineBreaks: true }, (error, text) => {
|
textract.fromFileWithPath(filePath, { preserveLineBreaks: true }, (error, text) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error.message.startsWith('File not correctly recognized as zip file')) {
|
if (error.message.startsWith('File not correctly recognized as zip file')) {
|
||||||
text = fs.readFileSync(path, 'utf8');
|
text = fs.readFileSync(filePath, 'utf8');
|
||||||
} else {
|
} else {
|
||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
|
@ -1090,8 +1090,8 @@ export class GBVMService extends GBService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const botId = min.botId;
|
const botId = min.botId;
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbdialog`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbdialog`);
|
||||||
const gbdialogPath = urlJoin(process.cwd(), 'work', path);
|
const gbdialogPath = urlJoin(process.cwd(), 'work', packagePath);
|
||||||
const scriptFilePath = urlJoin(gbdialogPath, `${text}.js`);
|
const scriptFilePath = urlJoin(gbdialogPath, `${text}.js`);
|
||||||
|
|
||||||
let code = min.sandBoxMap[text];
|
let code = min.sandBoxMap[text];
|
||||||
|
|
|
@ -75,9 +75,9 @@ export class ImageProcessingServices {
|
||||||
});
|
});
|
||||||
|
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
const path = GBUtil.getGBAIPath(min.botId);
|
const packagePath = GBUtil.getGBAIPath(min.botId);
|
||||||
// TODO: const img = await joinImages(paths);
|
// TODO: const img = await joinImages(paths);
|
||||||
const localName = path.join('work', path, 'cache', `img-mrg${GBAdminService.getRndReadableIdentifier()}.png`);
|
const localName = path.join('work', packagePath, 'cache', `img-mrg${GBAdminService.getRndReadableIdentifier()}.png`);
|
||||||
const url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(localName));
|
const url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(localName));
|
||||||
// img.toFile(localName);
|
// img.toFile(localName);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import { setFlagsFromString } from 'v8';
|
||||||
import { runInNewContext } from 'vm';
|
import { runInNewContext } from 'vm';
|
||||||
import { IgApiClient } from 'instagram-private-api';
|
import { IgApiClient } from 'instagram-private-api';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { resolve } from 'path';
|
import path, { resolve } from 'path';
|
||||||
import { GBLog, GBMinInstance } from 'botlib';
|
import { GBLog, GBMinInstance } from 'botlib';
|
||||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
|
@ -48,7 +48,7 @@ import urlJoin from 'url-join';
|
||||||
import Excel from 'exceljs';
|
import Excel from 'exceljs';
|
||||||
import { BufferWindowMemory } from 'langchain/memory';
|
import { BufferWindowMemory } from 'langchain/memory';
|
||||||
import csvdb from 'csv-database';
|
import csvdb from 'csv-database';
|
||||||
import path from 'path';
|
import packagePath from 'path';
|
||||||
import ComputerVisionClient from '@azure/cognitiveservices-computervision';
|
import ComputerVisionClient from '@azure/cognitiveservices-computervision';
|
||||||
import ApiKeyCredentials from '@azure/ms-rest-js';
|
import ApiKeyCredentials from '@azure/ms-rest-js';
|
||||||
import alasql from 'alasql';
|
import alasql from 'alasql';
|
||||||
|
@ -570,8 +570,8 @@ export class SystemKeywords {
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
|
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
const path = GBUtil.getGBAIPath(botId, 'gbdata');
|
const packagePath = GBUtil.getGBAIPath(botId, 'gbdata');
|
||||||
let document = await this.internalGetDocument(client, baseUrl, path, file);
|
let document = await this.internalGetDocument(client, baseUrl, packagePath, file);
|
||||||
let sheets = await client.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`).get();
|
let sheets = await client.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`).get();
|
||||||
let body = { values: [[]] };
|
let body = { values: [[]] };
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ export class SystemKeywords {
|
||||||
GBLogEx.info(min, `Saving '${file}' (SAVE file).`);
|
GBLogEx.info(min, `Saving '${file}' (SAVE file).`);
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
||||||
|
|
||||||
// Checks if it is a GB FILE object.
|
// Checks if it is a GB FILE object.
|
||||||
|
|
||||||
|
@ -665,7 +665,7 @@ export class SystemKeywords {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data = GBServer.globals.files[data].data; // TODO
|
data = GBServer.globals.files[data].data; // TODO
|
||||||
await client.api(`${baseUrl}/drive/root:/${path}/${file}:/content`).put(data);
|
await client.api(`${baseUrl}/drive/root:/${packagePath}/${file}:/content`).put(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 'itemNotFound') {
|
if (error.code === 'itemNotFound') {
|
||||||
GBLogEx.info(min, `BASIC source file not found: ${file}.`);
|
GBLogEx.info(min, `BASIC source file not found: ${file}.`);
|
||||||
|
@ -874,12 +874,12 @@ export class SystemKeywords {
|
||||||
GBLogEx.info(min, `Saving '${file}' (SAVE). Args: ${args.join(',')}.`);
|
GBLogEx.info(min, `Saving '${file}' (SAVE). Args: ${args.join(',')}.`);
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
const path = GBUtil.getGBAIPath(botId, 'gbdata');
|
const packagePath = GBUtil.getGBAIPath(botId, 'gbdata');
|
||||||
|
|
||||||
let sheets;
|
let sheets;
|
||||||
let document;
|
let document;
|
||||||
try {
|
try {
|
||||||
document = await this.internalGetDocument(client, baseUrl, path, file);
|
document = await this.internalGetDocument(client, baseUrl, packagePath, file);
|
||||||
sheets = await client.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`).get();
|
sheets = await client.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`).get();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.cause === 404) {
|
if (e.cause === 404) {
|
||||||
|
@ -887,11 +887,11 @@ export class SystemKeywords {
|
||||||
|
|
||||||
const blank = path.join(process.env.PWD, 'blank.xlsx');
|
const blank = path.join(process.env.PWD, 'blank.xlsx');
|
||||||
const data = fs.readFileSync(blank);
|
const data = fs.readFileSync(blank);
|
||||||
await client.api(`${baseUrl}/drive/root:/${path}/${file}:/content`).put(data);
|
await client.api(`${baseUrl}/drive/root:/${packagePath}/${file}:/content`).put(data);
|
||||||
|
|
||||||
// Tries to open again.
|
// Tries to open again.
|
||||||
|
|
||||||
document = await this.internalGetDocument(client, baseUrl, path, file);
|
document = await this.internalGetDocument(client, baseUrl, packagePath, file);
|
||||||
sheets = await client.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`).get();
|
sheets = await client.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`).get();
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -993,9 +993,9 @@ export class SystemKeywords {
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
('');
|
('');
|
||||||
const path = GBUtil.getGBAIPath(botId, 'gbdata');
|
const packagePath = GBUtil.getGBAIPath(botId, 'gbdata');
|
||||||
|
|
||||||
let document = await this.internalGetDocument(client, baseUrl, path, file);
|
let document = await this.internalGetDocument(client, baseUrl, packagePath, file);
|
||||||
|
|
||||||
// Creates workbook session that will be discarded.
|
// Creates workbook session that will be discarded.
|
||||||
|
|
||||||
|
@ -1091,7 +1091,7 @@ export class SystemKeywords {
|
||||||
args.shift();
|
args.shift();
|
||||||
|
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
const path = GBUtil.getGBAIPath(botId, 'gbdata');
|
const packagePath = GBUtil.getGBAIPath(botId, 'gbdata');
|
||||||
|
|
||||||
// MAX LINES property.
|
// MAX LINES property.
|
||||||
|
|
||||||
|
@ -1183,7 +1183,7 @@ export class SystemKeywords {
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
|
|
||||||
let document;
|
let document;
|
||||||
document = await this.internalGetDocument(client, baseUrl, path, file);
|
document = await this.internalGetDocument(client, baseUrl, packagePath, file);
|
||||||
|
|
||||||
// Creates workbook session that will be discarded.
|
// Creates workbook session that will be discarded.
|
||||||
|
|
||||||
|
@ -1519,8 +1519,8 @@ export class SystemKeywords {
|
||||||
if (user) {
|
if (user) {
|
||||||
ChatServices.userSystemPrompt[user.userSystemId] = text;
|
ChatServices.userSystemPrompt[user.userSystemId] = text;
|
||||||
|
|
||||||
const path = GBUtil.getGBAIPath(min.botId);
|
const packagePath = GBUtil.getGBAIPath(min.botId);
|
||||||
const systemPromptFile = urlJoin(process.cwd(), 'work', path, 'users', user.userSystemId, 'systemPrompt.txt');
|
const systemPromptFile = urlJoin(process.cwd(), 'work', packagePath, 'users', user.userSystemId, 'systemPrompt.txt');
|
||||||
fs.writeFileSync(systemPromptFile, text);
|
fs.writeFileSync(systemPromptFile, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1535,7 +1535,7 @@ export class SystemKeywords {
|
||||||
const { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
const { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
let path = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
let packagePath = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
||||||
|
|
||||||
// Extracts each part of path to call create folder to each
|
// Extracts each part of path to call create folder to each
|
||||||
// one of them.
|
// one of them.
|
||||||
|
@ -1556,18 +1556,18 @@ export class SystemKeywords {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
lastFolder = await client.api(`${baseUrl}/drive/root:/${path}:/children`).post(body);
|
lastFolder = await client.api(`${baseUrl}/drive/root:/${packagePath}:/children`).post(body);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== 'nameAlreadyExists') {
|
if (error.code !== 'nameAlreadyExists') {
|
||||||
throw error;
|
throw error;
|
||||||
} else {
|
} else {
|
||||||
lastFolder = await client.api(`${baseUrl}/drive/root:/${urlJoin(path, item)}`).get();
|
lastFolder = await client.api(`${baseUrl}/drive/root:/${urlJoin(packagePath, item)}`).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increments path to the next child be created.
|
// Increments path to the next child be created.
|
||||||
|
|
||||||
path = urlJoin(path, item);
|
packagePath = urlJoin(packagePath, item);
|
||||||
});
|
});
|
||||||
return lastFolder;
|
return lastFolder;
|
||||||
}
|
}
|
||||||
|
@ -1584,8 +1584,8 @@ export class SystemKeywords {
|
||||||
public async shareFolder({ pid, folder, email, message }) {
|
public async shareFolder({ pid, folder, email, message }) {
|
||||||
const { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
const { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
||||||
const root = urlJoin(path, folder);
|
const root = urlJoin(packagePath, folder);
|
||||||
|
|
||||||
const src = await client.api(`${baseUrl}/drive/root:/${root}`).get();
|
const src = await client.api(`${baseUrl}/drive/root:/${root}`).get();
|
||||||
|
|
||||||
|
@ -1602,11 +1602,11 @@ export class SystemKeywords {
|
||||||
await client.api(`https://graph.microsoft.com/v1.0/drives/${driveId}/items/${itemId}/invite`).post(body);
|
await client.api(`https://graph.microsoft.com/v1.0/drives/${driveId}/items/${itemId}/invite`).post(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async internalCreateDocument(min, path, content) {
|
public async internalCreateDocument(min, filePath, content) {
|
||||||
GBLogEx.info(min, `CREATE DOCUMENT '${path}...'`);
|
GBLogEx.info(min, `CREATE DOCUMENT '${filePath}...'`);
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const gbaiName = GBUtil.getGBAIPath(min.botId);
|
const gbaiName = GBUtil.getGBAIPath(min.botId);
|
||||||
const tmpDocx = urlJoin(gbaiName, path);
|
const tmpDocx = urlJoin(gbaiName, filePath);
|
||||||
|
|
||||||
// Templates a blank {content} tag inside the blank.docx.
|
// Templates a blank {content} tag inside the blank.docx.
|
||||||
|
|
||||||
|
@ -1624,9 +1624,9 @@ export class SystemKeywords {
|
||||||
await client.api(`${baseUrl}/drive/root:/${tmpDocx}:/content`).put(buf);
|
await client.api(`${baseUrl}/drive/root:/${tmpDocx}:/content`).put(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createDocument({ pid, path, content }) {
|
public async createDocument({ pid, packagePath, content }) {
|
||||||
const { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
const { min, user, params } = await DialogKeywords.getProcessInfo(pid);
|
||||||
this.internalCreateDocument(min, path, content);
|
this.internalCreateDocument(min, packagePath, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1710,10 +1710,10 @@ export class SystemKeywords {
|
||||||
dest = dest.replace(/\\/gi, '/');
|
dest = dest.replace(/\\/gi, '/');
|
||||||
|
|
||||||
// Determines full path at source and destination.
|
// Determines full path at source and destination.
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
||||||
const root = path;
|
const root = packagePath;
|
||||||
const srcPath = urlJoin(root, src);
|
const srcPath = urlJoin(root, src);
|
||||||
const dstPath = urlJoin(path, dest);
|
const dstPath = urlJoin(packagePath, dest);
|
||||||
|
|
||||||
// Checks if the destination contains subfolders that
|
// Checks if the destination contains subfolders that
|
||||||
// need to be created.
|
// need to be created.
|
||||||
|
@ -2239,12 +2239,12 @@ export class SystemKeywords {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const botId = min.instance.botId;
|
const botId = min.instance.botId;
|
||||||
const path = GBUtil.getGBAIPath(botId, 'gbdata');
|
const packagePath = GBUtil.getGBAIPath(botId, 'gbdata');
|
||||||
|
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
|
|
||||||
let document;
|
let document;
|
||||||
document = await this.internalGetDocument(client, baseUrl, path, file);
|
document = await this.internalGetDocument(client, baseUrl, packagePath, file);
|
||||||
|
|
||||||
// Creates workbook session that will be discarded.
|
// Creates workbook session that will be discarded.
|
||||||
|
|
||||||
|
@ -2586,7 +2586,7 @@ export class SystemKeywords {
|
||||||
GBLogEx.info(min, `Auto saving '${file.filename}' (SAVE file).`);
|
GBLogEx.info(min, `Auto saving '${file.filename}' (SAVE file).`);
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
|
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
||||||
const fileName = file.url ? file.url : file.name;
|
const fileName = file.url ? file.url : file.name;
|
||||||
const contentType = mime.lookup(fileName);
|
const contentType = mime.lookup(fileName);
|
||||||
const ext = path.extname(fileName).substring(1);
|
const ext = path.extname(fileName).substring(1);
|
||||||
|
@ -2599,7 +2599,7 @@ export class SystemKeywords {
|
||||||
|
|
||||||
const today = [day, month, year].join('-');
|
const today = [day, month, year].join('-');
|
||||||
const result = await client
|
const result = await client
|
||||||
.api(`${baseUrl}/drive/root:/${path}/${today}/${kind.category}/${fileName}:/content`)
|
.api(`${baseUrl}/drive/root:/${packagePath}/${today}/${kind.category}/${fileName}:/content`)
|
||||||
.put(file.data);
|
.put(file.data);
|
||||||
|
|
||||||
return { contentType, ext, kind, category: kind['category'] };
|
return { contentType, ext, kind, category: kind['category'] };
|
||||||
|
@ -2676,9 +2676,9 @@ export class SystemKeywords {
|
||||||
|
|
||||||
// Retrieves all files in remote folder.
|
// Retrieves all files in remote folder.
|
||||||
|
|
||||||
let path = GBUtil.getGBAIPath(min.botId);
|
let packagePath = GBUtil.getGBAIPath(min.botId);
|
||||||
path = urlJoin(path, remotePath);
|
packagePath = urlJoin(packagePath, remotePath);
|
||||||
let url = `${baseUrl}/drive/root:/${path}:/children`;
|
let url = `${baseUrl}/drive/root:/${packagePath}:/children`;
|
||||||
|
|
||||||
const res = await client.api(url).get();
|
const res = await client.api(url).get();
|
||||||
const documents = res.value;
|
const documents = res.value;
|
||||||
|
@ -2725,16 +2725,16 @@ export class SystemKeywords {
|
||||||
if (GBConfigService.get('STORAGE_NAME')) {
|
if (GBConfigService.get('STORAGE_NAME')) {
|
||||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
const gbaiName = GBUtil.getGBAIPath(min.botId);
|
const gbaiName = GBUtil.getGBAIPath(min.botId);
|
||||||
let path = '/' + urlJoin(gbaiName, `${min.botId}.gbdrive`);
|
let packagePath = '/' + urlJoin(gbaiName, `${min.botId}.gbdrive`);
|
||||||
let template = await this.internalGetDocument(client, baseUrl, path, file);
|
let template = await this.internalGetDocument(client, baseUrl, packagePath, file);
|
||||||
let url = template['@microsoft.graph.downloadUrl'];
|
let url = template['@microsoft.graph.downloadUrl'];
|
||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
||||||
let buf: any = Buffer.from(await res.arrayBuffer());
|
let buf: any = Buffer.from(await res.arrayBuffer());
|
||||||
data = new Uint8Array(buf);
|
data = new Uint8Array(buf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let path = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
let packagePath = GBUtil.getGBAIPath(min.botId, `gbdrive`);
|
||||||
let filePath = path.join(GBConfigService.get('STORAGE_LIBRARY'), path, file);
|
let filePath = path.join(GBConfigService.get('STORAGE_LIBRARY'), packagePath, file);
|
||||||
data = fs.readFileSync(filePath, 'utf8');
|
data = fs.readFileSync(filePath, 'utf8');
|
||||||
data = new Uint8Array(Buffer.from(data, 'utf8'));
|
data = new Uint8Array(Buffer.from(data, 'utf8'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,9 +680,9 @@ ENDPOINT_UPDATE=true
|
||||||
|
|
||||||
const maxLines = 512;
|
const maxLines = 512;
|
||||||
const file = 'Config.xlsx';
|
const file = 'Config.xlsx';
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbot`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbot`);
|
||||||
|
|
||||||
let document = await new SystemKeywords().internalGetDocument(client, baseUrl, path, file);
|
let document = await new SystemKeywords().internalGetDocument(client, baseUrl, packagePath, file);
|
||||||
|
|
||||||
// Creates book session that will be discarded.
|
// Creates book session that will be discarded.
|
||||||
|
|
||||||
|
@ -716,8 +716,8 @@ ENDPOINT_UPDATE=true
|
||||||
)
|
)
|
||||||
.patch(body);
|
.patch(body);
|
||||||
} else {
|
} else {
|
||||||
let path = GBUtil.getGBAIPath(min.botId, `gbot`);
|
let packagePath = GBUtil.getGBAIPath(min.botId, `gbot`);
|
||||||
const config = path.join(GBConfigService.get('STORAGE_LIBRARY'), path, 'config.csv');
|
const config = path.join(GBConfigService.get('STORAGE_LIBRARY'), packagePath, 'config.csv');
|
||||||
|
|
||||||
const db = await csvdb(config, ['name', 'value'], ',');
|
const db = await csvdb(config, ['name', 'value'], ',');
|
||||||
if (await db.get({ name: name })) {
|
if (await db.get({ name: name })) {
|
||||||
|
|
|
@ -56,7 +56,6 @@ import { GBImporter } from './GBImporterService.js';
|
||||||
import { TeamsService } from '../../teams.gblib/services/TeamsService.js';
|
import { TeamsService } from '../../teams.gblib/services/TeamsService.js';
|
||||||
import MicrosoftGraph from '@microsoft/microsoft-graph-client';
|
import MicrosoftGraph from '@microsoft/microsoft-graph-client';
|
||||||
import { GBLogEx } from './GBLogEx.js';
|
import { GBLogEx } from './GBLogEx.js';
|
||||||
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
|
|
||||||
import { GBUtil } from '../../../src/util.js';
|
import { GBUtil } from '../../../src/util.js';
|
||||||
import { HNSWLib } from '@langchain/community/vectorstores/hnswlib';
|
import { HNSWLib } from '@langchain/community/vectorstores/hnswlib';
|
||||||
import { OpenAIEmbeddings } from '@langchain/openai';
|
import { OpenAIEmbeddings } from '@langchain/openai';
|
||||||
|
@ -148,7 +147,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
const gbappPackages: string[] = [];
|
const gbappPackages: string[] = [];
|
||||||
const generalPackages: string[] = [];
|
const generalPackages: string[] = [];
|
||||||
|
|
||||||
async function scanPackageDirectory(path) {
|
async function scanPackageDirectory(directory) {
|
||||||
// Gets all directories.
|
// Gets all directories.
|
||||||
|
|
||||||
const isDirectory = source => fs.lstatSync(source).isDirectory();
|
const isDirectory = source => fs.lstatSync(source).isDirectory();
|
||||||
|
@ -156,7 +155,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
fs.readdirSync(source)
|
fs.readdirSync(source)
|
||||||
.map(name => path.join(source, name))
|
.map(name => path.join(source, name))
|
||||||
.filter(isDirectory);
|
.filter(isDirectory);
|
||||||
const dirs = getDirectories(path);
|
const dirs = getDirectories(directory);
|
||||||
await CollectionUtil.asyncForEach(dirs, async element => {
|
await CollectionUtil.asyncForEach(dirs, async element => {
|
||||||
// For each folder, checks its extensions looking for valid packages.
|
// For each folder, checks its extensions looking for valid packages.
|
||||||
|
|
||||||
|
@ -503,7 +502,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
}
|
}
|
||||||
|
|
||||||
await CollectionUtil.asyncForEach(parts, async item => {
|
await CollectionUtil.asyncForEach(parts, async item => {
|
||||||
pathBase = path.join(pathBase, item);
|
pathBase = packagePath.join(pathBase, item);
|
||||||
if (!fs.existsSync(pathBase)) {
|
if (!fs.existsSync(pathBase)) {
|
||||||
fs.mkdirSync(pathBase);
|
fs.mkdirSync(pathBase);
|
||||||
}
|
}
|
||||||
|
@ -511,9 +510,9 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
// Retrieves all files in remote folder.
|
// Retrieves all files in remote folder.
|
||||||
|
|
||||||
let path = GBUtil.getGBAIPath(min.botId);
|
let packagePath = GBUtil.getGBAIPath(min.botId);
|
||||||
path = urlJoin(path, remotePath);
|
packagePath = urlJoin(packagePath, remotePath);
|
||||||
let url = `${baseUrl}/drive/root:/${path}:/children`;
|
let url = `${baseUrl}/drive/root:/${packagePath}:/children`;
|
||||||
|
|
||||||
GBLogEx.info(min, `Download URL: ${url}`);
|
GBLogEx.info(min, `Download URL: ${url}`);
|
||||||
|
|
||||||
|
@ -527,7 +526,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
// Download files or navigate to directory to recurse.
|
// Download files or navigate to directory to recurse.
|
||||||
|
|
||||||
await CollectionUtil.asyncForEach(documents, async item => {
|
await CollectionUtil.asyncForEach(documents, async item => {
|
||||||
const itemPath = path.join(localPath, remotePath, item.name);
|
const itemPath = packagePath.join(localPath, remotePath, item.name);
|
||||||
|
|
||||||
if (item.folder) {
|
if (item.folder) {
|
||||||
if (!fs.existsSync(itemPath)) {
|
if (!fs.existsSync(itemPath)) {
|
||||||
|
@ -658,16 +657,16 @@ export class GBDeployer implements IGBDeployer {
|
||||||
con['storagePort'] = min.core.getParam<string>(min.instance, `${connectionName} Port`, null);
|
con['storagePort'] = min.core.getParam<string>(min.instance, `${connectionName} Port`, null);
|
||||||
con['storagePassword'] = min.core.getParam<string>(min.instance, `${connectionName} Password`, null);
|
con['storagePassword'] = min.core.getParam<string>(min.instance, `${connectionName} Password`, null);
|
||||||
} else if (file) {
|
} else if (file) {
|
||||||
const path = GBUtil.getGBAIPath(min.botId, 'gbdata');
|
const packagePath = GBUtil.getGBAIPath(min.botId, 'gbdata');
|
||||||
con['storageFile'] = path.join(GBConfigService.get('STORAGE_LIBRARY'), path, file);
|
con['storageFile'] = path.join(GBConfigService.get('STORAGE_LIBRARY'), packagePath, file);
|
||||||
} else {
|
} else {
|
||||||
GBLogEx.debug(min, `No storage information found for ${connectionName}, missing storage name or file.`);
|
GBLogEx.debug(min, `No storage information found for ${connectionName}, missing storage name or file.`);
|
||||||
}
|
}
|
||||||
connections.push(con);
|
connections.push(con);
|
||||||
});
|
});
|
||||||
|
|
||||||
const path = GBUtil.getGBAIPath(min.botId, null);
|
const packagePath = GBUtil.getGBAIPath(min.botId, null);
|
||||||
const localFolder = path.join('work', path, 'connections.json');
|
const localFolder = path.join('work', packagePath, 'connections.json');
|
||||||
fs.writeFileSync(localFolder, JSON.stringify(connections), { encoding: null });
|
fs.writeFileSync(localFolder, JSON.stringify(connections), { encoding: null });
|
||||||
|
|
||||||
// Updates instance object.
|
// Updates instance object.
|
||||||
|
@ -726,8 +725,8 @@ export class GBDeployer implements IGBDeployer {
|
||||||
* Removes the package local files from cache.
|
* Removes the package local files from cache.
|
||||||
*/
|
*/
|
||||||
public async cleanupPackage(instance: IGBInstance, packageName: string) {
|
public async cleanupPackage(instance: IGBInstance, packageName: string) {
|
||||||
const path = GBUtil.getGBAIPath(instance.botId, null, packageName);
|
const packagePath = GBUtil.getGBAIPath(instance.botId, null, packageName);
|
||||||
const localFolder = path.join('work', path);
|
const localFolder = path.join('work', packagePath);
|
||||||
rimraf.sync(localFolder);
|
rimraf.sync(localFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1095,7 +1095,7 @@ export class GBMinService {
|
||||||
ps: null,
|
ps: null,
|
||||||
qs: null
|
qs: null
|
||||||
});
|
});
|
||||||
const path = GBUtil.getGBAIPath(min.botId);
|
const packagePath = GBUtil.getGBAIPath(min.botId);
|
||||||
const folder = `work/${path}/cache`;
|
const folder = `work/${path}/cache`;
|
||||||
const filename = `${GBAdminService.generateUuid()}.png`;
|
const filename = `${GBAdminService.generateUuid()}.png`;
|
||||||
|
|
||||||
|
@ -1271,8 +1271,8 @@ export class GBMinService {
|
||||||
private static async downloadAttachmentAndWrite(attachment) {
|
private static async downloadAttachmentAndWrite(attachment) {
|
||||||
const url = attachment.contentUrl;
|
const url = attachment.contentUrl;
|
||||||
const localFolder = 'work';
|
const localFolder = 'work';
|
||||||
const path = GBUtil.getGBAIPath(this['min'].botId);
|
const packagePath = GBUtil.getGBAIPath(this['min'].botId);
|
||||||
const localFileName = path.join(localFolder, path, 'uploads', attachment.name);
|
const localFileName = path.join(localFolder, packagePath, 'uploads', attachment.name);
|
||||||
|
|
||||||
let buffer;
|
let buffer;
|
||||||
if (url.startsWith('data:')) {
|
if (url.startsWith('data:')) {
|
||||||
|
|
|
@ -303,29 +303,29 @@ export class GBSSR {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let path = GBUtil.getGBAIPath(botId, `gbui`);
|
let packagePath = GBUtil.getGBAIPath(botId, `gbui`);
|
||||||
|
|
||||||
// Checks if the bot has an .gbui published or use default.gbui.
|
// Checks if the bot has an .gbui published or use default.gbui.
|
||||||
|
|
||||||
if (!fs.existsSync(path)) {
|
if (!fs.existsSync(packagePath)) {
|
||||||
path = GBUtil.getGBAIPath(minBoot.botId, `gbui`);
|
packagePath = GBUtil.getGBAIPath(minBoot.botId, `gbui`);
|
||||||
}
|
}
|
||||||
let parts = req.url.replace(`/${botId}`, '').split('?');
|
let parts = req.url.replace(`/${botId}`, '').split('?');
|
||||||
let url = parts[0];
|
let url = parts[0];
|
||||||
|
|
||||||
if (min && req.originalUrl && prerender && exclude && fs.existsSync(path)) {
|
if (min && req.originalUrl && prerender && exclude && fs.existsSync(packagePath)) {
|
||||||
|
|
||||||
// Reads from static HTML when a bot is crawling.
|
// Reads from static HTML when a bot is crawling.
|
||||||
|
|
||||||
path = path.join(process.env.PWD, 'work', path, 'index.html');
|
packagePath = path.join(process.env.PWD, 'work', packagePath, 'index.html');
|
||||||
const html = fs.readFileSync(path, 'utf8');
|
const html = fs.readFileSync(packagePath, 'utf8');
|
||||||
res.status(200).send(html);
|
res.status(200).send(html);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Servers default.gbui web application.
|
// Servers default.gbui web application.
|
||||||
|
|
||||||
path = path.join(
|
packagePath = path.join(
|
||||||
process.env.PWD,
|
process.env.PWD,
|
||||||
GBDeployer.deployFolder,
|
GBDeployer.deployFolder,
|
||||||
GBMinService.uiPackage,
|
GBMinService.uiPackage,
|
||||||
|
@ -333,14 +333,14 @@ export class GBSSR {
|
||||||
url === '/' || url === '' ? `index.html` : url
|
url === '/' || url === '' ? `index.html` : url
|
||||||
);
|
);
|
||||||
if (GBServer.globals.wwwroot && url === '/') {
|
if (GBServer.globals.wwwroot && url === '/') {
|
||||||
path = GBServer.globals.wwwroot + "/index.html"; // TODO.
|
packagePath = GBServer.globals.wwwroot + "/index.html"; // TODO.
|
||||||
}
|
}
|
||||||
if (!min && !url.startsWith("/static") && GBServer.globals.wwwroot) {
|
if (!min && !url.startsWith("/static") && GBServer.globals.wwwroot) {
|
||||||
path = path.join(GBServer.globals.wwwroot, url);
|
packagePath = packagePath.join(GBServer.globals.wwwroot, url);
|
||||||
}
|
}
|
||||||
if (fs.existsSync(path)) {
|
if (fs.existsSync(packagePath)) {
|
||||||
if (min) {
|
if (min) {
|
||||||
let html = fs.readFileSync(path, 'utf8');
|
let html = fs.readFileSync(packagePath, 'utf8');
|
||||||
html = html.replace(/\{p\}/gi, min.botId);
|
html = html.replace(/\{p\}/gi, min.botId);
|
||||||
html = html.replace(/\{botId\}/gi, min.botId);
|
html = html.replace(/\{botId\}/gi, min.botId);
|
||||||
html = html.replace(/\{theme\}/gi, min.instance.theme ? min.instance.theme :
|
html = html.replace(/\{theme\}/gi, min.instance.theme ? min.instance.theme :
|
||||||
|
@ -348,7 +348,7 @@ export class GBSSR {
|
||||||
html = html.replace(/\{title\}/gi, min.instance.title);
|
html = html.replace(/\{title\}/gi, min.instance.title);
|
||||||
res.send(html).end();
|
res.send(html).end();
|
||||||
} else {
|
} else {
|
||||||
res.sendFile(path);
|
res.sendFile(packagePath);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -246,8 +246,8 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
for (const key in results.sources) {
|
for (const key in results.sources) {
|
||||||
const source = results.sources[key];
|
const source = results.sources[key];
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
||||||
let url = urlJoin('kb', path, 'docs', path.basename(source.file));
|
let url = urlJoin('kb', packagePath, 'docs', path.basename(source.file));
|
||||||
url = `${url}#page=${source.page}&toolbar=0&messages=0&statusbar=0&navpanes=0`;
|
url = `${url}#page=${source.page}&toolbar=0&messages=0&statusbar=0&navpanes=0`;
|
||||||
urls.push({ url: url });
|
urls.push({ url: url });
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,8 +164,8 @@ export class KBService implements IGBKBService {
|
||||||
|
|
||||||
// Extracts botId from URL.
|
// Extracts botId from URL.
|
||||||
|
|
||||||
let path = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/gi;
|
let packagePath = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/gi;
|
||||||
const botId = url.replace(path, ($0, $1, $2, $3) => {
|
const botId = url.replace(packagePath, ($0, $1, $2, $3) => {
|
||||||
return $3.substr($3.indexOf('/'));
|
return $3.substr($3.indexOf('/'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -555,9 +555,9 @@ export class KBService implements IGBKBService {
|
||||||
const isBasic = answer.toLowerCase().startsWith('/basic');
|
const isBasic = answer.toLowerCase().startsWith('/basic');
|
||||||
if (/TALK\s*\".*\"/gi.test(answer) || isBasic) {
|
if (/TALK\s*\".*\"/gi.test(answer) || isBasic) {
|
||||||
const code = isBasic ? answer.substr(6) : answer;
|
const code = isBasic ? answer.substr(6) : answer;
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbdialog`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbdialog`);
|
||||||
const scriptName = `tmp${GBAdminService.getRndReadableIdentifier()}.docx`;
|
const scriptName = `tmp${GBAdminService.getRndReadableIdentifier()}.docx`;
|
||||||
const localName = path.join('work', path, `${scriptName}`);
|
const localName = path.join('work', packagePath, `${scriptName}`);
|
||||||
fs.writeFileSync(localName, code, { encoding: null });
|
fs.writeFileSync(localName, code, { encoding: null });
|
||||||
answer = scriptName;
|
answer = scriptName;
|
||||||
|
|
||||||
|
@ -630,13 +630,13 @@ export class KBService implements IGBKBService {
|
||||||
answer.endsWith('.xls') ||
|
answer.endsWith('.xls') ||
|
||||||
answer.endsWith('.xlsx')
|
answer.endsWith('.xlsx')
|
||||||
) {
|
) {
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
||||||
const doc = urlJoin(GBServer.globals.publicAddress, 'kb', path, 'assets', answer);
|
const doc = urlJoin(GBServer.globals.publicAddress, 'kb', packagePath, 'assets', answer);
|
||||||
const url = `http://view.officeapps.live.com/op/view.aspx?src=${doc}`;
|
const url = `http://view.officeapps.live.com/op/view.aspx?src=${doc}`;
|
||||||
await this.playUrl(min, min.conversationalService, step, url, channel);
|
await this.playUrl(min, min.conversationalService, step, url, channel);
|
||||||
} else if (answer.endsWith('.pdf')) {
|
} else if (answer.endsWith('.pdf')) {
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
||||||
const url = urlJoin('kb', path, 'assets', answer);
|
const url = urlJoin('kb', packagePath, 'assets', answer);
|
||||||
await this.playUrl(min, min.conversationalService, step, url, channel);
|
await this.playUrl(min, min.conversationalService, step, url, channel);
|
||||||
} else if (answer.format === '.md') {
|
} else if (answer.format === '.md') {
|
||||||
await min.conversationalService['playMarkdown'](min, answer, channel, step, GBMinService.userMobile(step));
|
await min.conversationalService['playMarkdown'](min, answer, channel, step, GBMinService.userMobile(step));
|
||||||
|
@ -737,8 +737,8 @@ export class KBService implements IGBKBService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (file !== null && file.name.endsWith('.docx')) {
|
} else if (file !== null && file.name.endsWith('.docx')) {
|
||||||
let path = GBUtil.getGBAIPath(instance.botId, `gbkb`);
|
let packagePath = GBUtil.getGBAIPath(instance.botId, `gbkb`);
|
||||||
const localName = path.join('work', path, 'articles', file.name);
|
const localName = path.join('work', packagePath, 'articles', file.name);
|
||||||
let loader = new DocxLoader(localName);
|
let loader = new DocxLoader(localName);
|
||||||
let doc = await loader.load();
|
let doc = await loader.load();
|
||||||
let content = doc[0].pageContent;
|
let content = doc[0].pageContent;
|
||||||
|
@ -758,8 +758,8 @@ export class KBService implements IGBKBService {
|
||||||
|
|
||||||
data.answers.push(answer);
|
data.answers.push(answer);
|
||||||
} else if (file !== null && file.name.endsWith('.toc.docx')) {
|
} else if (file !== null && file.name.endsWith('.toc.docx')) {
|
||||||
const path = GBUtil.getGBAIPath(instance.botId, `gbkb`);
|
const packagePath = GBUtil.getGBAIPath(instance.botId, `gbkb`);
|
||||||
const localName = path.join('work', path, 'articles', file.name);
|
const localName = path.join('work', packagePath, 'articles', file.name);
|
||||||
const buffer = fs.readFileSync(localName, { encoding: null });
|
const buffer = fs.readFileSync(localName, { encoding: null });
|
||||||
var options = {
|
var options = {
|
||||||
buffer: buffer,
|
buffer: buffer,
|
||||||
|
@ -885,8 +885,8 @@ export class KBService implements IGBKBService {
|
||||||
await GBLogEx.info(min, `Processing URL: ${url}.`);
|
await GBLogEx.info(min, `Processing URL: ${url}.`);
|
||||||
visited.add(url);
|
visited.add(url);
|
||||||
|
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbot`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbot`);
|
||||||
const directoryPath = path.join(process.env.PWD, 'work', path, 'Website');
|
const directoryPath = path.join(process.env.PWD, 'work', packagePath, 'Website');
|
||||||
const filename = await GBUtil.savePage(url, page, directoryPath);
|
const filename = await GBUtil.savePage(url, page, directoryPath);
|
||||||
|
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
|
@ -1023,8 +1023,8 @@ export class KBService implements IGBKBService {
|
||||||
|
|
||||||
website.endsWith('/') ? website.substring(0, website.length - 1) : website;
|
website.endsWith('/') ? website.substring(0, website.length - 1) : website;
|
||||||
|
|
||||||
let path = GBUtil.getGBAIPath(min.botId, `gbot`);
|
let packagePath = GBUtil.getGBAIPath(min.botId, `gbot`);
|
||||||
const directoryPath = path.join(process.env.PWD, 'work', path, 'Website');
|
const directoryPath = path.join(process.env.PWD, 'work', packagePath, 'Website');
|
||||||
fs.rmSync(directoryPath, { recursive: true, force: true });
|
fs.rmSync(directoryPath, { recursive: true, force: true });
|
||||||
|
|
||||||
let browser = await puppeteer.launch({ headless: false });
|
let browser = await puppeteer.launch({ headless: false });
|
||||||
|
@ -1032,7 +1032,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 = GBUtil.getGBAIPath(min.botId);
|
packagePath = GBUtil.getGBAIPath(min.botId);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -1040,7 +1040,7 @@ export class KBService implements IGBKBService {
|
||||||
try {
|
try {
|
||||||
const logoBinary = await page.goto(logo);
|
const logoBinary = await page.goto(logo);
|
||||||
const buffer = await logoBinary.buffer();
|
const buffer = await logoBinary.buffer();
|
||||||
const logoFilename = path.basename(logo);
|
const logoFilename = packagePath.basename(logo);
|
||||||
// TODO: sharp(buffer)
|
// TODO: sharp(buffer)
|
||||||
// .resize({
|
// .resize({
|
||||||
// width: 48,
|
// width: 48,
|
||||||
|
@ -1396,10 +1396,10 @@ export class KBService implements IGBKBService {
|
||||||
if (channel === 'whatsapp') {
|
if (channel === 'whatsapp') {
|
||||||
await min.conversationalService.sendFile(min, step, null, answer.content, '');
|
await min.conversationalService.sendFile(min, step, null, answer.content, '');
|
||||||
} else {
|
} else {
|
||||||
const path = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
const packagePath = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
||||||
await conversationalService.sendEvent(min, step, 'play', {
|
await conversationalService.sendEvent(min, step, 'play', {
|
||||||
playerType: 'video',
|
playerType: 'video',
|
||||||
data: urlJoin(path, 'videos', answer.content)
|
data: urlJoin(packagePath, 'videos', answer.content)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,6 +568,7 @@ export class ChatServices {
|
||||||
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQL. You can order the results to return the most informative data in the database.
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQL. You can order the results to return the most informative data in the database.
|
||||||
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
|
||||||
Pay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.
|
Pay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.
|
||||||
|
Attention not to generate ambiguous column name, qualifing tables on joins.
|
||||||
|
|
||||||
VERY IMPORTANT: Return just the generated SQL command as plain text with no Markdown or formmating.
|
VERY IMPORTANT: Return just the generated SQL command as plain text with no Markdown or formmating.
|
||||||
------------
|
------------
|
||||||
|
@ -708,8 +709,8 @@ export class ChatServices {
|
||||||
|
|
||||||
// Adds .gbdialog as functions if any to LLM Functions.
|
// Adds .gbdialog as functions if any to LLM Functions.
|
||||||
await CollectionUtil.asyncForEach(Object.keys(min.scriptMap), async script => {
|
await CollectionUtil.asyncForEach(Object.keys(min.scriptMap), async script => {
|
||||||
const path = GBUtil.getGBAIPath(min.botId, 'gbdialog', null);
|
const packagePath = GBUtil.getGBAIPath(min.botId, 'gbdialog', null);
|
||||||
const jsonFile = path.join('work', path, `${script}.json`);
|
const jsonFile = path.join('work', packagePath, `${script}.json`);
|
||||||
|
|
||||||
if (fs.existsSync(jsonFile) && script.toLowerCase() !== 'start.vbs') {
|
if (fs.existsSync(jsonFile) && script.toLowerCase() !== 'start.vbs') {
|
||||||
const funcJSON = JSON.parse(fs.readFileSync(jsonFile, 'utf8'));
|
const funcJSON = JSON.parse(fs.readFileSync(jsonFile, 'utf8'));
|
||||||
|
|
|
@ -112,7 +112,7 @@ export class Package implements IGBPackage {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async getTasksMarkdown(path, file) {
|
public async getTasksMarkdown(packagePath, file) {
|
||||||
|
|
||||||
let token =
|
let token =
|
||||||
await this.adminService.acquireElevatedToken(this.instanceId);
|
await this.adminService.acquireElevatedToken(this.instanceId);
|
||||||
|
@ -126,7 +126,7 @@ export class Package implements IGBPackage {
|
||||||
let libraryId = process.env.STORAGE_LIBRARY;
|
let libraryId = process.env.STORAGE_LIBRARY;
|
||||||
|
|
||||||
let res = await client.api(
|
let res = await client.api(
|
||||||
`https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/root:${path}:/children`)
|
`https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}/drive/root:${packagePath}:/children`)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
let document = res.value.filter(m => {
|
let document = res.value.filter(m => {
|
||||||
|
|
|
@ -139,7 +139,7 @@ export class GBOService {
|
||||||
done(null, token);
|
done(null, token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const path = `/`;
|
const packagePath = `/`;
|
||||||
let res = await client.api(
|
let res = await client.api(
|
||||||
`https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${templateLibraryId}/drive/root/children`)
|
`https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${templateLibraryId}/drive/root/children`)
|
||||||
.get();
|
.get();
|
||||||
|
|
|
@ -763,14 +763,14 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
// Set folder based on media type
|
// Set folder based on media type
|
||||||
let folder = mediaType === 'video' ? 'videos' : 'images';
|
let folder = mediaType === 'video' ? 'videos' : 'images';
|
||||||
let path = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
let packagePath = GBUtil.getGBAIPath(min.botId, `gbkb`);
|
||||||
path = path.join(process.env.PWD, 'work', path, folder, mediaFile);
|
packagePath = path.join(process.env.PWD, 'work', packagePath, folder, mediaFile);
|
||||||
|
|
||||||
text = text.substring(mediaFile.length + 1).trim();
|
text = text.substring(mediaFile.length + 1).trim();
|
||||||
text = text.replace(/\n/g, '\\n');
|
text = text.replace(/\n/g, '\\n');
|
||||||
|
|
||||||
// Upload the media file based on media type
|
// Upload the media file based on media type
|
||||||
const handleMedia = await min.whatsAppDirectLine.uploadLargeFile(min, path);
|
const handleMedia = await min.whatsAppDirectLine.uploadLargeFile(min, packagePath);
|
||||||
|
|
||||||
let data: any = {
|
let data: any = {
|
||||||
name: template,
|
name: template,
|
||||||
|
|
Loading…
Add table
Reference in a new issue