Placeholder.svelte 2.09 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
5
6
	import { onMount, getContext } from 'svelte';

	const i18n = getContext('i18n');
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

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

	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}
Timothy J. Baek's avatar
Timothy J. Baek committed
23
	<div class="m-auto text-center max-w-md px-2">
24
		<div class="flex justify-center mt-8">
Timothy J. Baek's avatar
Timothy J. Baek committed
25
			<div class="flex -space-x-4 mb-1">
26
27
28
29
30
31
32
33
				{#each models as model, modelIdx}
					<button
						on:click={() => {
							selectedModelIdx = modelIdx;
						}}
					>
						{#if model in modelfiles}
							<img
34
								src={modelfiles[model]?.imageUrl ?? `${WEBUI_BASE_URL}/static/favicon.png`}
35
								alt="modelfile"
Timothy J. Baek's avatar
Timothy J. Baek committed
36
								class=" w-14 rounded-full border-[1px] border-gray-200 dark:border-none"
37
38
39
40
								draggable="false"
							/>
						{:else}
							<img
41
42
43
								src={models.length === 1
									? `${WEBUI_BASE_URL}/static/favicon.png`
									: `${WEBUI_BASE_URL}/static/favicon.png`}
Timothy J. Baek's avatar
Timothy J. Baek committed
44
45
								class=" w-14 rounded-full border-[1px] border-gray-200 dark:border-none"
								alt="logo"
46
47
48
49
50
51
52
								draggable="false"
							/>
						{/if}
					</button>
				{/each}
			</div>
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
53
		<div class=" mt-2 mb-5 text-2xl text-gray-800 dark:text-gray-100 font-semibold">
54
55
56
57
58
59
60
61
62
			{#if modelfile}
				<span class=" capitalize">
					{modelfile.title}
				</span>
				<div class="mt-0.5 text-base font-normal text-gray-600 dark:text-gray-400">
					{modelfile.desc}
				</div>
				{#if modelfile.user}
					<div class="mt-0.5 text-sm font-normal text-gray-500 dark:text-gray-500">
Timothy J. Baek's avatar
Timothy J. Baek committed
63
						By <a href="https://openwebui.com/m/{modelfile.user.username}"
64
65
66
67
68
							>{modelfile.user.name ? modelfile.user.name : `@${modelfile.user.username}`}</a
						>
					</div>
				{/if}
			{:else}
69
				<div class=" line-clamp-1">{$i18n.t('Hello, {{name}}', { name: $user.name })}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
70

71
				<div>{$i18n.t('How can I help you today?')}</div>
72
73
74
75
			{/if}
		</div>
	</div>
{/if}