Placeholder.svelte 3.01 KB
Newer Older
1
<script lang="ts">
2
	import { WEBUI_BASE_URL } from '$lib/constants';
3
	import { config, user, models as _models } 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
	export let modelIds = [];
13
14
	export let models = [];

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

18
	let mounted = false;
19
20
	let selectedModelIdx = 0;

21
	$: if (modelIds.length > 0) {
22
23
		selectedModelIdx = models.length - 1;
	}
24

25
26
	$: models = modelIds.map((id) => $_models.find((m) => m.id === id));

27
28
29
	onMount(() => {
		mounted = true;
	});
30
31
</script>

32
{#key mounted}
Timothy J. Baek's avatar
Timothy J. Baek committed
33
	<div class="m-auto w-full max-w-6xl px-8 lg:px-24 pb-16">
Timothy J. Baek's avatar
Timothy J. Baek committed
34
		<div class="flex justify-start">
35
			<div class="flex -space-x-4 mb-1" in:fade={{ duration: 200 }}>
Timothy J. Baek's avatar
Timothy J. Baek committed
36
37
38
39
40
41
				{#each models as model, modelIdx}
					<button
						on:click={() => {
							selectedModelIdx = modelIdx;
						}}
					>
42
43
44
45
46
47
48
49
						<img
							crossorigin="anonymous"
							src={model?.info?.meta?.profile_image_url ??
								($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
50
51
52
					</button>
				{/each}
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
53
54
		</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
55
		<div
Timothy J. Baek's avatar
Timothy J. Baek committed
56
			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
57
58
		>
			<div>
59
				<div class=" capitalize line-clamp-1" in:fade={{ duration: 200 }}>
60
61
					{#if models[selectedModelIdx]?.info}
						{models[selectedModelIdx]?.info?.name}
62
63
					{:else}
						{$i18n.t('Hello, {{name}}', { name: $user.name })}
Timothy J. Baek's avatar
Timothy J. Baek committed
64
					{/if}
65
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
66

67
				<div in:fade={{ duration: 200, delay: 200 }}>
68
					{#if models[selectedModelIdx]?.info}
69
						<div class="mt-0.5 text-base font-normal text-gray-500 dark:text-gray-400">
70
							{models[selectedModelIdx]?.info?.meta?.description}
71
						</div>
72
						{#if models[selectedModelIdx]?.info?.meta?.user}
73
							<div class="mt-0.5 text-sm font-normal text-gray-400 dark:text-gray-500">
74
75
76
77
78
79
80
81
82
83
84
85
								By
								{#if models[selectedModelIdx]?.info?.meta?.user.community}
									<a
										href="https://openwebui.com/m/{models[selectedModelIdx]?.info?.meta?.user
											.username}"
										>{models[selectedModelIdx]?.info?.meta?.user.name
											? models[selectedModelIdx]?.info?.meta?.user.name
											: `@${models[selectedModelIdx]?.info?.meta?.user.username}`}</a
									>
								{:else}
									{models[selectedModelIdx]?.info?.meta?.user.name}
								{/if}
86
87
88
89
90
91
92
93
							</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
94
			</div>
95
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
96

97
		<div class=" w-full" in:fade={{ duration: 200, delay: 300 }}>
98
99
100
101
102
			<Suggestions
				suggestionPrompts={models[selectedModelIdx]?.info?.meta?.suggestion_prompts ??
					$config.default_prompt_suggestions}
				{submitPrompt}
			/>
Timothy J. Baek's avatar
Timothy J. Baek committed
103
		</div>
104
	</div>
105
{/key}