Skip to content

Commit

Permalink
ENABLE_PDF_CHAT env var
Browse files Browse the repository at this point in the history
  • Loading branch information
mishig25 committed Jan 9, 2024
1 parent 1484132 commit e9ffdab
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/lib/components/UploadBtn.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof setInterval>;
Expand All @@ -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")) {
Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/chat/ChatWindow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@
/>
{/if}
<div class="ml-auto flex items-center gap-x-3">
{#if pdfUpload?.name}
{#if $page.data.enablePdfChat && pdfUpload?.name}
<UploadedPdfStatus on:deletepdf {pdfUpload} />
{/if}
<UploadBtn bind:files on:uploadpdf multimodal={currentModel.multimodal} {pdfUpload} />
{#if currentModel.multimodal || $page.data.enablePdfChat}
<UploadBtn bind:files on:uploadpdf multimodal={currentModel.multimodal} pdfChat={$page.data.enablePdfChat} {pdfUpload} />
{/if}
</div>
</div>
<form
Expand Down
4 changes: 4 additions & 0 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
MESSAGES_BEFORE_LOGIN,
YDC_API_KEY,
USE_LOCAL_WEBSEARCH,
ENABLE_PDF_CHAT,
} from "$env/static/private";

export const load: LayoutServerLoad = async ({ locals, depends }) => {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -127,5 +130,6 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
loginRequired,
loginEnabled: requiresUser,
guestMode: requiresUser && messagesBeforeLogin > 0,
enablePdfChat,
};
};

0 comments on commit e9ffdab

Please sign in to comment.