Skip to content

Commit fac5314

Browse files
lethemanhlethemanh
authored andcommitted
feat: Skip extract file content with txt or markdown file ✨
1 parent f66279b commit fac5314

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

packages/cozy-viewer/src/Panel/AI/AIAssistantPanel.jsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,22 @@ const AIAssistantPanel = ({ className }) => {
5353
try {
5454
const fileBlob = await fetchBlobFileById(client, file?._id)
5555

56-
const rawTextContent = await extractText(client, fileBlob, {
57-
name: file.name,
58-
mime: file.mime
59-
})
60-
const textContent = rawTextContent ? JSON.stringify(rawTextContent) : ''
56+
let textContent = ''
57+
const mime = file.mime?.toLowerCase() || ''
58+
59+
if (
60+
mime === 'text/plain' ||
61+
mime === 'text/markdown' ||
62+
mime.startsWith('text/')
63+
) {
64+
textContent = await fileBlob.text()
65+
} else {
66+
const rawTextContent = await extractText(client, fileBlob, {
67+
name: file.name,
68+
mime: file.mime
69+
})
70+
textContent = rawTextContent ? JSON.stringify(rawTextContent) : ''
71+
}
6172

6273
const summaryConfig = flag('drive.summary')
6374
if (

0 commit comments

Comments
 (0)