Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
oerlabshenrique committed Aug 23, 2024
2 parents d319782 + 26f5fce commit 76cb157
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 56 deletions.
5 changes: 3 additions & 2 deletions boot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Path from 'path';
import { exec } from 'child_process';
import pjson from './package.json' assert { type: 'json' };


// Displays version of Node JS being used at runtime and others attributes.

process.stdout.write(`General Bots. BotServer@${pjson.version}, botlib@${pjson.dependencies.botlib}, node@${process.version.replace('v', '')}, ${process.platform} ${process.arch} `);
Expand All @@ -15,8 +16,8 @@ var __dirname = process.env.PWD || process.cwd();
try {
var run = () => {

import('./dist/src/app.js').then((gb)=> {
gb.GBServer.run()
import('./dist/src/webapp.js').then((gb)=> {
gb.GBUI.run()
});
};
var processDist = () => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@
"cli-progress": "3.12.0",
"cli-spinner": "0.2.10",
"core-js": "3.37.1",
"csv-database": "^0.9.2",
"data-forge": "1.10.2",
"date-diff": "1.0.2",
"docximager": "0.0.4",
"docxtemplater": "3.47.4",
"dotenv-extended": "2.9.0",
"electron": "32.0.1",
"exceljs": "4.4.0",
"express": "4.19.2",
"express-remove-route": "1.0.0",
Expand Down Expand Up @@ -198,7 +200,6 @@
"sequelize": "6.28.2",
"sequelize-cli": "6.6.0",
"sequelize-typescript": "2.1.5",
"sharp": "0.33.4",
"simple-git": "3.24.0",
"speakingurl": "14.0.1",
"sqlite3": "5.1.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/basic.gblib/services/DebuggerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { GBServer } from '../../../src/app.js';
import Fs from 'fs';
import SwaggerClient from 'swagger-client';
import { spawn } from 'child_process';
import { CodeServices } from '../../gpt.gblib/services/CodeServices.js';
import { CodeServices } from '../../llm.gblib/services/CodeServices.js';
import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js';
import { GBUtil } from '../../../src/util.js';

Expand Down
17 changes: 1 addition & 16 deletions packages/basic.gblib/services/ImageProcessingServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
import urlJoin from 'url-join';
import { GBServer } from '../../../src/app.js';
import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js';
import sharp from 'sharp';

/**
* Image processing services of conversation to be called by BASIC.
Expand All @@ -55,22 +54,8 @@ export class ImageProcessingServices {
GBLogEx.info(min, `BASIC: Image Processing SHARPEN ${file}.`);

const gbfile = DialogKeywords.getFileByHandle(file);
const data = await sharp(gbfile.data)
.sharpen({
sigma: 2,
m1: 0,
m2: 3,
x1: 3,
y2: 15,
y3: 15
})
.toBuffer();

const newFile = {
filename: gbfile.filename,
data: data

};
// TODO: sharp.
return;
}

Expand Down
11 changes: 5 additions & 6 deletions packages/basic.gblib/services/SystemKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ import Docxtemplater from 'docxtemplater';
import pptxTemplaterModule from 'pptxtemplater';
import _ from 'lodash';
import { pdfToPng, PngPageOutput } from 'pdf-to-png-converter';
import sharp from 'sharp';
import ImageModule from 'open-docxtemplater-image-module';
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js';
import { WebAutomationServices } from './WebAutomationServices.js';
import { KeywordsExpressions } from './KeywordsExpressions.js';
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js';
import { ChatServices } from '../../llm.gblib/services/ChatServices.js';
import mime from 'mime-types';
import exts from '../../../extensions.json' assert { type: 'json' };
import { SecService } from '../../security.gbapp/services/SecService.js';
Expand Down Expand Up @@ -1998,11 +1997,11 @@ export class SystemKeywords {
return (orientation || 0) >= 5 ? [height, width] : [width, height];
};

const metadata = await sharp(buf).metadata();
// TODO: sharp. const metadata = await sharp(buf).metadata();
const size = getNormalSize({
width: metadata['width'],
height: metadata['height'],
orientation: metadata['orientation']
width: 400,
height: 400,
orientation: '0'
});
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(imageName));
images[index++] = { url: url, size: size, buf: buf };
Expand Down
19 changes: 9 additions & 10 deletions packages/kb.gbapp/services/KBService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import puppeteer, { Page } from 'puppeteer';
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
import { Document } from 'langchain/document';
import getColors from 'get-image-colors';
import sharp from 'sharp';

import {
GBDialogStep,
Expand Down Expand Up @@ -83,7 +82,7 @@ import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
import { GBVMService } from '../../basic.gblib/services/GBVMService.js';
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
import { GBMinService } from '../../core.gbapp/services/GBMinService.js';
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js';
import { ChatServices } from '../../llm.gblib/services/ChatServices.js';
import { GBUtil } from '../../../src/util.js';

/**
Expand Down Expand Up @@ -1070,14 +1069,14 @@ export class KBService implements IGBKBService {
const logoBinary = await page.goto(logo);
const buffer = await logoBinary.buffer();
const logoFilename = Path.basename(logo);
sharp(buffer)
.resize({
width: 48,
height: 48,
fit: 'inside', // Resize the image to fit within the specified dimensions
withoutEnlargement: true // Don't enlarge the image if its dimensions are already smaller
})
.toFile(Path.join(logoPath, logoFilename));
// TODO: sharp(buffer)
// .resize({
// width: 48,
// height: 48,
// fit: 'inside', // Resize the image to fit within the specified dimensions
// withoutEnlargement: true // Don't enlarge the image if its dimensions are already smaller
// })
// .toFile(Path.join(logoPath, logoFilename));
await min.core['setConfig'](min, 'Logo', logoFilename);
} catch (error) {
GBLogEx.debug(min, error);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { GBSSR } from '../../core.gbapp/services/GBSSR.js';
import pkg from 'whatsapp-web.js';
import fetch from 'node-fetch';
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js';
import { ChatServices } from '../../llm.gblib/services/ChatServices.js';
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
import { GBUtil } from '../../../src/util.js';
const { WAState, Client, MessageMedia } = pkg;
Expand Down
37 changes: 22 additions & 15 deletions src/webapp.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
import { GBConfigService } from "../packages/core.gbapp/services/GBConfigService";
import { app, BrowserWindow } from 'electron';
import { GBConfigService } from '../packages/core.gbapp/services/GBConfigService.js';
const {app} = (await import('electron')).default;

import path from 'path';
import url from 'url';

export function runUI() {


export function runUI() {
// Create the browser window.
const win = new BrowserWindow({ width: 800, height: 600, title: 'General Bots Studio' });
const win = null;// new BrowserWindow({ width: 800, height: 600, title: 'General Bots Studio' });

// and load the index.html of the app.
win.loadURL(
url.format({
pathname: path.join(__dirname, `http://localhost:${GBConfigService.get('PORT')}`),
protocol: 'file:',
slashes: true
})
);
import('./app.js').then(gb => {
gb.GBServer.run();
// and load the index.html of the app.
win.loadURL(
url.format({
pathname: path.join(__dirname, `http://localhost:${GBConfigService.get('PORT')}`),
protocol: 'file:',
slashes: true
})
);
});
}

app.on('ready', runUI);
export class GBUI {
static run() {
app.on('ready', runUI);
}
}
8 changes: 4 additions & 4 deletions templates/api-server.gbai/api.gbdialog/start.bas
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FOR EACH item IN data[0].itens
produto.detalhe = item.detalhe
produto.acompanhamentos = item.gruposAcompanhamento

produtos.push(produto)
produtos.push(produto)
END IF
NEXT

Expand All @@ -43,7 +43,7 @@ Segue o exemplo do JSON do Pedido, apague os itens e mande um com o pedido feito
item: {
id: 23872,
valor: 20,
nome: Caipirinha Limão
nome: Guaraná
},
itensAcompanhamento: [
{
Expand All @@ -59,7 +59,7 @@ Segue o exemplo do JSON do Pedido, apague os itens e mande um com o pedido feito
item: {
id: 25510,
valor: 12,
nome: Heineken Lata 350ml
nome: Laranja Lata 350ml
},
itensAcompanhamento: [],
quantidade: 1,
Expand All @@ -68,7 +68,7 @@ Segue o exemplo do JSON do Pedido, apague os itens e mande um com o pedido feito
],
barracaId: ${barraca},
usuarioId: ${operador},
identificadorConta: Rafael,
identificadorConta: Areia,
tipoEntregaId: 2,
camposTipoEntrega: {
Mesa: 5
Expand Down

0 comments on commit 76cb157

Please sign in to comment.