@@ -31,6 +31,8 @@ export const useChatStore = defineStore('chat', () => {
3131 const sourcesList : Ref < Document [ ] | null > = ref ( getFromStorage ( 'chatSources' ) || [ ] ) ;
3232 const reformulatedQuery : Ref < string | null > = ref ( getFromStorage ( 'reformulatedQuery' ) ) ;
3333 const queryToSearch : Ref < string | null > = ref ( null ) ;
34+ const storedConversationId : Ref < string | null > = ref ( localStorage . getItem ( 'chatConversationId' ) ) ;
35+ const storedMessageId : Ref < string | null > = ref ( localStorage . getItem ( 'chatMessageId' ) ) ;
3436
3537 const isChatEmpty : ComputedRef < Boolean > = computed ( ( ) => chatMessagesList . value . length === 0 ) ;
3638 const chatStatus : Ref < CHAT_STATUSES_TYPE > = ref (
@@ -208,9 +210,25 @@ export const useChatStore = defineStore('chat', () => {
208210 }
209211 }
210212
213+ function storeConversationId ( conversationId : string ) {
214+ if ( conversationId !== storedConversationId . value ) {
215+ localStorage . setItem ( 'chatConversationId' , conversationId ) ;
216+ storedConversationId . value = conversationId ;
217+ }
218+ }
219+
220+ function storeMessageId ( messageId : string ) {
221+ if ( messageId !== storedMessageId . value ) {
222+ console . log ( 'Storing message ID:' , messageId ) ;
223+ localStorage . setItem ( 'chatMessageId' , messageId ) ;
224+ storedMessageId . value = messageId ;
225+ }
226+ }
227+
211228 async function getNoStreamAnswer ( userMsg : string ) {
212229 chatStatus . value = CHAT_STATUS . FORMULATING_ANSWER ;
213230 const bodyContent = {
231+ conversation_id : storedConversationId . value ,
214232 sources : sourcesList . value || [ ] ,
215233 history : getMessageHistory . value ,
216234 query : userMsg ,
@@ -221,8 +239,10 @@ export const useChatStore = defineStore('chat', () => {
221239
222240 chatStatus . value = CHAT_STATUS . FORMULATED_ANSWER ;
223241
224- chatMessagesList . value . push ( { role : 'assistant' , content : respBody . data } ) ;
242+ chatMessagesList . value . push ( { role : 'assistant' , content : respBody . data . answer } ) ;
225243 saveToStorage ( 'chat' , chatMessagesList . value ) ;
244+ storeConversationId ( respBody . data . conversation_id ) ;
245+ storeMessageId ( respBody . data . message_id ) ;
226246
227247 const newQuestions : AxiosResponse < { NEW_QUESTIONS : string [ ] } > = await postAxios (
228248 '/qna/reformulate/questions' ,
@@ -322,11 +342,15 @@ export const useChatStore = defineStore('chat', () => {
322342 reformulatedQuery . value = null ;
323343 shouldFetchNewDocuments . value = true ;
324344 storedSubject . value = undefined ;
345+ storedConversationId . value = null ;
346+ storedMessageId . value = null ;
325347 clearFromStorage ( 'chat' ) ;
326348 clearFromStorage ( 'chatSources' ) ;
327349 clearFromStorage ( 'questionQueues' ) ;
328350 clearFromStorage ( 'reformulatedQuery' ) ;
329351 clearFromStorage ( 'chatSubject' ) ;
352+ clearFromStorage ( 'chatConversationId' ) ;
353+ clearFromStorage ( 'chatMessageId' ) ;
330354 }
331355
332356 return {
0 commit comments