Girish Jeswani commited on
Commit
eff2f84
·
1 Parent(s): e4e2554

fix data mismatch

Browse files
phd-advisor-frontend/src/pages/ChatPage.js CHANGED
@@ -181,7 +181,8 @@ const loadChatSession = async (sessionId) => {
181
  // Load the messages from the synced context
182
  const formattedMessages = result.context.messages.map(msg => ({
183
  ...msg,
184
- timestamp: new Date(msg.timestamp)
 
185
  }));
186
 
187
  setMessages(formattedMessages);
@@ -423,7 +424,7 @@ const handleNewChat = async (sessionId = null) => {
423
  const newResponses = data.responses.map(response => ({
424
  id: generateMessageId(),
425
  type: 'advisor',
426
- advisor: response.persona_id,
427
  content: response.content,
428
  timestamp: new Date(),
429
  advisorName: response.persona_name || response.persona_id,
@@ -497,7 +498,7 @@ const handleNewChat = async (sessionId = null) => {
497
  },
498
  body: JSON.stringify({
499
  user_input: inputMessage,
500
- advisor_id: replyContext.persona_id,
501
  original_message_id: replyContext.messageId,
502
  chat_session_id: sessionId // Use confirmed session ID
503
  }),
@@ -513,7 +514,7 @@ const handleNewChat = async (sessionId = null) => {
513
  const replyResponseMessage = {
514
  id: generateMessageId(),
515
  type: 'advisor',
516
- advisorId: data.persona_id,
517
  advisorName: data.persona,
518
  content: data.response,
519
  isReply: true,
@@ -595,7 +596,7 @@ const handleNewChat = async (sessionId = null) => {
595
  const expandedMessage = {
596
  id: generateMessageId(),
597
  type: 'advisor',
598
- advisorId: advisorId,
599
  advisorName: advisor.name,
600
  content: data.response,
601
  isExpansion: true,
@@ -642,7 +643,8 @@ const handleNewChat = async (sessionId = null) => {
642
  setReplyingTo({
643
  advisorId: message.persona_id,
644
  messageId: message.id,
645
- advisorName: advisor.name
 
646
  });
647
  };
648
 
@@ -652,7 +654,8 @@ const handleNewChat = async (sessionId = null) => {
652
  setReplyingTo({
653
  advisorId: message.persona_id,
654
  messageId: message.id,
655
- advisorName: advisor.name
 
656
  });
657
  }
658
  };
 
181
  // Load the messages from the synced context
182
  const formattedMessages = result.context.messages.map(msg => ({
183
  ...msg,
184
+ timestamp: new Date(msg.timestamp),
185
+ persona_id: msg.persona_id || msg.advisor || msg.advisorId
186
  }));
187
 
188
  setMessages(formattedMessages);
 
424
  const newResponses = data.responses.map(response => ({
425
  id: generateMessageId(),
426
  type: 'advisor',
427
+ persona_id: response.persona_id,
428
  content: response.content,
429
  timestamp: new Date(),
430
  advisorName: response.persona_name || response.persona_id,
 
498
  },
499
  body: JSON.stringify({
500
  user_input: inputMessage,
501
+ advisor_id: replyContext.advisorId,
502
  original_message_id: replyContext.messageId,
503
  chat_session_id: sessionId // Use confirmed session ID
504
  }),
 
514
  const replyResponseMessage = {
515
  id: generateMessageId(),
516
  type: 'advisor',
517
+ persona_id: data.persona_id,
518
  advisorName: data.persona,
519
  content: data.response,
520
  isReply: true,
 
596
  const expandedMessage = {
597
  id: generateMessageId(),
598
  type: 'advisor',
599
+ persona_id: advisorId,
600
  advisorName: advisor.name,
601
  content: data.response,
602
  isExpansion: true,
 
643
  setReplyingTo({
644
  advisorId: message.persona_id,
645
  messageId: message.id,
646
+ advisorName: advisor.name,
647
+ persona_id: message.persona_id
648
  });
649
  };
650
 
 
654
  setReplyingTo({
655
  advisorId: message.persona_id,
656
  messageId: message.id,
657
+ advisorName: advisor.name,
658
+ persona_id: message.persona_id
659
  });
660
  }
661
  };