Skip to content

Commit

Permalink
fix(llm.gblib): Fix in doc. publishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Dec 3, 2024
1 parent e7ad6e8 commit a443927
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"html-to-md": "0.8.6",
"http-proxy": "1.18.1",
"ibm-watson": "9.1.0",
"icojs": "^0.19.4",
"instagram-private-api": "1.46.1",
"iso-639-1": "3.1.3",
"isomorphic-fetch": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ export class GBDeployer implements IGBDeployer {

GBServer.globals.server.use(
`/${gbaiName}/${botId}.gbdrive/public`,
express.static(urlJoin('work', gbaiName, `${botId}.gbdata`, 'public'))
express.static(urlJoin('work', gbaiName, `${botId}.gbdrive`, 'public'))
);

GBLog.verbose(`KB (.gbkb) assets accessible at: /kb/${gbaiName}/${packageName}.`);
Expand Down
14 changes: 10 additions & 4 deletions packages/kb.gbapp/services/KBService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { DocxLoader } from '@langchain/community/document_loaders/fs/docx';
import { EPubLoader } from '@langchain/community/document_loaders/fs/epub';
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';
import svg2img from 'svg2img';
import isICO from 'icojs';
import getColors from 'get-image-colors';
import { Document } from 'langchain/document';
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
Expand Down Expand Up @@ -1069,13 +1070,18 @@ export class KBService implements IGBKBService {

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

// Replace sharp with jimp
if (buffer.toString().includes('<svg')) {
if (buffer.slice(0, 4).toString('hex') === '00000100') {
// Convert ICO to PNG
const images = await isICO.parseICO(buffer, 'image/x-icon');
if (!images || images.length === 0) {
throw new Error('Failed to parse ICO file');
}
buffer = Buffer.from(images[0].buffer);
} else if (buffer.toString().includes('<svg')) {

logoFilename = logoFilename.replace('.svg', '.png');

// For SVG files, convert using svg2img

buffer = await new Promise((resolve, reject) => {
Expand Down

0 comments on commit a443927

Please sign in to comment.