File tree Expand file tree Collapse file tree 2 files changed +32
-22
lines changed Expand file tree Collapse file tree 2 files changed +32
-22
lines changed Original file line number Diff line number Diff line change @@ -82,28 +82,38 @@ export function useChatExtraContext(): ChatExtraContextApi {
8282 toast . error ( 'Video and audio files are not supported yet.' ) ;
8383 break ;
8484 } else if ( mimeType . startsWith ( 'application/pdf' ) ) {
85- const promise = config . pdfAsImage
86- ? convertPDFToImage ( file ) . then ( ( base64Urls ) => {
87- addItems (
88- base64Urls . map ( ( base64Url ) => ( {
89- type : 'imageFile' ,
90- name : file . name ,
91- base64Url,
92- } ) )
93- ) ;
94- } )
95- : convertPDFToText ( file ) . then ( ( content ) => {
96- toast . success (
97- 'PDF file converted to text. You can also convert it to image, see in Settings.'
98- ) ;
99- addItems ( [
100- {
101- type : 'textFile' ,
102- name : file . name ,
103- content,
104- } ,
105- ] ) ;
106- } ) ;
85+ if ( config . pdfAsImage && ! isSupportVision ) {
86+ toast (
87+ 'Multimodal is not supported, PDF will be converted to text instead of image.'
88+ ) ;
89+ break ;
90+ }
91+
92+ const promise =
93+ config . pdfAsImage && isSupportVision
94+ ? convertPDFToImage ( file ) . then ( ( base64Urls ) => {
95+ addItems (
96+ base64Urls . map ( ( base64Url ) => ( {
97+ type : 'imageFile' ,
98+ name : file . name ,
99+ base64Url,
100+ } ) )
101+ ) ;
102+ } )
103+ : convertPDFToText ( file ) . then ( ( content ) => {
104+ if ( isSupportVision ) {
105+ toast . success (
106+ 'PDF file converted to text. You can also convert it to image, see in Settings.'
107+ ) ;
108+ }
109+ addItems ( [
110+ {
111+ type : 'textFile' ,
112+ name : file . name ,
113+ content,
114+ } ,
115+ ] ) ;
116+ } ) ;
107117
108118 promise . catch ( ( error ) => {
109119 console . error ( error ) ;
You can’t perform that action at this time.
0 commit comments