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

messages do not send anymore. and these errors poped up: index.html:540 Uncaught ReferenceError: updateRegenerateButton is not defined at renderMessages (index.html:540:13) at loadChat (index.html:483:13) at HTMLDivElement.<anonymous> (index.html:385:61) renderMessages @ index.html:540 loadChat @ index.html:483 (anonymous) @ index.html:385 index.html:540 Uncaught (in promise) ReferenceError: updateRegenerateButton is not defined at renderMessages (index.html:540:13) at sendMessage (index.html:568:13) at HTMLFormElement.<anonymous> (index.html:925:13) - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +11 -3
index.html CHANGED
@@ -537,7 +537,6 @@
537
 
538
  chatArea.appendChild(messagesContainer);
539
  chatArea.scrollTop = chatArea.scrollHeight;
540
- updateRegenerateButton();
541
  }
542
 
543
  // Send message
@@ -545,9 +544,13 @@
545
  const message = messageInput.value.trim();
546
  if (!message || !currentChatId) return;
547
 
548
- // Check if we need API key for OpenAI model
549
- const chat = chats.find(c => c.id === currentChatId);
 
 
 
550
  const model = models.find(m => m.id === chat.model);
 
551
 
552
  if (model.type === 'default' && !localStorage.getItem('openaiApiKey')) {
553
  showApiKeyModal();
@@ -592,6 +595,11 @@
592
  const model = models.find(m => m.id === chat.model);
593
  if (!model) throw new Error('Model not found');
594
 
 
 
 
 
 
595
  // Prepare messages for API
596
  const messages = chat.messages.map(msg => ({
597
  role: msg.role,
 
537
 
538
  chatArea.appendChild(messagesContainer);
539
  chatArea.scrollTop = chatArea.scrollHeight;
 
540
  }
541
 
542
  // Send message
 
544
  const message = messageInput.value.trim();
545
  if (!message || !currentChatId) return;
546
 
547
+ // Get current chat
548
+ const chatIndex = chats.findIndex(c => c.id === currentChatId);
549
+ if (chatIndex === -1) return;
550
+
551
+ const chat = chats[chatIndex];
552
  const model = models.find(m => m.id === chat.model);
553
+ if (!model) return;
554
 
555
  if (model.type === 'default' && !localStorage.getItem('openaiApiKey')) {
556
  showApiKeyModal();
 
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,