Personalization.svelte 2.64 KB
Newer Older
1
2
3
4
5
6
7
<script lang="ts">
	import { getBackendConfig } from '$lib/apis';
	import { setDefaultPromptSuggestions } from '$lib/apis/configs';
	import Switch from '$lib/components/common/Switch.svelte';
	import { config, models, settings, user } from '$lib/stores';
	import { createEventDispatcher, onMount, getContext, tick } from 'svelte';
	import { toast } from 'svelte-sonner';
Timothy J. Baek's avatar
Timothy J. Baek committed
8
9
	import ManageModal from './Personalization/ManageModal.svelte';
	import Tooltip from '$lib/components/common/Tooltip.svelte';
10
11
12
13
14
15
	const dispatch = createEventDispatcher();

	const i18n = getContext('i18n');

	export let saveSettings: Function;

Timothy J. Baek's avatar
Timothy J. Baek committed
16
17
	let showManageModal = false;

18
	// Addons
19
	let enableMemory = false;
20
21

	onMount(async () => {
22
		enableMemory = $settings?.memory ?? false;
23
24
25
	});
</script>

Timothy J. Baek's avatar
Timothy J. Baek committed
26
27
<ManageModal bind:show={showManageModal} />

28
29
30
31
32
33
34
35
36
<form
	class="flex flex-col h-full justify-between space-y-3 text-sm"
	on:submit|preventDefault={() => {
		dispatch('save');
	}}
>
	<div class="  pr-1.5 overflow-y-scroll max-h-[25rem]">
		<div>
			<div class="flex items-center justify-between mb-1">
Timothy J. Baek's avatar
Timothy J. Baek committed
37
38
39
40
41
42
43
44
45
				<Tooltip
					content="This is an experimental feature, it may not function as expected and is subject to change at any time."
				>
					<div class="text-sm font-medium">
						{$i18n.t('Memory')}

						<span class=" text-xs text-gray-500">({$i18n.t('Experimental')})</span>
					</div>
				</Tooltip>
46
47
48
49
50
51
52
53
54
55
56
57
58
59

				<div class="mt-1">
					<Switch
						bind:state={enableMemory}
						on:change={async () => {
							saveSettings({ memory: enableMemory });
						}}
					/>
				</div>
			</div>
		</div>

		<div class="text-xs text-gray-600 dark:text-gray-400">
			<div>
Timothy J. Baek's avatar
Timothy J. Baek committed
60
61
				You can personalize your interactions with LLMs by adding memories through the 'Manage'
				button below, making them more helpful and tailored to you.
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
			</div>

			<!-- <div class="mt-3">
				To understand what LLM remembers or teach it something new, just chat with it:

				<div>- “Remember that I like concise responses.”</div>
				<div>- “I just got a puppy!”</div>
				<div>- “What do you remember about me?”</div>
				<div>- “Where did we leave off on my last project?”</div>
			</div> -->
		</div>

		<div class="mt-3 mb-1 ml-1">
			<button
				type="button"
77
				class=" px-3.5 py-1.5 font-medium hover:bg-black/5 dark:hover:bg-white/5 outline outline-1 outline-gray-300 dark:outline-gray-800 rounded-3xl"
Timothy J. Baek's avatar
Timothy J. Baek committed
78
79
80
				on:click={() => {
					showManageModal = true;
				}}
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
			>
				Manage
			</button>
		</div>
	</div>

	<div class="flex justify-end text-sm font-medium">
		<button
			class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
			type="submit"
		>
			{$i18n.t('Save')}
		</button>
	</div>
</form>