Personalization.svelte 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 = false;
  16. onMount(async () => {
  17. enableMemory = $settings?.memory ?? false;
  18. });
  19. </script>
  20. <ManageModal bind:show={showManageModal} />
  21. <form
  22. class="flex flex-col h-full justify-between space-y-3 text-sm"
  23. on:submit|preventDefault={() => {
  24. dispatch('save');
  25. }}
  26. >
  27. <div class=" pr-1.5 overflow-y-scroll max-h-[25rem]">
  28. <div>
  29. <div class="flex items-center justify-between mb-1">
  30. <Tooltip
  31. content="This is an experimental feature, it may not function as expected and is subject to change at any time."
  32. >
  33. <div class="text-sm font-medium">
  34. {$i18n.t('Memory')}
  35. <span class=" text-xs text-gray-500">({$i18n.t('Experimental')})</span>
  36. </div>
  37. </Tooltip>
  38. <div class="mt-1">
  39. <Switch
  40. bind:state={enableMemory}
  41. on:change={async () => {
  42. saveSettings({ memory: enableMemory });
  43. }}
  44. />
  45. </div>
  46. </div>
  47. </div>
  48. <div class="text-xs text-gray-600 dark:text-gray-400">
  49. <div>
  50. You can personalize your interactions with LLMs by adding memories through the 'Manage'
  51. button below, making them more helpful and tailored to you.
  52. </div>
  53. <!-- <div class="mt-3">
  54. To understand what LLM remembers or teach it something new, just chat with it:
  55. <div>- “Remember that I like concise responses.”</div>
  56. <div>- “I just got a puppy!”</div>
  57. <div>- “What do you remember about me?”</div>
  58. <div>- “Where did we leave off on my last project?”</div>
  59. </div> -->
  60. </div>
  61. <div class="mt-3 mb-1 ml-1">
  62. <button
  63. type="button"
  64. 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"
  65. on:click={() => {
  66. showManageModal = true;
  67. }}
  68. >
  69. Manage
  70. </button>
  71. </div>
  72. </div>
  73. <div class="flex justify-end text-sm font-medium">
  74. <button
  75. class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
  76. type="submit"
  77. >
  78. {$i18n.t('Save')}
  79. </button>
  80. </div>
  81. </form>