Skip to content

Commit

Permalink
Ensure only pdf files are handled
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutugiii committed Sep 30, 2024
1 parent 3e5ae00 commit e8508bb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions chatapi/src/utils/chat-helpers.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit e8508bb

Please sign in to comment.