"backend/vscode:/vscode.git/clone" did not exist on "5eac5c54f8577c50e35a7ce1c64fc70f25fccd07"
Controls.svelte 2.47 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/chat/Controls/Valves.svelte';
Timothy J. Baek's avatar
Timothy J. Baek committed
9
	import FileItem from '$lib/components/common/FileItem.svelte';
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
10
	import Collapsible from '$lib/components/common/Collapsible.svelte';
11

12
13
	import { user } from '$lib/stores';

Timothy J. Baek's avatar
Timothy J. Baek committed
14
	export let models = [];
Timothy J. Baek's avatar
Timothy J. Baek committed
15
16

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

<div class=" dark:text-white">
21
22
23
24
25
26
27
28
29
30
31
	<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
32

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
33
	<div class=" dark:text-gray-200 text-sm font-primary py-0.5">
Timothy J. Baek's avatar
Timothy J. Baek committed
34
		{#if chatFiles.length > 0}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
35
36
			<Collapsible title={$i18n.t('Files')} open={true}>
				<div class="flex flex-col gap-1 mt-1.5" slot="content">
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
37
					{#each chatFiles as file, fileIdx}
Timothy J. Baek's avatar
Timothy J. Baek committed
38
39
40
41
42
						<FileItem
							className="w-full"
							url={`${file?.url}`}
							name={file.name}
							type={file.type}
43
							size={file?.size}
Timothy J. Baek's avatar
Timothy J. Baek committed
44
45
46
							dismissible={true}
							on:dismiss={() => {
								// Remove the file from the chatFiles array
Timothy J. Baek's avatar
fix  
Timothy J. Baek committed
47
48
49

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

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

Timothy J. Baek's avatar
Timothy J. Baek committed
59
60
61
		<Collapsible title={$i18n.t('Valves')}>
			<div class="text-sm mt-1.5" slot="content">
				<Valves />
Timothy J. Baek's avatar
Timothy J. Baek committed
62
			</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
63
		</Collapsible>
Timothy J. Baek's avatar
Timothy J. Baek committed
64

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

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
67
68
		<Collapsible title={$i18n.t('System Prompt')} open={true}>
			<div class=" mt-1.5" slot="content">
69
70
				<textarea
					bind:value={params.system}
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
71
72
					class="w-full rounded-lg px-3.5 py-2.5 text-sm dark:text-gray-300 dark:bg-gray-850 border border-gray-100 dark:border-gray-800 outline-none resize-none"
					rows="4"
Karl Lee's avatar
Karl Lee committed
73
					placeholder={$i18n.t('Enter system prompt')}
74
75
				/>
			</div>
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
76
		</Collapsible>
Timothy J. Baek's avatar
Timothy J. Baek committed
77

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

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
80
81
82
		<Collapsible title={$i18n.t('Advanced Params')} open={true}>
			<div class="text-sm mt-1.5" slot="content">
				<div>
83
					<AdvancedParams admin={$user?.role === 'admin'} bind:params />
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
84
				</div>
85
			</div>
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
86
		</Collapsible>
87
	</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
88
</div>