kokofixcomputers commited on
Commit
6a52ec8
·
verified ·
1 Parent(s): 803064a

index.html:634 API Error: ReferenceError: Cannot access 'chat' before initialization at index.html:595:57 at Array.find (<anonymous>) at sendMessage (index.html:595:38) at HTMLFormElement.<anonymous> (index.html:933:13) i cannot send any message this happens - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +8 -8
index.html CHANGED
@@ -591,17 +591,17 @@
591
  chatArea.scrollTop = chatArea.scrollHeight;
592
 
593
  try {
594
- // Get the current model
595
- const model = models.find(m => m.id === chat.model);
596
- if (!model) throw new Error('Model not found');
597
-
598
- // Ensure we have the latest chat reference
599
  const chatIndex = chats.findIndex(c => c.id === currentChatId);
600
  if (chatIndex === -1) throw new Error('Chat not found');
601
- const chat = chats[chatIndex];
 
 
 
 
602
 
603
  // Prepare messages for API
604
- const messages = chat.messages.map(msg => ({
605
  role: msg.role,
606
  content: msg.content
607
  }));
@@ -624,7 +624,7 @@
624
  timestamp: new Date().toISOString()
625
  };
626
 
627
- chat.messages.push(assistantMessage);
628
  saveChats();
629
  renderMessages(chat.messages);
630
 
 
591
  chatArea.scrollTop = chatArea.scrollHeight;
592
 
593
  try {
594
+ // Ensure we have the latest chat reference first
 
 
 
 
595
  const chatIndex = chats.findIndex(c => c.id === currentChatId);
596
  if (chatIndex === -1) throw new Error('Chat not found');
597
+ const currentChat = chats[chatIndex];
598
+
599
+ // Get the current model
600
+ const model = models.find(m => m.id === currentChat.model);
601
+ if (!model) throw new Error('Model not found');
602
 
603
  // Prepare messages for API
604
+ const messages = currentChat.messages.map(msg => ({
605
  role: msg.role,
606
  content: msg.content
607
  }));
 
624
  timestamp: new Date().toISOString()
625
  };
626
 
627
+ currentChat.messages.push(assistantMessage);
628
  saveChats();
629
  renderMessages(chat.messages);
630