Placeholder.svelte 3.11 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
4
	import { marked } from 'marked';

5
	import { config, user, models as _models } from '$lib/stores';
6
	import { onMount, getContext } from 'svelte';
7
8
9

	import { blur, fade } from 'svelte/transition';

Timothy J. Baek's avatar
Timothy J. Baek committed
10
	import Suggestions from '../MessageInput/Suggestions.svelte';
11
12

	const i18n = getContext('i18n');
13

14
	export let modelIds = [];
15
16
	export let models = [];

Timothy J. Baek's avatar
Timothy J. Baek committed
17
18
	export let submitPrompt;

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

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

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

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

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

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

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

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