@@ -542,7 +542,8 @@ const Chat: React.FC<ChatProps> = ({
542542 }
543543 // END OF STREAMING
544544 if ( hasError ) {
545- const errorMsg = JSON . parse ( runningText ) . error ;
545+ const errorMsg = JSON . parse ( runningText ) . error === "Attempted to access streaming response content, without having called `read()`." ?"An error occurred. Please try again later." : JSON . parse ( runningText ) . error ;
546+
546547 const errorMessage : ChatMessage = {
547548 id : generateUUIDv4 ( ) ,
548549 role : ASSISTANT ,
@@ -641,7 +642,6 @@ const Chat: React.FC<ChatProps> = ({
641642 ] ;
642643 }
643644 }
644- console . log ( "line 66o:updatedMessages:::" , updatedMessages )
645645 saveToDB ( updatedMessages , conversationId , isChatReq ) ;
646646 } catch ( e ) {
647647 console . log ( "Catched with an error while chat and save" , e ) ;
@@ -758,6 +758,8 @@ const Chat: React.FC<ChatProps> = ({
758758 messages . map ( ( msg , index ) => (
759759 < div key = { index } className = { `chat-message ${ msg . role } ` } >
760760 { ( ( ) => {
761+ const isLastAssistantMessage =
762+ msg . role === "assistant" && index === messages . length - 1 ;
761763 if ( ( msg . role === "user" ) && typeof msg . content === "string" ) {
762764 if ( msg . content == "show in a graph by default" ) return null ;
763765 return (
@@ -787,16 +789,25 @@ const Chat: React.FC<ChatProps> = ({
787789 remarkPlugins = { [ remarkGfm , supersub ] }
788790 children = { msg . content }
789791 />
790- < Citations
791- answer = { {
792- answer : msg . content ,
793- citations :
794- msg . role === ASSISTANT
795- ? parseCitationFromMessage ( msg . citations )
796- : [ ] ,
797- } }
798- index = { index }
799- />
792+ { /* Citation Loader: Show only while citations are fetching */ }
793+ { isLastAssistantMessage && generatingResponse ? (
794+ < div className = "typing-indicator" >
795+ < span className = "dot" > </ span >
796+ < span className = "dot" > </ span >
797+ < span className = "dot" > </ span >
798+ </ div >
799+ ) : (
800+ < Citations
801+ answer = { {
802+ answer : msg . content ,
803+ citations :
804+ msg . role === "assistant"
805+ ? parseCitationFromMessage ( msg . citations )
806+ : [ ] ,
807+ } }
808+ index = { index }
809+ />
810+ ) }
800811
801812 < div className = "answerDisclaimerContainer" >
802813 < span className = "answerDisclaimer" >
0 commit comments