fix(llm.gblib): Talk to data local db use fix.
This commit is contained in:
parent
420543768b
commit
afc72c5d55
1 changed files with 22 additions and 13 deletions
|
@ -47,8 +47,7 @@ import { CSVLoader } from '@langchain/community/document_loaders/fs/csv';
|
|||
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 { rimraf } from 'rimraf';
|
||||
|
||||
import svg2img from 'svg2img';
|
||||
import getColors from 'get-image-colors';
|
||||
import { Document } from 'langchain/document';
|
||||
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
|
||||
|
@ -1067,14 +1066,24 @@ export class KBService implements IGBKBService {
|
|||
|
||||
const logoBinary = await page.goto(logo);
|
||||
let buffer = await logoBinary.buffer();
|
||||
const logoFilename = path.basename(logo);
|
||||
let logoFilename = path.basename(logo);
|
||||
|
||||
// Replace sharp with jimp
|
||||
if (buffer.toString().includes('<svg')) {
|
||||
|
||||
logoFilename = logoFilename.replace('.svg', '.png');
|
||||
|
||||
// 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) => {
|
||||
svg2img(buffer, {
|
||||
resvg: {
|
||||
fitTo: {
|
||||
mode: 'width', // or height
|
||||
value: 48,
|
||||
},
|
||||
}
|
||||
}, (error: any, buffer: Buffer) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue