Skip to content

Commit e9ffdab

Browse files
committed
ENABLE_PDF_CHAT env var
1 parent 1484132 commit e9ffdab

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
@@ -108,6 +108,8 @@ PUBLIC_APP_DATA_SHARING=#set to 1 to enable options & text regarding data sharin
108108
PUBLIC_APP_DISCLAIMER=#set to 1 to show a disclaimer on login page
109109
LLM_SUMMERIZATION=true
110110

111+
ENABLE_PDF_CHAT=false #set to true to enable PDF-chat feature
112+
111113
# PUBLIC_APP_NAME=HuggingChat
112114
# PUBLIC_APP_ASSETS=huggingchat
113115
# 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
@@ -178,10 +178,12 @@
178178
/>
179179
{/if}
180180
<div class="ml-auto flex items-center gap-x-3">
181-
{#if pdfUpload?.name}
181+
{#if $page.data.enablePdfChat && pdfUpload?.name}
182182
<UploadedPdfStatus on:deletepdf {pdfUpload} />
183183
{/if}
184-
<UploadBtn bind:files on:uploadpdf multimodal={currentModel.multimodal} {pdfUpload} />
184+
{#if currentModel.multimodal || $page.data.enablePdfChat}
185+
<UploadBtn bind:files on:uploadpdf multimodal={currentModel.multimodal} pdfChat={$page.data.enablePdfChat} {pdfUpload} />
186+
{/if}
185187
</div>
186188
</div>
187189
<form

src/routes/+layout.server.ts

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
MESSAGES_BEFORE_LOGIN,
1313
YDC_API_KEY,
1414
USE_LOCAL_WEBSEARCH,
15+
ENABLE_PDF_CHAT,
1516
} from "$env/static/private";
1617

1718
export const load: LayoutServerLoad = async ({ locals, depends }) => {
@@ -59,6 +60,8 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
5960

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

63+
const enablePdfChat = ENABLE_PDF_CHAT === "true";
64+
6265
return {
6366
conversations: await conversations
6467
.find(authCondition(locals))
@@ -127,5 +130,6 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
127130
loginRequired,
128131
loginEnabled: requiresUser,
129132
guestMode: requiresUser && messagesBeforeLogin > 0,
133+
enablePdfChat,
130134
};
131135
};

0 commit comments

Comments
 (0)