Placeholder.svelte 2.72 KB
Newer Older
1
<script lang="ts">
2
	import { WEBUI_BASE_URL } from '$lib/constants';
Timothy J. Baek's avatar
Timothy J. Baek committed
3
	import { user } from '$lib/stores';
4
	import { onMount, getContext } from 'svelte';
5
6
7

	import { blur, fade } from 'svelte/transition';

Timothy J. Baek's avatar
Timothy J. Baek committed
8
	import Suggestions from '../MessageInput/Suggestions.svelte';
9
10

	const i18n = getContext('i18n');
11
12
13
14

	export let models = [];
	export let modelfiles = [];

Timothy J. Baek's avatar
Timothy J. Baek committed
15
16
17
	export let submitPrompt;
	export let suggestionPrompts;

18
	let mounted = false;
19
20
21
22
23
24
25
26
27
	let modelfile = null;
	let selectedModelIdx = 0;

	$: modelfile =
		models[selectedModelIdx] in modelfiles ? modelfiles[models[selectedModelIdx]] : null;

	$: if (models.length > 0) {
		selectedModelIdx = models.length - 1;
	}
28
29
30
31

	onMount(() => {
		mounted = true;
	});
32
33
</script>

34
{#key mounted}
Timothy J. Baek's avatar
Timothy J. Baek committed
35
36
	<div class="m-auto w-full max-w-3xl px-8 pb-32">
		<div class="flex justify-start">
37
			<div class="flex -space-x-4 mb-1" in:fade={{ duration: 200 }}>
Timothy J. Baek's avatar
Timothy J. Baek committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
				{#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"
								class=" size-[2.7rem] rounded-full border-[1px] border-gray-200 dark:border-none"
								draggable="false"
							/>
						{:else}
							<img
								src={$i18n.language === 'dg-DG'
									? `/doge.png`
									: `${WEBUI_BASE_URL}/static/favicon.png`}
								class=" size-[2.7rem] rounded-full border-[1px] border-gray-200 dark:border-none"
								alt="logo"
								draggable="false"
							/>
Timothy J. Baek's avatar
Timothy J. Baek committed
60
						{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
61
62
63
					</button>
				{/each}
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
64
65
		</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
66
		<div
Timothy J. Baek's avatar
Timothy J. Baek committed
67
			class=" mt-2 mb-4 text-3xl text-gray-800 dark:text-gray-100 font-semibold text-left flex items-center gap-4"
Timothy J. Baek's avatar
Timothy J. Baek committed
68
69
		>
			<div>
70
71
				<div class=" capitalize line-clamp-1" in:fade={{ duration: 200 }}>
					{#if modelfile}
Timothy J. Baek's avatar
Timothy J. Baek committed
72
						{modelfile.title}
73
74
					{:else}
						{$i18n.t('Hello, {{name}}', { name: $user.name })}
Timothy J. Baek's avatar
Timothy J. Baek committed
75
					{/if}
76
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
				<div in:fade={{ duration: 200, delay: 200 }}>
					{#if modelfile}
						<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=" font-medium text-gray-400 dark:text-gray-500">
							{$i18n.t('How can I help you today?')}
						</div>
					{/if}
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
96
			</div>
97
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
98

99
		<div class=" w-full" in:fade={{ duration: 200, delay: 300 }}>
Timothy J. Baek's avatar
Timothy J. Baek committed
100
101
			<Suggestions {suggestionPrompts} {submitPrompt} />
		</div>
102
	</div>
103
{/key}