Personalization.svelte 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <script lang="ts">
  2. import { getBackendConfig } from '$lib/apis';
  3. import { setDefaultPromptSuggestions } from '$lib/apis/configs';
  4. import Switch from '$lib/components/common/Switch.svelte';
  5. import { config, models, settings, user } from '$lib/stores';
  6. import { createEventDispatcher, onMount, getContext, tick } from 'svelte';
  7. import { toast } from 'svelte-sonner';
  8. import ManageModal from './Personalization/ManageModal.svelte';
  9. import Tooltip from '$lib/components/common/Tooltip.svelte';
  10. const dispatch = createEventDispatcher();
  11. const i18n = getContext('i18n');
  12. export let saveSettings: Function;
  13. let showManageModal = false;
  14. // Addons
  15. let enableMemory = true;
  16. onMount(async () => {
  17. let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
  18. enableMemory = settings?.memory ?? true;
  19. });
  20. </script>
  21. <ManageModal bind:show={showManageModal} />
  22. <form
  23. class="flex flex-col h-full justify-between space-y-3 text-sm"
  24. on:submit|preventDefault={() => {
  25. dispatch('save');
  26. }}
  27. >
  28. <div class=" pr-1.5 overflow-y-scroll max-h-[25rem]">
  29. <div>
  30. <div class="flex items-center justify-between mb-1">
  31. <Tooltip
  32. content="This is an experimental feature, it may not function as expected and is subject to change at any time."
  33. >
  34. <div class="text-sm font-medium">
  35. {$i18n.t('Memory')}
  36. <span class=" text-xs text-gray-500">({$i18n.t('Experimental')})</span>
  37. </div>
  38. </Tooltip>
  39. <div class="mt-1">
  40. <Switch
  41. bind:state={enableMemory}
  42. on:change={async () => {
  43. saveSettings({ memory: enableMemory });
  44. }}
  45. />
  46. </div>
  47. </div>
  48. </div>
  49. <div class="text-xs text-gray-600 dark:text-gray-400">
  50. <div>
  51. LLMs will become more helpful as you chat, picking up on details and preferences to tailor
  52. its responses to you.
  53. </div>
  54. <!-- <div class="mt-3">
  55. To understand what LLM remembers or teach it something new, just chat with it:
  56. <div>- “Remember that I like concise responses.”</div>
  57. <div>- “I just got a puppy!”</div>
  58. <div>- “What do you remember about me?”</div>
  59. <div>- “Where did we leave off on my last project?”</div>
  60. </div> -->
  61. </div>
  62. <div class="mt-3 mb-1 ml-1">
  63. <button
  64. type="button"
  65. 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"
  66. on:click={() => {
  67. showManageModal = true;
  68. }}
  69. >
  70. Manage
  71. </button>
  72. </div>
  73. </div>
  74. <div class="flex justify-end text-sm font-medium">
  75. <button
  76. class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
  77. type="submit"
  78. >
  79. {$i18n.t('Save')}
  80. </button>
  81. </div>
  82. </form>