{#key message.id}
{model?.name ?? message.model}
{#if message.timestamp}
{dayjs(message.timestamp * 1000).format($i18n.t('h:mm a'))}
{/if}
{#if message?.files && message.files?.filter((f) => f.type === 'image').length > 0}
{#each message.files as file}
{#if file.type === 'image'}
{/if}
{/each}
{/if}
{#if (message?.statusHistory ?? [...(message?.status ? [message?.status] : [])]).length > 0} {@const status = ( message?.statusHistory ?? [...(message?.status ? [message?.status] : [])] ).at(-1)} {#if !status?.hidden}
{#if status?.done === false}
{/if} {#if status?.action === 'web_search' && status?.urls}
{#if status?.description.includes('{{count}}')} {$i18n.t(status?.description, { count: status?.urls.length })} {:else if status?.description === 'No search query generated'} {$i18n.t('No search query generated')} {:else if status?.description === 'Generating search query'} {$i18n.t('Generating search query')} {:else} {status?.description} {/if}
{:else if status?.action === 'knowledge_search'}
{$i18n.t(`Searching Knowledge for "{{searchQuery}}"`, { searchQuery: status.query })}
{:else}
{#if status?.description.includes('{{searchQuery}}')} {$i18n.t(status?.description, { searchQuery: status?.query })} {:else if status?.description === 'No search query generated'} {$i18n.t('No search query generated')} {:else if status?.description === 'Generating search query'} {$i18n.t('Generating search query')} {:else} {status?.description} {/if}
{/if}
{/if} {/if} {#if edit === true}
{ e.target.style.height = ''; e.target.style.height = `${e.target.scrollHeight}px`; }} on:keydown={(e) => { if (e.key === 'Escape') { document.getElementById('close-edit-message-button')?.click(); } const isCmdOrCtrlPressed = e.metaKey || e.ctrlKey; const isEnterPressed = e.key === 'Enter'; if (isCmdOrCtrlPressed && isEnterPressed) { document.getElementById('confirm-edit-message-button')?.click(); } }} />
{ saveAsCopyHandler(); }} > {$i18n.t('Save As Copy')}
{ cancelEditMessage(); }} > {$i18n.t('Cancel')}
{ editMessageConfirmHandler(); }} > {$i18n.t('Save')}
{:else}
{#if message.content === '' && !message.error}
{:else if message.content && message.error !== true}
{ console.log(e); const sourceButton = document.getElementById(`source-${e}`); if (sourceButton) { sourceButton.click(); } }} onAddMessages={({ modelId, parentId, messages }) => { addMessages({ modelId, parentId, messages }); }} on:update={(e) => { const { raw, oldContent, newContent } = e.detail; history.messages[message.id].content = history.messages[ message.id ].content.replace(raw, raw.replace(oldContent, newContent)); updateChat(); }} on:select={(e) => { const { type, content } = e.detail; if (type === 'explain') { submitMessage( message.id, `Explain this section to me in more detail\n\n\`\`\`\n${content}\n\`\`\`` ); } else if (type === 'ask') { const input = e.detail?.input ?? ''; submitMessage(message.id, `\`\`\`\n${content}\n\`\`\`\n${input}`); } }} /> {/if} {#if message?.error}
{/if} {#if (message?.sources || message?.citations) && (model?.info?.meta?.capabilities?.citations ?? true)}
{/if} {#if message.code_executions}
{/if}
{/if}
{#if !edit} {#if message.done || siblings.length > 1}
{#if siblings.length > 1}
{ showPreviousMessage(message); }} >
{siblings.indexOf(message.id) + 1}/{siblings.length}
{ showNextMessage(message); }} >
{/if} {#if message.done} {#if !readOnly} {#if $user.role === 'user' ? ($user?.permissions?.chat?.edit ?? true) : true}
{ editMessageHandler(); }} >
{/if} {/if}
{ copyToClipboard(message.content); }} >
{ if (!loadingSpeech) { toggleSpeakMessage(); } }} > {#if loadingSpeech}
{:else if speaking}
{:else}
{/if}
{#if $config?.features.enable_image_generation && !readOnly}
{ if (!generatingImage) { generateImage(message); } }} > {#if generatingImage}
{:else}
{/if}
{/if} {#if message.usage}
${sanitizeResponseContent( JSON.stringify(message.usage, null, 2) .replace(/"([^(")"]+)":/g, '$1:') .slice(1, -1) .split('\n') .map((line) => line.slice(2)) .map((line) => (line.endsWith(',') ? line.slice(0, -1) : line)) .join('\n') )}` : ''} placement="bottom" >
{ console.log(message); }} id="info-{message.id}" >
{/if} {#if !readOnly} {#if $config?.features.enable_message_rating ?? true}
{ await feedbackHandler(1); window.setTimeout(() => { document .getElementById(`message-feedback-${message.id}`) ?.scrollIntoView(); }, 0); }} >
{ await feedbackHandler(-1); window.setTimeout(() => { document .getElementById(`message-feedback-${message.id}`) ?.scrollIntoView(); }, 0); }} >
{/if} {#if isLastMessage}
{ continueResponse(); }} >
{/if}
{ showRateComment = false; regenerateResponse(message); (model?.actions ?? []).forEach((action) => { dispatch('action', { id: action.id, event: { id: 'regenerate-response', data: { messageId: message.id } } }); }); }} >
{#if isLastMessage} {#each model?.actions ?? [] as action}
{ actionMessage(action.id, message); }} > {#if action.icon_url}
{:else}
{/if}
{/each} {/if} {/if} {/if}
{/if} {#if message.done && showRateComment}
{ await feedbackHandler(null, { ...e.detail }); }} /> {/if} {/if}
{/key}