open-webui/src/lib/components/chat/Messages/Message.svelte
Timothy J. Baek 02269a21a9
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Integration Test / Run Cypress Integration Tests (push) Waiting to run
Integration Test / Run Migration Tests (push) Waiting to run
refac
2024-11-06 02:58:44 -08:00

105 lines
2.6 KiB
Svelte

<script lang="ts">
import { toast } from 'svelte-sonner';
import { tick, getContext, onMount, createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
const i18n = getContext('i18n');
import { settings } from '$lib/stores';
import { copyToClipboard } from '$lib/utils';
import MultiResponseMessages from './MultiResponseMessages.svelte';
import ResponseMessage from './ResponseMessage.svelte';
import UserMessage from './UserMessage.svelte';
export let chatId;
export let idx = 0;
export let history;
export let messageId;
export let user;
export let showPreviousMessage;
export let showNextMessage;
export let updateChat;
export let editMessage;
export let saveMessage;
export let deleteMessage;
export let rateMessage;
export let actionMessage;
export let submitMessage;
export let regenerateResponse;
export let continueResponse;
export let mergeResponses;
export let triggerScroll;
export let readOnly = false;
</script>
<div
class="flex flex-col justify-between px-5 mb-3 w-full {($settings?.widescreenMode ?? null)
? 'max-w-full'
: 'max-w-5xl'} mx-auto rounded-lg group"
>
{#if history.messages[messageId]}
{#if history.messages[messageId].role === 'user'}
<UserMessage
{user}
{history}
{messageId}
isFirstMessage={idx === 0}
siblings={history.messages[messageId].parentId !== null
? (history.messages[history.messages[messageId].parentId]?.childrenIds ?? [])
: (Object.values(history.messages)
.filter((message) => message.parentId === null)
.map((message) => message.id) ?? [])}
{showPreviousMessage}
{showNextMessage}
{editMessage}
{deleteMessage}
{readOnly}
/>
{:else if (history.messages[history.messages[messageId].parentId]?.models?.length ?? 1) === 1}
<ResponseMessage
{chatId}
{history}
{messageId}
isLastMessage={messageId === history.currentId}
siblings={history.messages[history.messages[messageId].parentId]?.childrenIds ?? []}
{showPreviousMessage}
{showNextMessage}
{updateChat}
{editMessage}
{saveMessage}
{rateMessage}
{actionMessage}
{submitMessage}
{continueResponse}
{regenerateResponse}
{readOnly}
/>
{:else}
<MultiResponseMessages
bind:history
{chatId}
{messageId}
isLastMessage={messageId === history?.currentId}
{updateChat}
{editMessage}
{saveMessage}
{rateMessage}
{actionMessage}
{submitMessage}
{continueResponse}
{regenerateResponse}
{mergeResponses}
{triggerScroll}
{readOnly}
/>
{/if}
{/if}
</div>