Placeholder.svelte 3.03 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
	export let submitPrompt;

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

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

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

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

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

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

66
				<div in:fade={{ duration: 200, delay: 200 }}>
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
67
					{#if models[selectedModelIdx]?.info?.meta?.description ?? null}
68
						<div class="mt-0.5 text-base font-normal text-gray-500 dark:text-gray-400 line-clamp-3">
69
							{models[selectedModelIdx]?.info?.meta?.description}
70
						</div>
71
						{#if models[selectedModelIdx]?.info?.meta?.user}
72
							<div class="mt-0.5 text-sm font-normal text-gray-400 dark:text-gray-500">
73
74
75
76
77
78
79
80
81
82
83
84
								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}
85
86
87
							</div>
						{/if}
					{:else}
Timothy J. Baek's avatar
Timothy J. Baek committed
88
						<div class=" font-medium text-gray-400 dark:text-gray-500 line-clamp-1">
89
90
91
92
							{$i18n.t('How can I help you today?')}
						</div>
					{/if}
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
93
			</div>
94
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
95

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