diff --git a/.env b/.env index cf5ed56e744..651ae3b1ba8 100644 --- a/.env +++ b/.env @@ -108,6 +108,8 @@ PUBLIC_APP_DATA_SHARING=#set to 1 to enable options & text regarding data sharin PUBLIC_APP_DISCLAIMER=#set to 1 to show a disclaimer on login page LLM_SUMMERIZATION=true +ENABLE_PDF_CHAT=false #set to true to enable PDF-chat feature + # PUBLIC_APP_NAME=HuggingChat # PUBLIC_APP_ASSETS=huggingchat # PUBLIC_APP_COLOR=yellow diff --git a/src/lib/components/UploadBtn.svelte b/src/lib/components/UploadBtn.svelte index 62b87316cee..2c8005b9a0c 100644 --- a/src/lib/components/UploadBtn.svelte +++ b/src/lib/components/UploadBtn.svelte @@ -6,10 +6,13 @@ export let classNames = ""; export let multimodal = false; + export let pdfChat = false; export let files: File[]; export let pdfUpload: PdfUpload | undefined = undefined; - const accept = multimodal ? "image/*,.pdf" : ".pdf"; - const label = multimodal ? "Upload image or PDF" : "Upload PDF"; + + const accept = (multimodal && pdfChat) ? "image/*,.pdf" : multimodal ? "image/*" : ".pdf"; + const label = (multimodal && pdfChat) ? "Upload image or PDF" : multimodal ? "Upload image" : "Upload PDF"; + let fileInput: HTMLInputElement; let interval: ReturnType; @@ -35,7 +38,7 @@ } const file = fileInput.files?.[0]; - if (file?.type === "application/pdf") { + if (pdfChat && file?.type === "application/pdf") { // pdf upload dispatch("uploadpdf", file); } else if (multimodal && file?.type.startsWith("image")) { diff --git a/src/lib/components/chat/ChatWindow.svelte b/src/lib/components/chat/ChatWindow.svelte index 673d67465a1..31001e4db49 100644 --- a/src/lib/components/chat/ChatWindow.svelte +++ b/src/lib/components/chat/ChatWindow.svelte @@ -178,10 +178,12 @@ /> {/if}
- {#if pdfUpload?.name} + {#if $page.data.enablePdfChat && pdfUpload?.name} {/if} - + {#if currentModel.multimodal || $page.data.enablePdfChat} + + {/if}
{ @@ -59,6 +60,8 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => { const loginRequired = requiresUser && !locals.user && userHasExceededMessages; + const enablePdfChat = ENABLE_PDF_CHAT === "true"; + return { conversations: await conversations .find(authCondition(locals)) @@ -127,5 +130,6 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => { loginRequired, loginEnabled: requiresUser, guestMode: requiresUser && messagesBeforeLogin > 0, + enablePdfChat, }; };