|
3 | 3 |
|
4 | 4 | import { createEventDispatcher, tick } from "svelte";
|
5 | 5 |
|
6 |
| - import { FEATUED_MODELS_IDS } from "./inferencePlaygroundUtils"; |
| 6 | + import { FEATURED_MODELS_IDS } from "./inferencePlaygroundUtils"; |
7 | 7 | import IconSearch from "../Icons/IconSearch.svelte";
|
8 | 8 | import IconStar from "../Icons/IconStar.svelte";
|
9 | 9 |
|
|
17 | 17 |
|
18 | 18 | const dispatch = createEventDispatcher<{ modelSelected: string; close: void }>();
|
19 | 19 |
|
20 |
| - let featuredModels = models.filter(m => FEATUED_MODELS_IDS.includes(m.id)); |
21 |
| - let otherModels = models.filter(m => !FEATUED_MODELS_IDS.includes(m.id)); |
| 20 | + let featuredModels = models.filter(m => FEATURED_MODELS_IDS.includes(m.id)); |
| 21 | + let otherModels = models.filter(m => !FEATURED_MODELS_IDS.includes(m.id)); |
22 | 22 |
|
23 | 23 | if (featuredModels.findIndex(model => model.id === conversation.model.id) !== -1) {
|
24 | 24 | highlightIdx = featuredModels.findIndex(model => model.id === conversation.model.id);
|
|
83 | 83 | function filterModels(query: string) {
|
84 | 84 | featuredModels = models.filter(m =>
|
85 | 85 | query
|
86 |
| - ? FEATUED_MODELS_IDS.includes(m.id) && m.id.toLocaleLowerCase().includes(query.toLocaleLowerCase().trim()) |
87 |
| - : FEATUED_MODELS_IDS.includes(m.id) |
| 86 | + ? FEATURED_MODELS_IDS.includes(m.id) && m.id.toLocaleLowerCase().includes(query.toLocaleLowerCase().trim()) |
| 87 | + : FEATURED_MODELS_IDS.includes(m.id) |
88 | 88 | );
|
89 | 89 |
|
90 | 90 | otherModels = models.filter(m =>
|
91 | 91 | query
|
92 |
| - ? !FEATUED_MODELS_IDS.includes(m.id) && m.id.toLocaleLowerCase().includes(query.toLocaleLowerCase().trim()) |
93 |
| - : !FEATUED_MODELS_IDS.includes(m.id) |
| 92 | + ? !FEATURED_MODELS_IDS.includes(m.id) && m.id.toLocaleLowerCase().includes(query.toLocaleLowerCase().trim()) |
| 93 | + : !FEATURED_MODELS_IDS.includes(m.id) |
94 | 94 | );
|
95 | 95 | }
|
96 | 96 | </script>
|
|
119 | 119 | />
|
120 | 120 | </div>
|
121 | 121 | <div class="max-h-[300px] overflow-y-auto overflow-x-hidden">
|
122 |
| - <div> |
123 |
| - <div class="px-2 py-1.5 text-xs font-medium text-gray-500">Trending</div> |
| 122 | + {#if featuredModels.length} |
124 | 123 | <div>
|
125 |
| - {#each featuredModels as model, idx} |
126 |
| - {@const [nameSpace, modelName] = model.id.split("/")} |
127 |
| - <button |
128 |
| - class="flex w-full cursor-pointer items-center px-2 py-1.5 text-sm {highlightIdx === idx |
129 |
| - ? 'highlighted bg-gray-100 dark:bg-gray-800' |
130 |
| - : ''}" |
131 |
| - on:mouseenter={() => highlightRow(idx)} |
132 |
| - on:click={() => { |
133 |
| - dispatch("modelSelected", model.id); |
134 |
| - dispatch("close"); |
135 |
| - }} |
136 |
| - > |
137 |
| - <IconStar classNames="lucide lucide-star mr-2 h-4 w-4 text-yellow-400" /> |
138 |
| - <span class="inline-flex items-center" |
139 |
| - ><span class="text-gray-500 dark:text-gray-400">{nameSpace}</span><span |
140 |
| - class="mx-1 text-gray-300 dark:text-gray-700">/</span |
141 |
| - ><span class="text-black dark:text-white">{modelName}</span></span |
| 124 | + <div class="px-2 py-1.5 text-xs font-medium text-gray-500">Trending</div> |
| 125 | + <div> |
| 126 | + {#each featuredModels as model, idx} |
| 127 | + {@const [nameSpace, modelName] = model.id.split("/")} |
| 128 | + <button |
| 129 | + class="flex w-full cursor-pointer items-center px-2 py-1.5 text-sm {highlightIdx === idx |
| 130 | + ? 'highlighted bg-gray-100 dark:bg-gray-800' |
| 131 | + : ''}" |
| 132 | + on:mouseenter={() => highlightRow(idx)} |
| 133 | + on:click={() => { |
| 134 | + dispatch("modelSelected", model.id); |
| 135 | + dispatch("close"); |
| 136 | + }} |
142 | 137 | >
|
143 |
| - </button> |
144 |
| - {/each} |
| 138 | + <IconStar classNames="lucide lucide-star mr-1.5 size-4 text-yellow-400" /> |
| 139 | + <span class="inline-flex items-center" |
| 140 | + ><span class="text-gray-500 dark:text-gray-400">{nameSpace}</span><span |
| 141 | + class="mx-1 text-gray-300 dark:text-gray-700">/</span |
| 142 | + ><span class="text-black dark:text-white">{modelName}</span></span |
| 143 | + > |
| 144 | + </button> |
| 145 | + {/each} |
| 146 | + </div> |
145 | 147 | </div>
|
146 |
| - </div> |
147 |
| - <div> |
148 |
| - <div class="px-2 py-1.5 text-xs font-medium text-gray-500">Other Models</div> |
| 148 | + {/if} |
| 149 | + {#if otherModels.length} |
149 | 150 | <div>
|
150 |
| - {#each otherModels as model, _idx} |
151 |
| - {@const [nameSpace, modelName] = model.id.split("/")} |
152 |
| - {@const idx = featuredModels.length + _idx} |
153 |
| - <button |
154 |
| - class="flex w-full cursor-pointer items-center px-2 py-1.5 text-sm {highlightIdx === idx |
155 |
| - ? 'highlighted bg-gray-100 dark:bg-gray-800' |
156 |
| - : ''}" |
157 |
| - on:mouseenter={() => highlightRow(idx)} |
158 |
| - on:click={() => { |
159 |
| - dispatch("modelSelected", model.id); |
160 |
| - dispatch("close"); |
161 |
| - }} |
162 |
| - > |
163 |
| - <span class="inline-flex items-center" |
164 |
| - ><span class="text-gray-500 dark:text-gray-400">{nameSpace}</span><span |
165 |
| - class="mx-1 text-gray-300 dark:text-gray-700">/</span |
166 |
| - ><span class="text-black dark:text-white">{modelName}</span></span |
| 151 | + <div class="px-2 py-1.5 text-xs font-medium text-gray-500">Other Models</div> |
| 152 | + <div> |
| 153 | + {#each otherModels as model, _idx} |
| 154 | + {@const [nameSpace, modelName] = model.id.split("/")} |
| 155 | + {@const idx = featuredModels.length + _idx} |
| 156 | + <button |
| 157 | + class="flex w-full cursor-pointer items-center px-2 py-1.5 text-sm {highlightIdx === idx |
| 158 | + ? 'highlighted bg-gray-100 dark:bg-gray-800' |
| 159 | + : ''}" |
| 160 | + on:mouseenter={() => highlightRow(idx)} |
| 161 | + on:click={() => { |
| 162 | + dispatch("modelSelected", model.id); |
| 163 | + dispatch("close"); |
| 164 | + }} |
167 | 165 | >
|
168 |
| - </button> |
169 |
| - {/each} |
| 166 | + <span class="inline-flex items-center" |
| 167 | + ><span class="text-gray-500 dark:text-gray-400">{nameSpace}</span><span |
| 168 | + class="mx-1 text-gray-300 dark:text-gray-700">/</span |
| 169 | + ><span class="text-black dark:text-white">{modelName}</span></span |
| 170 | + > |
| 171 | + </button> |
| 172 | + {/each} |
| 173 | + </div> |
170 | 174 | </div>
|
171 |
| - </div> |
| 175 | + {/if} |
172 | 176 | </div>
|
173 | 177 | </div>
|
174 | 178 | </div>
|
|
0 commit comments