MCPcopy
hub / github.com/mudler/LocalAI / readInputFileFile

Function readInputFileFile

core/http/static/chat.js:959–984  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

957}
958
959function readInputFileFile(file) {
960 const FR = new FileReader();
961 currentFileNames.push(file.name);
962 const fileExtension = file.name.split('.').pop().toLowerCase();
963
964 FR.addEventListener("load", async function(evt) {
965 if (fileExtension === 'pdf') {
966 try {
967 const content = await extractTextFromPDF(evt.target.result);
968 fileContents.push({ name: file.name, content: content });
969 } catch (error) {
970 console.error('Error processing PDF:', error);
971 fileContents.push({ name: file.name, content: "Error processing PDF file" });
972 }
973 } else {
974 // For text and markdown files
975 fileContents.push({ name: file.name, content: evt.target.result });
976 }
977 });
978
979 if (fileExtension === 'pdf') {
980 FR.readAsArrayBuffer(file);
981 } else {
982 FR.readAsText(file);
983 }
984}
985
986function submitPrompt(event) {
987 event.preventDefault();

Callers 2

chat.jsFile · 0.85
readInputFileFunction · 0.85

Calls 5

extractTextFromPDFFunction · 0.85
popMethod · 0.80
addEventListenerMethod · 0.80
pushMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected