Skip to content

Commit

Permalink
fix(kb.gbapp): Auto Logo generation fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Nov 26, 2024
1 parent 9c2c1bc commit 878f102
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"instagram-private-api": "1.46.1",
"iso-639-1": "3.1.3",
"isomorphic-fetch": "3.0.0",
"jimp": "^1.6.0",
"jimp": "1.6.0",
"js-md5": "0.8.3",
"json-schema-to-zod": "2.4.0",
"jsqr": "^1.4.0",
Expand Down
30 changes: 13 additions & 17 deletions packages/kb.gbapp/services/KBService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import getColors from 'get-image-colors';
import { Document } from 'langchain/document';
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
import puppeteer, { Page } from 'puppeteer';

import {Jimp} from 'jimp';
import {
GBDialogStep,
GBLog,
Expand Down Expand Up @@ -1065,22 +1065,18 @@ export class KBService implements IGBKBService {
const baseUrl = page.url().split('/').slice(0, 3).join('/');
logo = logo.startsWith('https') ? logo : urlJoin(baseUrl, logo);

try {
const logoBinary = await page.goto(logo);
const buffer = await logoBinary.buffer();
const logoFilename = path.basename(logo);
// 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);
}
const logoBinary = await page.goto(logo);
const buffer = await logoBinary.buffer();
const logoFilename = path.basename(logo);

// Replace sharp with jimp
const image = await Jimp.read(buffer);
await image.scaleToFit({w:48, h:48});
packagePath = path.join(process.env.PWD, 'work', packagePath);

const logoPath = path.join(packagePath, 'cache', logoFilename);
await (image as any).write(logoPath);
await min.core['setConfig'](min, 'Logo', logoFilename);
}

// Extract dominant colors from the screenshot
Expand Down
15 changes: 15 additions & 0 deletions templates/talk-to-data.gbai/talk-to-data.gbdialog/start.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BEGIN TALK

General Bots Talk To Data

Examples:
- Show me top products in a rainbow collored pie chart.
- Sales across years.


Let’s get started!
END TALK

BEGIN SYSTEM PROMPT

END SYSTEM PROMPT

0 comments on commit 878f102

Please sign in to comment.