@@ -8,7 +8,7 @@ import React, {
88 Fragment ,
99 RefObject ,
1010} from "react" ;
11- import DocumentIcon from "../icons/document.svg" ;
11+
1212import SendWhiteIcon from "../icons/send-white.svg" ;
1313import BrainIcon from "../icons/brain.svg" ;
1414import RenameIcon from "../icons/rename.svg" ;
@@ -548,91 +548,6 @@ export function ChatActions(props: {
548548 ) ;
549549 }
550550 } , [ chatStore , currentModel , models ] ) ;
551- const isBedrockProvider = currentProviderName === ServiceProvider . Bedrock ;
552-
553- // ... (rest of the existing state and functions)
554-
555- async function uploadDocument ( ) {
556- const fileInput = document . createElement ( "input" ) ;
557- fileInput . type = "file" ;
558- fileInput . accept = ".pdf,.csv,.doc,.docx,.xls,.xlsx,.html,.txt,.md" ;
559- fileInput . onchange = async ( event : any ) => {
560- const file = event . target . files [ 0 ] ;
561- if ( ! file ) return ;
562-
563- props . setUploading ( true ) ;
564- try {
565- // Convert file to base64
566- const base64 = await new Promise < string > ( ( resolve , reject ) => {
567- const reader = new FileReader ( ) ;
568- reader . onload = ( e ) => {
569- if ( ! e . target ?. result ) return reject ( "Failed to read file" ) ;
570- const base64 = ( e . target . result as string ) . split ( "," ) [ 1 ] ;
571- resolve ( base64 ) ;
572- } ;
573- reader . onerror = reject ;
574- reader . readAsDataURL ( file ) ;
575- } ) ;
576-
577- // Get file extension
578- const format = file . name . split ( "." ) . pop ( ) ?. toLowerCase ( ) || "" ;
579- const supportedFormats = [
580- "pdf" ,
581- "csv" ,
582- "doc" ,
583- "docx" ,
584- "xls" ,
585- "xlsx" ,
586- "html" ,
587- "txt" ,
588- "md" ,
589- ] ;
590-
591- if ( ! supportedFormats . includes ( format ) ) {
592- throw new Error ( "Unsupported file format" ) ;
593- }
594-
595- // Format file size
596- const size = file . size ;
597- let sizeStr = "" ;
598- if ( size < 1024 ) {
599- sizeStr = size + " B" ;
600- } else if ( size < 1024 * 1024 ) {
601- sizeStr = ( size / 1024 ) . toFixed ( 2 ) + " KB" ;
602- } else {
603- sizeStr = ( size / ( 1024 * 1024 ) ) . toFixed ( 2 ) + " MB" ;
604- }
605-
606- // Create document content with only filename and size
607- const documentContent = {
608- type : "document" ,
609- document : {
610- format,
611- name : file . name ,
612- size : sizeStr ,
613- source : {
614- bytes : base64 ,
615- } ,
616- } ,
617- } ;
618-
619- // Submit the document content as a JSON string but only display filename and size
620- const displayContent = `Document: ${ file . name } (${ sizeStr } )` ;
621- chatStore . onUserInput ( displayContent ) ;
622-
623- // Store the actual document content separately if needed
624- // chatStore.updateCurrentSession((session) => {
625- // session.lastDocument = documentContent;
626- // });
627- } catch ( error ) {
628- console . error ( "Failed to upload document:" , error ) ;
629- showToast ( "Failed to upload document" ) ;
630- } finally {
631- props . setUploading ( false ) ;
632- }
633- } ;
634- fileInput . click ( ) ;
635- }
636551
637552 return (
638553 < div className = { styles [ "chat-input-actions" ] } >
@@ -665,14 +580,6 @@ export function ChatActions(props: {
665580 icon = { props . uploading ? < LoadingButtonIcon /> : < ImageIcon /> }
666581 />
667582 ) }
668- { /* Add document upload button for Bedrock */ }
669- { isBedrockProvider && (
670- < ChatAction
671- onClick = { uploadDocument }
672- text = { Locale . Chat . InputActions . UploadDocument }
673- icon = { props . uploading ? < LoadingButtonIcon /> : < DocumentIcon /> }
674- />
675- ) }
676583 < ChatAction
677584 onClick = { nextTheme }
678585 text = { Locale . Chat . InputActions . Theme [ theme ] }
0 commit comments