{#each Object.keys(groupedMessages) as model} {#if groupedMessagesIdx[model] !== undefined && groupedMessages[model].messages.length > 0}
{ currentMessageId = groupedMessages[model].messages[groupedMessagesIdx[model]].id; let messageId = groupedMessages[model].messages[groupedMessagesIdx[model]].id; console.log(messageId); let messageChildrenIds = history.messages[messageId].childrenIds; while (messageChildrenIds.length !== 0) { messageId = messageChildrenIds.at(-1); messageChildrenIds = history.messages[messageId].childrenIds; } history.currentId = messageId; dispatch('change'); }} > m.id)} isLastMessage={true} {updateChatMessages} {confirmEditResponseMessage} showPreviousMessage={() => { groupedMessagesIdx[model] = Math.max(0, groupedMessagesIdx[model] - 1); let messageId = groupedMessages[model].messages[groupedMessagesIdx[model]].id; console.log(messageId); let messageChildrenIds = history.messages[messageId].childrenIds; while (messageChildrenIds.length !== 0) { messageId = messageChildrenIds.at(-1); messageChildrenIds = history.messages[messageId].childrenIds; } history.currentId = messageId; dispatch('change'); }} showNextMessage={() => { groupedMessagesIdx[model] = Math.min( groupedMessages[model].messages.length - 1, groupedMessagesIdx[model] + 1 ); let messageId = groupedMessages[model].messages[groupedMessagesIdx[model]].id; console.log(messageId); let messageChildrenIds = history.messages[messageId].childrenIds; while (messageChildrenIds.length !== 0) { messageId = messageChildrenIds.at(-1); messageChildrenIds = history.messages[messageId].childrenIds; } history.currentId = messageId; dispatch('change'); }} {rateMessage} {copyToClipboard} {continueGeneration} regenerateResponse={async (model) => { regenerateResponse(model); await tick(); groupedMessagesIdx[model] = groupedMessages[model].messages.length - 1; }} on:save={async (e) => { console.log('save', e); const message = e.detail; history.messages[message.id] = message; await updateChatById(localStorage.token, chatId, { messages: messages, history: history }); }} />
{/if} {/each}