fix(kb.gbapp): Auto Logo generation fixed.
This commit is contained in:
parent
9c2c1bc204
commit
878f10245f
3 changed files with 29 additions and 18 deletions
|
@ -154,7 +154,7 @@
|
||||||
"instagram-private-api": "1.46.1",
|
"instagram-private-api": "1.46.1",
|
||||||
"iso-639-1": "3.1.3",
|
"iso-639-1": "3.1.3",
|
||||||
"isomorphic-fetch": "3.0.0",
|
"isomorphic-fetch": "3.0.0",
|
||||||
"jimp": "^1.6.0",
|
"jimp": "1.6.0",
|
||||||
"js-md5": "0.8.3",
|
"js-md5": "0.8.3",
|
||||||
"json-schema-to-zod": "2.4.0",
|
"json-schema-to-zod": "2.4.0",
|
||||||
"jsqr": "^1.4.0",
|
"jsqr": "^1.4.0",
|
||||||
|
|
|
@ -53,7 +53,7 @@ import getColors from 'get-image-colors';
|
||||||
import { Document } from 'langchain/document';
|
import { Document } from 'langchain/document';
|
||||||
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
|
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
|
||||||
import puppeteer, { Page } from 'puppeteer';
|
import puppeteer, { Page } from 'puppeteer';
|
||||||
|
import {Jimp} from 'jimp';
|
||||||
import {
|
import {
|
||||||
GBDialogStep,
|
GBDialogStep,
|
||||||
GBLog,
|
GBLog,
|
||||||
|
@ -1065,22 +1065,18 @@ export class KBService implements IGBKBService {
|
||||||
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);
|
||||||
|
|
||||||
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 = path.basename(logo);
|
|
||||||
// TODO: sharp(buffer)
|
// Replace sharp with jimp
|
||||||
// .resize({
|
const image = await Jimp.read(buffer);
|
||||||
// width: 48,
|
await image.scaleToFit({w:48, h:48});
|
||||||
// height: 48,
|
packagePath = path.join(process.env.PWD, 'work', packagePath);
|
||||||
// fit: 'inside', // Resize the image to fit within the specified dimensions
|
|
||||||
// withoutEnlargement: true // Don't enlarge the image if its dimensions are already smaller
|
const logoPath = path.join(packagePath, 'cache', logoFilename);
|
||||||
// })
|
await (image as any).write(logoPath);
|
||||||
// .toFile(path.join(logoPath, logoFilename));
|
await min.core['setConfig'](min, 'Logo', logoFilename);
|
||||||
await min.core['setConfig'](min, 'Logo', logoFilename);
|
|
||||||
} catch (error) {
|
|
||||||
GBLogEx.debug(min, error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract dominant colors from the screenshot
|
// Extract dominant colors from the screenshot
|
||||||
|
|
15
templates/talk-to-data.gbai/talk-to-data.gbdialog/start.bas
Normal file
15
templates/talk-to-data.gbai/talk-to-data.gbdialog/start.bas
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue