File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
packages/cozy-viewer/src/Panel/AI Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments