fix(llm.gblib): Fix in doc. publishing.
This commit is contained in:
parent
e7ad6e84ca
commit
a443927d36
3 changed files with 12 additions and 5 deletions
|
@ -151,6 +151,7 @@
|
||||||
"html-to-md": "0.8.6",
|
"html-to-md": "0.8.6",
|
||||||
"http-proxy": "1.18.1",
|
"http-proxy": "1.18.1",
|
||||||
"ibm-watson": "9.1.0",
|
"ibm-watson": "9.1.0",
|
||||||
|
"icojs": "^0.19.4",
|
||||||
"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",
|
||||||
|
|
|
@ -964,7 +964,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
GBServer.globals.server.use(
|
GBServer.globals.server.use(
|
||||||
`/${gbaiName}/${botId}.gbdrive/public`,
|
`/${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}.`);
|
GBLog.verbose(`KB (.gbkb) assets accessible at: /kb/${gbaiName}/${packageName}.`);
|
||||||
|
|
|
@ -48,6 +48,7 @@ import { DocxLoader } from '@langchain/community/document_loaders/fs/docx';
|
||||||
import { EPubLoader } from '@langchain/community/document_loaders/fs/epub';
|
import { EPubLoader } from '@langchain/community/document_loaders/fs/epub';
|
||||||
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';
|
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';
|
||||||
import svg2img from 'svg2img';
|
import svg2img from 'svg2img';
|
||||||
|
import isICO from 'icojs';
|
||||||
import getColors from 'get-image-colors';
|
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';
|
||||||
|
@ -1069,13 +1070,18 @@ export class KBService implements IGBKBService {
|
||||||
|
|
||||||
const logoBinary = await page.goto(logo);
|
const logoBinary = await page.goto(logo);
|
||||||
let buffer = await logoBinary.buffer();
|
let buffer = await logoBinary.buffer();
|
||||||
let logoFilename = path.basename(logo);
|
let logoFilename = 'extracted-logo.png';
|
||||||
|
|
||||||
// Replace sharp with jimp
|
// 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
|
// For SVG files, convert using svg2img
|
||||||
|
|
||||||
buffer = await new Promise((resolve, reject) => {
|
buffer = await new Promise((resolve, reject) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue