File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 44from semantic_kernel .functions .kernel_function_decorator import kernel_function
55from azure .identity import DefaultAzureCredential
66from azure .ai .projects import AIProjectClient
7+ import copy
78
89from common .config .config import Config
910from common .database .sqldb_service import execute_sql_query
@@ -197,7 +198,13 @@ def get_answers_from_calltranscripts(
197198 ]
198199 }
199200 )
200- answer = completion .choices [0 ]
201+ answer = copy .deepcopy (completion .choices [0 ])
202+
203+ # Limit the content inside citations to 300 characters to minimize load
204+ if 'citations' in answer .message .context :
205+ for citation in answer .message .context ['citations' ]:
206+ if 'content' in citation :
207+ citation ['content' ] = citation ['content' ][:300 ] + '...' if len (citation ['content' ]) > 300 else citation ['content' ]
201208 except BaseException :
202209 answer = 'Details could not be retrieved. Please try again later.'
203210 return answer
You can’t perform that action at this time.
0 commit comments