From caf66bf5ca2480a626ee61e65219ffddeb0dea19 Mon Sep 17 00:00:00 2001 From: Reinder Vos de Wael Date: Fri, 31 May 2024 14:45:01 -0400 Subject: [PATCH 1/2] Add .txt as a valid format --- src/routes/gpt/Chat/Chat.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/gpt/Chat/Chat.svelte b/src/routes/gpt/Chat/Chat.svelte index 577a89d..dfea061 100644 --- a/src/routes/gpt/Chat/Chat.svelte +++ b/src/routes/gpt/Chat/Chat.svelte @@ -75,7 +75,7 @@ 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; From ab201c1f5f65821488d8162a186596d5f73176ad Mon Sep 17 00:00:00 2001 From: Reinder Vos de Wael Date: Fri, 31 May 2024 14:48:56 -0400 Subject: [PATCH 2/2] Upload .txt directly --- src/routes/gpt/Chat/Chat.svelte | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/routes/gpt/Chat/Chat.svelte b/src/routes/gpt/Chat/Chat.svelte index dfea061..7e14024 100644 --- a/src/routes/gpt/Chat/Chat.svelte +++ b/src/routes/gpt/Chat/Chat.svelte @@ -79,6 +79,12 @@ 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);