From e8508bba3193a6d32a48f3dfe5458acd655d45f4 Mon Sep 17 00:00:00 2001 From: mutugiii Date: Mon, 30 Sep 2024 19:59:16 +0300 Subject: [PATCH] Ensure only pdf files are handled --- chatapi/src/utils/chat-helpers.utils.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/chatapi/src/utils/chat-helpers.utils.ts b/chatapi/src/utils/chat-helpers.utils.ts index e7f8303ffc..57e91cc369 100644 --- a/chatapi/src/utils/chat-helpers.utils.ts +++ b/chatapi/src/utils/chat-helpers.utils.ts @@ -137,9 +137,11 @@ export async function aiChatNonStream( const typedAttachment = attachment as Attachment; const contentType = typedAttachment.content_type; - const file = await fetchFileFromCouchDB(context.resource.id, attachmentName); - const text = await extractTextFromDocument(file as Buffer, contentType); - context.data += text; + if (contentType === 'application/pdf') { + const file = await fetchFileFromCouchDB(context.resource.id, attachmentName); + const text = await extractTextFromDocument(file as Buffer, contentType); + context.data += text; + } } }