Controls.svelte 2.33 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
<script>
2
	import { createEventDispatcher, getContext } from 'svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
3
	const dispatch = createEventDispatcher();
4
5
	const i18n = getContext('i18n');

Timothy J. Baek's avatar
Timothy J. Baek committed
6
	import XMark from '$lib/components/icons/XMark.svelte';
7
	import AdvancedParams from '../Settings/Advanced/AdvancedParams.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
8
	import Valves from '$lib/components/common/Valves.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
9
	import FileItem from '$lib/components/common/FileItem.svelte';
10

Timothy J. Baek's avatar
Timothy J. Baek committed
11
	export let models = [];
Timothy J. Baek's avatar
Timothy J. Baek committed
12
13

	export let chatFiles = [];
Timothy J. Baek's avatar
Timothy J. Baek committed
14
	export let valves = {};
15
	export let params = {};
Timothy J. Baek's avatar
Timothy J. Baek committed
16
17
18
</script>

<div class=" dark:text-white">
19
20
21
22
23
24
25
26
27
28
29
	<div class=" flex justify-between dark:text-gray-100 mb-2">
		<div class=" text-lg font-medium self-center font-primary">{$i18n.t('Chat Controls')}</div>
		<button
			class="self-center"
			on:click={() => {
				dispatch('close');
			}}
		>
			<XMark className="size-4" />
		</button>
	</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
30

31
	<div class=" dark:text-gray-200 text-sm font-primary">
Timothy J. Baek's avatar
Timothy J. Baek committed
32
33
34
35
		{#if chatFiles.length > 0}
			<div>
				<div class="mb-1.5 font-medium">{$i18n.t('Files')}</div>

Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
36
37
				<div class="flex flex-col gap-1">
					{#each chatFiles as file, fileIdx}
Timothy J. Baek's avatar
Timothy J. Baek committed
38
39
40
41
42
43
44
45
						<FileItem
							className="w-full"
							url={`${file?.url}`}
							name={file.name}
							type={file.type}
							dismissible={true}
							on:dismiss={() => {
								// Remove the file from the chatFiles array
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
46
47
48

								chatFiles.splice(fileIdx, 1);
								chatFiles = chatFiles;
Timothy J. Baek's avatar
Timothy J. Baek committed
49
50
51
52
53
54
55
56
57
							}}
						/>
					{/each}
				</div>
			</div>

			<hr class="my-2 border-gray-100 dark:border-gray-800" />
		{/if}

Timothy J. Baek's avatar
Timothy J. Baek committed
58
59
		{#if models.length === 1 && models[0]?.pipe?.valves_spec}
			<div>
Timothy J. Baek's avatar
Timothy J. Baek committed
60
				<div class=" font-medium">{$i18n.t('Valves')}</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
61
62
63
64
65
66
67
68
69

				<div>
					<Valves valvesSpec={models[0]?.pipe?.valves_spec} bind:valves />
				</div>
			</div>

			<hr class="my-2 border-gray-100 dark:border-gray-800" />
		{/if}

Timothy J. Baek's avatar
Timothy J. Baek committed
70
		<div>
Karl Lee's avatar
Karl Lee committed
71
			<div class="mb-1.5 font-medium">{$i18n.t('System Prompt')}</div>
72
73
74
75

			<div>
				<textarea
					bind:value={params.system}
Timothy J. Baek's avatar
Timothy J. Baek committed
76
					class="w-full rounded-lg px-4 py-3 text-sm dark:text-gray-300 dark:bg-gray-850 border border-gray-100 dark:border-gray-800 outline-none resize-none"
77
					rows="3"
Karl Lee's avatar
Karl Lee committed
78
					placeholder={$i18n.t('Enter system prompt')}
79
80
				/>
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
81
82
		</div>

Timothy J. Baek's avatar
Timothy J. Baek committed
83
		<hr class="my-2 border-gray-100 dark:border-gray-800" />
84
85

		<div>
Karl Lee's avatar
Karl Lee committed
86
			<div class="mb-1.5 font-medium">{$i18n.t('Advanced Params')}</div>
87
88
89
90
91
92

			<div>
				<AdvancedParams bind:params />
			</div>
		</div>
	</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
93
</div>