Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Merge pull request #50 from childmindresearch:feature/upload-txt
Browse files Browse the repository at this point in the history
Add support for uploading .txt files
  • Loading branch information
ReinderVosDeWael authored May 31, 2024
2 parents 9e737a3 + ab201c1 commit 75cd989
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/routes/gpt/Chat/Chat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@
function uploadFile() {
const input = document.createElement('input');
input.type = 'file';
input.accept = '.pdf, .jpg, .jpeg, .png, .bmp, .tiff, .heif, .docx, .xlsx, .pptx, .html';
input.accept = '.pdf, .jpg, .jpeg, .png, .bmp, .tiff, .heif, .docx, .xlsx, .pptx, .html, .txt';
input.onchange = async (event) => {
const files = (event.target as HTMLInputElement).files;
if (!files) return;
if (files[0].name.split('.').slice(-1)[0] === 'txt') {
const text = await files[0].text();
addMessage(text, 'user');
await addResponse();
return;
}
const file = files[0];
const formData = new FormData();
formData.append('file', file);
Expand Down

0 comments on commit 75cd989

Please sign in to comment.