{#key message.id}
{model?.name ?? message.model} {#if message.timestamp}
{dayjs(message.timestamp * 1000).format($i18n.t('h:mm a'))}
{/if}
{#if (message?.files ?? []).filter((f) => f.type === 'image').length > 0}
{#each message.files as file}
{#if file.type === 'image'}
{/if}
{/each}
{/if}
{#if message?.status}
{#if message?.status?.done === false}
{/if} {#if message?.status?.action === 'web_search' && message?.status?.urls}
{message.status.description}
{:else}
{message.status.description}
{/if}
{/if} {#if edit === true}
{ e.target.style.height = ''; e.target.style.height = `${e.target.scrollHeight}px`; }} />
{ cancelEditMessage(); }} > {$i18n.t('Cancel')}
{ editMessageConfirmHandler(); }} > {$i18n.t('Save')}
{:else}
{#if message?.error === true}
{message.content}
{:else if message.content === ''}
{:else} {#each tokens as token, tokenIdx} {#if token.type === 'code'}
{:else} {@html marked.parse(token.raw, { ...defaults, gfm: true, breaks: true, renderer })} {/if} {/each} {/if} {#if message.citations}
{#each message.citations.reduce((acc, citation) => { citation.document.forEach((document, index) => { const metadata = citation.metadata?.[index]; const id = metadata?.source ?? 'N/A'; let source = citation?.source; // Check if ID looks like a URL if (id.startsWith('http://') || id.startsWith('https://')) { source = { name: id }; } const existingSource = acc.find((item) => item.id === id); if (existingSource) { existingSource.document.push(document); existingSource.metadata.push(metadata); } else { acc.push( { id: id, source: source, document: [document], metadata: metadata ? [metadata] : [] } ); } }); return acc; }, []) as citation, idx}
{ showCitationModal = true; selectedCitation = citation; }} >
{idx + 1}
{citation.source.name}
{/each}
{/if} {#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}
{ editMessageHandler(); }} >
{/if}
{ copyToClipboard(message.content); }} >
{ if (!loadingSpeech) { toggleSpeakMessage(message); } }} > {#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.info}
{ console.log(message); }} id="info-{message.id}" >
{/if} {#if !readOnly}
{ rateMessage(message.id, 1); showRateComment = true; window.setTimeout(() => { document .getElementById(`message-feedback-${message.id}`) ?.scrollIntoView(); }, 0); }} >
{ rateMessage(message.id, -1); showRateComment = true; window.setTimeout(() => { document .getElementById(`message-feedback-${message.id}`) ?.scrollIntoView(); }, 0); }} >
{/if} {#if isLastMessage && !readOnly}
{ continueGeneration(); }} >
{ regenerateResponse(message); }} >
{/if} {/if}
{/if} {#if message.done && showRateComment}
{ updateChatMessages(); }} /> {/if}
{/if}
{/key}