feat: 知识库文件支持 html 类型

This commit is contained in:
Wenwei Lin 2025-02-09 18:24:25 +08:00 committed by 亢奋猫
parent 72d61ef853
commit c900a186b7
2 changed files with 12 additions and 1 deletions

View File

@ -178,6 +178,17 @@ class KnowledgeService {
const fileContent = fs.readFileSync(file.path, 'utf-8') const fileContent = fs.readFileSync(file.path, 'utf-8')
if (['.html'].includes(file.ext)) {
return await ragApplication.addLoader(
new WebLoader({
urlOrContent: fileContent,
chunkSize: base.chunkSize,
chunkOverlap: base.chunkOverlap
}) as any,
forceReload
)
}
return await ragApplication.addLoader( return await ragApplication.addLoader(
new TextLoader({ text: fileContent, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }), new TextLoader({ text: fileContent, chunkSize: base.chunkSize, chunkOverlap: base.chunkOverlap }),
forceReload forceReload

View File

@ -33,7 +33,7 @@ interface KnowledgeContentProps {
selectedBase: KnowledgeBase selectedBase: KnowledgeBase
} }
const fileTypes = ['.pdf', '.docx', '.pptx', '.xlsx', '.txt', '.md'] const fileTypes = ['.pdf', '.docx', '.pptx', '.xlsx', '.txt', '.md', '.html']
const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => { const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
const { t } = useTranslation() const { t } = useTranslation()