Placeholder.svelte 1.87 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script lang="ts">
	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}
	<div class="m-auto text-center max-w-md pb-56 px-2">
		<div class="flex justify-center mt-8">
			<div class="flex -space-x-10">
				{#each models as model, modelIdx}
					<button
						on:click={() => {
							selectedModelIdx = modelIdx;
						}}
					>
						{#if model in modelfiles}
							<img
Timothy J. Baek's avatar
Timothy J. Baek committed
30
								src={modelfiles[model]?.imageUrl ?? './favicon.png'}
31
32
								alt="modelfile"
								class=" w-20 mb-2 rounded-full {models.length > 1
Timothy J. Baek's avatar
Timothy J. Baek committed
33
									? ' border-[5px] border-white dark:border-gray-900'
34
35
36
37
38
									: ''}"
								draggable="false"
							/>
						{:else}
							<img
Timothy J. Baek's avatar
Timothy J. Baek committed
39
								src={models.length === 1 ? '/favicon.png' : '/favicon.png'}
40
								class=" w-20 mb-2 {models.length === 1
Timothy J. Baek's avatar
Timothy J. Baek committed
41
42
									? ''
									: 'border-[5px] border-white dark:border-gray-900'}  rounded-full"
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
								alt="ollama"
								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">
						By <a href="https://ollamahub.com/m/{modelfile.user.username}"
							>{modelfile.user.name ? modelfile.user.name : `@${modelfile.user.username}`}</a
						>
					</div>
				{/if}
			{:else}
				How can I help you today?
			{/if}
		</div>
	</div>
{/if}