OllamaConnection.svelte 1.6 KB

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