{#if history.messages[messageId]} {#if history.messages[messageId].role === 'user'} message.parentId === null) .map((message) => message.id) ?? [])} {showPreviousMessage} {showNextMessage} {editMessage} on:delete={() => deleteMessage(messageId)} {readOnly} /> {:else if (history.messages[history.messages[messageId].parentId]?.models?.length ?? 1) === 1} { console.log('action', e); const message = history.messages[messageId]; if (typeof e.detail === 'string') { await chatActionHandler(chatId, e.detail, message.model, message.id); } else { const { id, event } = e.detail; await chatActionHandler(chatId, id, message.model, message.id, event); } }} on:update={async (e) => { console.log('update', e); updateChatHistory(); }} on:save={async (e) => { console.log('save', e); const message = e.detail; if (message) { history.messages[message.id] = message; await updateChatById(localStorage.token, chatId, { history: history }); } else { await updateChatById(localStorage.token, chatId, { history: history }); } }} {readOnly} /> {:else} { console.log('action', e); const message = history.messages[messageId]; if (typeof e.detail === 'string') { await chatActionHandler(chatId, e.detail, message.model, message.id); } else { const { id, event } = e.detail; await chatActionHandler(chatId, id, message.model, message.id, event); } }} on:update={async (e) => { console.log('update', e); updateChatHistory(); }} on:save={async (e) => { console.log('save', e); const message = e.detail; if (message) { history.messages[message.id] = message; await updateChatById(localStorage.token, chatId, { history: history }); } else { await updateChatById(localStorage.token, chatId, { history: history }); } }} on:change={async () => { await tick(); await updateChatById(localStorage.token, chatId, { history: history }); dispatch('scroll'); }} {readOnly} /> {/if} {/if}