Skip to content

Commit ba5f9b1

Browse files
committed
ENABLE_PDF_CHAT env var
1 parent 51249f1 commit ba5f9b1

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

.env

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ PUBLIC_APP_DATA_SHARING=#set to 1 to enable options & text regarding data sharin
104104
PUBLIC_APP_DISCLAIMER=#set to 1 to show a disclaimer on login page
105105
LLM_SUMMERIZATION=true
106106

107+
ENABLE_PDF_CHAT=false #set to true to enable PDF-chat feature
108+
107109
# PUBLIC_APP_NAME=HuggingChat
108110
# PUBLIC_APP_ASSETS=huggingchat
109111
# PUBLIC_APP_COLOR=yellow

src/lib/components/UploadBtn.svelte

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
77
export let classNames = "";
88
export let multimodal = false;
9+
export let pdfChat = false;
910
export let files: File[];
1011
export let pdfUpload: PdfUpload | undefined = undefined;
11-
const accept = multimodal ? "image/*,.pdf" : ".pdf";
12-
const label = multimodal ? "Upload image or PDF" : "Upload PDF";
12+
13+
const accept = (multimodal && pdfChat) ? "image/*,.pdf" : multimodal ? "image/*" : ".pdf";
14+
const label = (multimodal && pdfChat) ? "Upload image or PDF" : multimodal ? "Upload image" : "Upload PDF";
15+
1316
let fileInput: HTMLInputElement;
1417
let interval: ReturnType<typeof setInterval>;
1518
@@ -35,7 +38,7 @@
3538
}
3639
3740
const file = fileInput.files?.[0];
38-
if (file?.type === "application/pdf") {
41+
if (pdfChat && file?.type === "application/pdf") {
3942
// pdf upload
4043
dispatch("uploadpdf", file);
4144
} else if (multimodal && file?.type.startsWith("image")) {

src/lib/components/chat/ChatWindow.svelte

+4-2
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@
157157
/>
158158
{/if}
159159
<div class="ml-auto flex items-center gap-x-3">
160-
{#if pdfUpload?.name}
160+
{#if $page.data.enablePdfChat && pdfUpload?.name}
161161
<UploadedPdfStatus on:deletepdf {pdfUpload} />
162162
{/if}
163-
<UploadBtn bind:files on:uploadpdf multimodal={currentModel.multimodal} {pdfUpload} />
163+
{#if currentModel.multimodal || $page.data.enablePdfChat}
164+
<UploadBtn bind:files on:uploadpdf multimodal={currentModel.multimodal} pdfChat={$page.data.enablePdfChat} {pdfUpload} />
165+
{/if}
164166
</div>
165167
</div>
166168
<form

src/routes/+layout.server.ts

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
MESSAGES_BEFORE_LOGIN,
1212
YDC_API_KEY,
1313
USE_LOCAL_WEBSEARCH,
14+
ENABLE_PDF_CHAT,
1415
} from "$env/static/private";
1516

1617
export const load: LayoutServerLoad = async ({ locals, depends }) => {
@@ -58,6 +59,8 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
5859

5960
const loginRequired = requiresUser && !locals.user && userHasExceededMessages;
6061

62+
const enablePdfChat = ENABLE_PDF_CHAT === "true";
63+
6164
return {
6265
conversations: await conversations
6366
.find(authCondition(locals))
@@ -111,5 +114,6 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
111114
loginRequired,
112115
loginEnabled: requiresUser,
113116
guestMode: requiresUser && messagesBeforeLogin > 0,
117+
enablePdfChat,
114118
};
115119
};

0 commit comments

Comments
 (0)