Placeholder.svelte 2 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
7
8
9
10
11
12
13
14
15
16
17
18
19
20
	import { onMount } from 'svelte';

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

				<div>How can I help you today?</div>
70
71
72
73
			{/if}
		</div>
	</div>
{/if}