OllamaConnection.svelte 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <script lang="ts">
  2. import { getContext, tick } from 'svelte';
  3. const i18n = getContext('i18n');
  4. import Tooltip from '$lib/components/common/Tooltip.svelte';
  5. import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
  6. import AddConnectionModal from './AddConnectionModal.svelte';
  7. import Cog6 from '$lib/components/icons/Cog6.svelte';
  8. import Wrench from '$lib/components/icons/Wrench.svelte';
  9. import ManageOllamaModal from './ManageOllamaModal.svelte';
  10. export let onDelete = () => {};
  11. export let onSubmit = () => {};
  12. export let url = '';
  13. export let idx = 0;
  14. export let config = {};
  15. let showManageModal = false;
  16. let showConfigModal = false;
  17. </script>
  18. <AddConnectionModal
  19. ollama
  20. edit
  21. bind:show={showConfigModal}
  22. connection={{
  23. url,
  24. key: config?.key ?? '',
  25. config: config
  26. }}
  27. {onDelete}
  28. onSubmit={(connection) => {
  29. url = connection.url;
  30. config = { ...connection.config, key: connection.key };
  31. onSubmit(connection);
  32. }}
  33. />
  34. <ManageOllamaModal bind:show={showManageModal} urlIdx={idx} />
  35. <div class="flex gap-1.5">
  36. <Tooltip
  37. className="w-full relative"
  38. content={$i18n.t(`WebUI will make requests to "{{url}}/api/chat"`, {
  39. url
  40. })}
  41. placement="top-start"
  42. >
  43. {#if !(config?.enable ?? true)}
  44. <div
  45. class="absolute top-0 bottom-0 left-0 right-0 opacity-60 bg-white dark:bg-gray-900 z-10"
  46. ></div>
  47. {/if}
  48. <input
  49. class="w-full text-sm bg-transparent outline-none"
  50. placeholder={$i18n.t('Enter URL (e.g. http://localhost:11434)')}
  51. bind:value={url}
  52. />
  53. </Tooltip>
  54. <div class="flex gap-1">
  55. <Tooltip content={$i18n.t('Manage')} className="self-start">
  56. <button
  57. class="self-center p-1 bg-transparent hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-850 rounded-lg transition"
  58. on:click={() => {
  59. showManageModal = true;
  60. }}
  61. type="button"
  62. >
  63. <Wrench />
  64. </button>
  65. </Tooltip>
  66. <Tooltip content={$i18n.t('Configure')} className="self-start">
  67. <button
  68. class="self-center p-1 bg-transparent hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-850 rounded-lg transition"
  69. on:click={() => {
  70. showConfigModal = true;
  71. }}
  72. type="button"
  73. >
  74. <Cog6 />
  75. </button>
  76. </Tooltip>
  77. </div>
  78. </div>