@@ -118,7 +118,7 @@ type IUploads = {
118118 type : string ;
119119 name : string ;
120120 mime : string ;
121- } [ ]
121+ } [ ] ;
122122
123123type observerConfigType = ( accessor : string | boolean | object | MessageType [ ] ) => void ;
124124export type observersConfigType = Record < 'observeUserInput' | 'observeLoading' | 'observeMessages' , observerConfigType > ;
@@ -297,7 +297,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
297297
298298 // drag & drop
299299 const [ isDragActive , setIsDragActive ] = createSignal ( false ) ;
300- const [ uploadedFiles , setUploadedFiles ] = createSignal < { file : File , type : string } [ ] > ( [ ] ) ;
300+ const [ uploadedFiles , setUploadedFiles ] = createSignal < { file : File ; type : string } [ ] > ( [ ] ) ;
301301
302302 onMount ( ( ) => {
303303 if ( botProps ?. observersConfig ) {
@@ -643,54 +643,54 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
643643 } ;
644644
645645 const handleFileUploads = async ( uploads : IUploads ) => {
646- if ( ! uploadedFiles ( ) . length ) return uploads
646+ if ( ! uploadedFiles ( ) . length ) return uploads ;
647647
648648 if ( fullFileUpload ( ) ) {
649- const filesWithFullUploadType = uploadedFiles ( ) . filter ( ( file ) => file . type === 'file:full' )
649+ const filesWithFullUploadType = uploadedFiles ( ) . filter ( ( file ) => file . type === 'file:full' ) ;
650650
651- if ( filesWithFullUploadType . length > 0 ) {
652- const formData = new FormData ( )
653- for ( const file of filesWithFullUploadType ) {
654- formData . append ( 'files' , file . file )
655- }
656- formData . append ( 'chatId' , chatId ( ) )
651+ if ( filesWithFullUploadType . length > 0 ) {
652+ const formData = new FormData ( ) ;
653+ for ( const file of filesWithFullUploadType ) {
654+ formData . append ( 'files' , file . file ) ;
655+ }
656+ formData . append ( 'chatId' , chatId ( ) ) ;
657657
658- const response = await createAttachmentWithFormData ( {
659- chatflowid : props . chatflowid ,
660- apiHost : props . apiHost ,
661- formData : formData ,
662- } ) ;
658+ const response = await createAttachmentWithFormData ( {
659+ chatflowid : props . chatflowid ,
660+ apiHost : props . apiHost ,
661+ formData : formData ,
662+ } ) ;
663663
664- if ( ! response . data ) {
665- throw new Error ( 'Unable to upload documents' ) ;
666- } else {
667- const data = response . data as any
668- for ( const extractedFileData of data ) {
669- const content = extractedFileData . content
670- const fileName = extractedFileData . name
671-
672- // find matching name in previews and replace data with content
673- const uploadIndex = uploads . findIndex ( ( upload ) => upload . name === fileName )
674- if ( uploadIndex !== - 1 ) {
675- uploads [ uploadIndex ] = {
676- ...uploads [ uploadIndex ] ,
677- data : content ,
678- name : fileName ,
679- type : 'file:full'
680- }
681- }
664+ if ( ! response . data ) {
665+ throw new Error ( 'Unable to upload documents' ) ;
666+ } else {
667+ const data = response . data as any ;
668+ for ( const extractedFileData of data ) {
669+ const content = extractedFileData . content ;
670+ const fileName = extractedFileData . name ;
671+
672+ // find matching name in previews and replace data with content
673+ const uploadIndex = uploads . findIndex ( ( upload ) => upload . name === fileName ) ;
674+ if ( uploadIndex !== - 1 ) {
675+ uploads [ uploadIndex ] = {
676+ ...uploads [ uploadIndex ] ,
677+ data : content ,
678+ name : fileName ,
679+ type : 'file:full' ,
680+ } ;
682681 }
683682 }
684683 }
684+ }
685685 } else if ( uploadsConfig ( ) ?. isRAGFileUploadAllowed ) {
686- const filesWithRAGUploadType = uploadedFiles ( ) . filter ( ( file ) => file . type === 'file:rag' )
686+ const filesWithRAGUploadType = uploadedFiles ( ) . filter ( ( file ) => file . type === 'file:rag' ) ;
687687
688688 if ( filesWithRAGUploadType . length > 0 ) {
689- const formData = new FormData ( )
689+ const formData = new FormData ( ) ;
690690 for ( const file of filesWithRAGUploadType ) {
691- formData . append ( 'files' , file . file )
691+ formData . append ( 'files' , file . file ) ;
692692 }
693- formData . append ( 'chatId' , chatId ( ) )
693+ formData . append ( 'chatId' , chatId ( ) ) ;
694694
695695 const response = await upsertVectorStoreWithFormData ( {
696696 chatflowid : props . chatflowid ,
@@ -710,14 +710,14 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
710710 uploads = uploads . map ( ( upload ) => {
711711 return {
712712 ...upload ,
713- type : 'file:rag'
714- }
715- } )
713+ type : 'file:rag' ,
714+ } ;
715+ } ) ;
716716 }
717717 }
718718 }
719- return uploads
720- }
719+ return uploads ;
720+ } ;
721721
722722 // Handle form submission
723723 const handleSubmit = async ( value : string , action ?: IAction | undefined | null ) => {
@@ -741,10 +741,10 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
741741 } ) ;
742742
743743 try {
744- uploads = await handleFileUploads ( uploads )
744+ uploads = await handleFileUploads ( uploads ) ;
745745 } catch ( error ) {
746- handleError ( 'Unable to upload documents' )
747- return
746+ handleError ( 'Unable to upload documents' ) ;
747+ return ;
748748 }
749749
750750 clearPreviews ( ) ;
@@ -1024,8 +1024,8 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
10241024 setFollowUpPromptsStatus ( chatbotConfig . followUpPrompts . status ) ;
10251025 }
10261026 if ( chatbotConfig . fullFileUpload ) {
1027- setFullFileUpload ( chatbotConfig . fullFileUpload . status )
1028- }
1027+ setFullFileUpload ( chatbotConfig . fullFileUpload . status ) ;
1028+ }
10291029 }
10301030
10311031 // eslint-disable-next-line solid/reactivity
@@ -1090,7 +1090,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
10901090 } ) ;
10911091 }
10921092 if ( fullFileUpload ( ) ) {
1093- return true
1093+ return true ;
10941094 }
10951095 if ( uploadsConfig ( ) && uploadsConfig ( ) ?. isRAGFileUploadAllowed && uploadsConfig ( ) ?. fileUploadSizeAndTypes ) {
10961096 const fileExt = file . name . split ( '.' ) . pop ( ) ;
@@ -1164,7 +1164,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
11641164 return true ;
11651165 }
11661166 return false ;
1167- }
1167+ } ;
11681168
11691169 const handleDrag = ( e : DragEvent ) => {
11701170 if ( uploadsConfig ( ) ?. isImageUploadAllowed || isFileUploadAllowed ( ) ) {
0 commit comments