Skip to content

Commit

Permalink
fix(llm.gblib): Talk to data local db use fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Nov 30, 2024
1 parent 5e8e3cb commit 4205437
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
"sqlite3": "5.1.7",
"ssr-for-bots": "1.0.1-c",
"strict-password-generator": "1.1.2",
"svg2img": "^1.0.0-beta.2",
"swagger-client": "3.29.2",
"swagger-ui-dist": "5.17.14",
"tabulator-tables": "6.2.5",
Expand Down
17 changes: 16 additions & 1 deletion packages/kb.gbapp/services/KBService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,24 @@ export class KBService implements IGBKBService {
logo = logo.startsWith('https') ? logo : urlJoin(baseUrl, logo);

const logoBinary = await page.goto(logo);
const buffer = await logoBinary.buffer();
let buffer = await logoBinary.buffer();
const logoFilename = path.basename(logo);

// Replace sharp with jimp
if (buffer.toString().includes('<svg')) {
// For SVG files, convert using svg2img
const svg2img = require('svg2img');
buffer = await new Promise((resolve, reject) => {
svg2img(buffer, {width: 48, height: 48}, (error: any, buffer: Buffer) => {
if (error) {
reject(error);
} else {
resolve(buffer);
}
});
});
}

// Replace sharp with jimp
const image = await Jimp.read(buffer);
await image.scaleToFit({w:48, h:48});
Expand Down

0 comments on commit 4205437

Please sign in to comment.