matt HOFFNER commited on
Commit
d4cd819
Β·
1 Parent(s): e82c85b

fix plain text embed

Browse files
Files changed (1) hide show
  1. src/components/FileLoader.jsx +8 -2
src/components/FileLoader.jsx CHANGED
@@ -45,7 +45,13 @@ export const FileLoader = () => {
45
  if (file.type === "application/pdf") {
46
  text = await Pdf.getPDFText(URL.createObjectURL(blob));
47
  } else {
48
- text = URL.createObjectURL(blob);
 
 
 
 
 
 
49
  }
50
  const response = await fetch('/api/docHandle', {
51
  method: 'POST',
@@ -55,7 +61,7 @@ export const FileLoader = () => {
55
  console.log('handleDocs-getModels: ', docChat);
56
  const id = await db.docs.add({
57
  fileName: file.name || '',
58
- fileSourceData: pdfText,
59
  model: docChat,
60
  });
61
  setUploadStatus("Embedding Completed");
 
45
  if (file.type === "application/pdf") {
46
  text = await Pdf.getPDFText(URL.createObjectURL(blob));
47
  } else {
48
+ let reader = new FileReader();
49
+
50
+ reader.addEventListener('load', function (e) {
51
+ text = e.target.result;
52
+ });
53
+
54
+ reader.readAsBinaryString(file);
55
  }
56
  const response = await fetch('/api/docHandle', {
57
  method: 'POST',
 
61
  console.log('handleDocs-getModels: ', docChat);
62
  const id = await db.docs.add({
63
  fileName: file.name || '',
64
+ fileSourceData: text,
65
  model: docChat,
66
  });
67
  setUploadStatus("Embedding Completed");