open-webui/src/lib/components/chat/Messages/Placeholder.svelte

92 lines
2.5 KiB
Svelte
Raw Normal View History

2023-12-30 07:03:48 +00:00
<script lang="ts">
2024-02-24 01:12:19 +00:00
import { WEBUI_BASE_URL } from '$lib/constants';
2024-02-25 20:34:32 +00:00
import { user } from '$lib/stores';
2024-03-01 04:40:36 +00:00
import { onMount, getContext } from 'svelte';
2024-04-30 21:56:06 +00:00
import Suggestions from '../MessageInput/Suggestions.svelte';
2024-03-01 04:40:36 +00:00
const i18n = getContext('i18n');
2023-12-30 07:03:48 +00:00
export let models = [];
export let modelfiles = [];
2024-04-30 21:56:06 +00:00
export let submitPrompt;
export let suggestionPrompts;
2023-12-30 07:03:48 +00:00
let modelfile = null;
let selectedModelIdx = 0;
$: modelfile =
models[selectedModelIdx] in modelfiles ? modelfiles[models[selectedModelIdx]] : null;
$: if (models.length > 0) {
selectedModelIdx = models.length - 1;
}
</script>
{#if models.length > 0}
2024-04-30 22:31:50 +00:00
<div class=" text-center py-24 md:py-36">
2024-04-30 21:56:06 +00:00
<div class="m-auto max-w-3xl px-8">
<div class="flex justify-start mt-8">
2024-04-30 22:12:58 +00:00
<div class="flex -space-x-4 mb-0.5">
2024-04-30 21:56:06 +00:00
{#each models as model, modelIdx}
<button
on:click={() => {
selectedModelIdx = modelIdx;
}}
>
{#if model in modelfiles}
<img
src={modelfiles[model]?.imageUrl ?? `${WEBUI_BASE_URL}/static/favicon.png`}
alt="modelfile"
2024-04-30 22:12:58 +00:00
class=" size-[2.7rem] rounded-full border-[1px] border-gray-200 dark:border-none"
2024-04-30 21:56:06 +00:00
draggable="false"
/>
{:else}
<img
src={$i18n.language === 'dg-DG'
? `/doge.png`
: `${WEBUI_BASE_URL}/static/favicon.png`}
2024-04-30 22:12:58 +00:00
class=" size-[2.7rem] rounded-full border-[1px] border-gray-200 dark:border-none"
2024-04-30 21:56:06 +00:00
alt="logo"
draggable="false"
/>
{/if}
</button>
{/each}
</div>
2023-12-30 07:03:48 +00:00
</div>
2024-04-30 21:56:06 +00:00
<div
2024-04-30 21:58:11 +00:00
class=" mt-2 mb-4 text-2xl text-gray-800 dark:text-gray-100 font-semibold text-left flex items-center gap-4"
2024-04-30 21:56:06 +00:00
>
<div>
{#if modelfile}
<span class=" capitalize">
{modelfile.title}
</span>
<div class="mt-0.5 text-base font-normal text-gray-500 dark:text-gray-400">
{modelfile.desc}
</div>
{#if modelfile.user}
<div class="mt-0.5 text-sm font-normal text-gray-400 dark:text-gray-500">
By <a href="https://openwebui.com/m/{modelfile.user.username}"
>{modelfile.user.name ? modelfile.user.name : `@${modelfile.user.username}`}</a
>
</div>
{/if}
{:else}
<div class=" line-clamp-1">{$i18n.t('Hello, {{name}}', { name: $user.name })}</div>
2024-04-30 22:18:58 +00:00
<div class=" font-medium text-gray-400 dark:text-gray-500">
2024-04-30 21:56:06 +00:00
{$i18n.t('How can I help you today?')}
</div>
{/if}
2023-12-30 07:03:48 +00:00
</div>
2024-04-30 21:56:06 +00:00
</div>
2024-02-25 20:34:32 +00:00
2024-04-30 21:56:06 +00:00
<div class=" max-w-full">
<Suggestions {suggestionPrompts} {submitPrompt} />
</div>
2023-12-30 07:03:48 +00:00
</div>
</div>
{/if}