feat: remove KnowledgeSearching and add knowledge configuration page and add a run button to the document (#64)

* feat: add a run button to the document

* feat: add knowledge configuration page

* feat: remove KnowledgeSearching
This commit is contained in:
balibabu
2024-02-18 18:18:20 +08:00
committed by GitHub
parent 53be70c7a9
commit f3d0ebd293
22 changed files with 495 additions and 687 deletions

28
web/src/utils/fileUtil.ts Normal file
View File

@@ -0,0 +1,28 @@
export const transformFile2Base64 = (val: any): Promise<any> => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(val);
reader.onload = (): void => {
resolve(reader.result);
};
reader.onerror = reject;
});
};
export const transformBase64ToFile = (
dataUrl: string,
filename: string = 'file',
) => {
let arr = dataUrl.split(','),
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
const mime = arr[0].match(/:(.*?);/);
const mimeType = mime ? mime[1] : 'image/png';
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, { type: mimeType });
};