Placeholder.svelte 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <script lang="ts">
  2. import { WEBUI_BASE_URL } from '$lib/constants';
  3. import { user } from '$lib/stores';
  4. import { onMount } from 'svelte';
  5. export let models = [];
  6. export let modelfiles = [];
  7. let modelfile = null;
  8. let selectedModelIdx = 0;
  9. $: modelfile =
  10. models[selectedModelIdx] in modelfiles ? modelfiles[models[selectedModelIdx]] : null;
  11. $: if (models.length > 0) {
  12. selectedModelIdx = models.length - 1;
  13. }
  14. </script>
  15. {#if models.length > 0}
  16. <div class="m-auto text-center max-w-md px-2">
  17. <div class="flex justify-center mt-8">
  18. <div class="flex -space-x-4 mb-1">
  19. {#each models as model, modelIdx}
  20. <button
  21. on:click={() => {
  22. selectedModelIdx = modelIdx;
  23. }}
  24. >
  25. {#if model in modelfiles}
  26. <img
  27. src={modelfiles[model]?.imageUrl ?? `${WEBUI_BASE_URL}/static/favicon.png`}
  28. alt="modelfile"
  29. class=" w-14 rounded-full border-[1px] border-gray-200 dark:border-none"
  30. draggable="false"
  31. />
  32. {:else}
  33. <img
  34. src={models.length === 1
  35. ? `${WEBUI_BASE_URL}/static/favicon.png`
  36. : `${WEBUI_BASE_URL}/static/favicon.png`}
  37. class=" w-14 rounded-full border-[1px] border-gray-200 dark:border-none"
  38. alt="logo"
  39. draggable="false"
  40. />
  41. {/if}
  42. </button>
  43. {/each}
  44. </div>
  45. </div>
  46. <div class=" mt-2 mb-5 text-2xl text-gray-800 dark:text-gray-100 font-semibold">
  47. {#if modelfile}
  48. <span class=" capitalize">
  49. {modelfile.title}
  50. </span>
  51. <div class="mt-0.5 text-base font-normal text-gray-600 dark:text-gray-400">
  52. {modelfile.desc}
  53. </div>
  54. {#if modelfile.user}
  55. <div class="mt-0.5 text-sm font-normal text-gray-500 dark:text-gray-500">
  56. By <a href="https://openwebui.com/m/{modelfile.user.username}"
  57. >{modelfile.user.name ? modelfile.user.name : `@${modelfile.user.username}`}</a
  58. >
  59. </div>
  60. {/if}
  61. {:else}
  62. <div class=" line-clamp-1">Hello, {$user.name}</div>
  63. <div>How can I help you today?</div>
  64. {/if}
  65. </div>
  66. </div>
  67. {/if}