forked from labring/FastGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
182 changed files
with
3,084 additions
and
81,670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: 'V4.6.6(需要改配置文件)' | ||
description: 'FastGPT V4.6.6' | ||
icon: 'upgrade' | ||
draft: false | ||
toc: true | ||
weight: 831 | ||
--- | ||
|
||
**版本仍在开发中……** | ||
|
||
## 配置文件变更 | ||
|
||
为了减少代码重复度,我们对配置文件做了一些修改:[点击查看最新的配置文件](/docs/development/configuration/) | ||
|
||
|
||
|
||
## V4.6.6 即将更新 | ||
|
||
1. UI 优化,未来将逐步替换新的UI设计。 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* read file to txt */ | ||
import * as pdfjsLib from 'pdfjs-dist'; | ||
|
||
export const readPdfFile = async ({ pdf }: { pdf: string | URL | ArrayBuffer }) => { | ||
pdfjsLib.GlobalWorkerOptions.workerSrc = '/js/pdf.worker.js'; | ||
|
||
type TokenType = { | ||
str: string; | ||
dir: string; | ||
width: number; | ||
height: number; | ||
transform: number[]; | ||
fontName: string; | ||
hasEOL: boolean; | ||
}; | ||
|
||
const readPDFPage = async (doc: any, pageNo: number) => { | ||
const page = await doc.getPage(pageNo); | ||
const tokenizedText = await page.getTextContent(); | ||
|
||
const viewport = page.getViewport({ scale: 1 }); | ||
const pageHeight = viewport.height; | ||
const headerThreshold = pageHeight * 0.07; // 假设页头在页面顶部5%的区域内 | ||
const footerThreshold = pageHeight * 0.93; // 假设页脚在页面底部5%的区域内 | ||
|
||
const pageTexts: TokenType[] = tokenizedText.items.filter((token: TokenType) => { | ||
return ( | ||
!token.transform || | ||
(token.transform[5] > headerThreshold && token.transform[5] < footerThreshold) | ||
); | ||
}); | ||
|
||
// concat empty string 'hasEOL' | ||
for (let i = 0; i < pageTexts.length; i++) { | ||
const item = pageTexts[i]; | ||
if (item.str === '' && pageTexts[i - 1]) { | ||
pageTexts[i - 1].hasEOL = item.hasEOL; | ||
pageTexts.splice(i, 1); | ||
i--; | ||
} | ||
} | ||
|
||
page.cleanup(); | ||
|
||
return pageTexts | ||
.map((token) => { | ||
const paragraphEnd = token.hasEOL && /([。?!.?!\n\r]|(\r\n))$/.test(token.str); | ||
|
||
return paragraphEnd ? `${token.str}\n` : token.str; | ||
}) | ||
.join(''); | ||
}; | ||
|
||
const doc = await pdfjsLib.getDocument(pdf).promise; | ||
const pageTextPromises = []; | ||
for (let pageNo = 1; pageNo <= doc.numPages; pageNo++) { | ||
pageTextPromises.push(readPDFPage(doc, pageNo)); | ||
} | ||
const pageTexts = await Promise.all(pageTextPromises); | ||
|
||
return pageTexts.join(''); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.