File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -642,7 +642,9 @@ const Chat: React.FC<ChatProps> = ({
642642 ] ;
643643 }
644644 }
645- saveToDB ( updatedMessages , conversationId , isChatReq ) ;
645+ if ( ! updatedMessages . find ( ( msg : any ) => msg . role === "error" ) ) {
646+ saveToDB ( updatedMessages , conversationId , isChatReq ) ;
647+ }
646648 } catch ( e ) {
647649 console . log ( "Catched with an error while chat and save" , e ) ;
648650 if ( abortController . signal . aborted ) {
Original file line number Diff line number Diff line change @@ -198,6 +198,12 @@ def get_answers_from_calltranscripts(
198198 }
199199 )
200200 answer = completion .choices [0 ]
201+
202+ # Limit the content inside citations to 300 characters to minimize load
203+ if hasattr (answer .message , 'context' ) and 'citations' in answer .message .context :
204+ for citation in answer .message .context .get ('citations' , []):
205+ if isinstance (citation , dict ) and 'content' in citation :
206+ citation ['content' ] = citation ['content' ][:300 ] + '...' if len (citation ['content' ]) > 300 else citation ['content' ]
201207 except BaseException :
202208 answer = 'Details could not be retrieved. Please try again later.'
203209 return answer
You can’t perform that action at this time.
0 commit comments