Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
fix model query search
Browse files
src/lib/components/InferencePlayground/InferencePlaygroundModelSelectorModal.svelte
CHANGED
|
@@ -11,23 +11,14 @@
|
|
| 11 |
export let conversation: Conversation;
|
| 12 |
|
| 13 |
let backdropEl: HTMLDivElement;
|
| 14 |
-
let query = "";
|
| 15 |
let highlightIdx = 0;
|
| 16 |
let ignoreCursorHighlight = false;
|
| 17 |
let containerEl: HTMLDivElement;
|
| 18 |
|
| 19 |
const dispatch = createEventDispatcher<{ modelSelected: string; close: void }>();
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
? FEATUED_MODELS_IDS.includes(m.id) && m.id.toLocaleLowerCase().includes(query.toLocaleLowerCase().trim())
|
| 24 |
-
: FEATUED_MODELS_IDS.includes(m.id)
|
| 25 |
-
);
|
| 26 |
-
const otherModels = models.filter(m =>
|
| 27 |
-
query
|
| 28 |
-
? !FEATUED_MODELS_IDS.includes(m.id) && m.id.toLocaleLowerCase().includes(query.toLocaleLowerCase().trim())
|
| 29 |
-
: !FEATUED_MODELS_IDS.includes(m.id)
|
| 30 |
-
);
|
| 31 |
|
| 32 |
if (featuredModels.findIndex(model => model.id === conversation.model.id) !== -1) {
|
| 33 |
highlightIdx = featuredModels.findIndex(model => model.id === conversation.model.id);
|
|
@@ -56,7 +47,7 @@
|
|
| 56 |
highlightIdx++;
|
| 57 |
ignoreCursorHighlight = true;
|
| 58 |
}
|
| 59 |
-
const n =
|
| 60 |
highlightIdx = ((highlightIdx % n) + n) % n;
|
| 61 |
scrollToResult(scrollLogicalPosition);
|
| 62 |
}
|
|
@@ -87,6 +78,20 @@
|
|
| 87 |
dispatch("close");
|
| 88 |
}
|
| 89 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
</script>
|
| 91 |
|
| 92 |
<svelte:window on:keydown={handleKeydown} on:mousemove={() => (ignoreCursorHighlight = false)} />
|
|
@@ -107,7 +112,7 @@
|
|
| 107 |
autofocus
|
| 108 |
class="flex h-10 w-full rounded-md bg-transparent py-3 text-sm placeholder-gray-400 outline-none"
|
| 109 |
placeholder="Search models ..."
|
| 110 |
-
|
| 111 |
/>
|
| 112 |
</div>
|
| 113 |
<div class="max-h-[300px] overflow-y-auto overflow-x-hidden">
|
|
|
|
| 11 |
export let conversation: Conversation;
|
| 12 |
|
| 13 |
let backdropEl: HTMLDivElement;
|
|
|
|
| 14 |
let highlightIdx = 0;
|
| 15 |
let ignoreCursorHighlight = false;
|
| 16 |
let containerEl: HTMLDivElement;
|
| 17 |
|
| 18 |
const dispatch = createEventDispatcher<{ modelSelected: string; close: void }>();
|
| 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));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
if (featuredModels.findIndex(model => model.id === conversation.model.id) !== -1) {
|
| 24 |
highlightIdx = featuredModels.findIndex(model => model.id === conversation.model.id);
|
|
|
|
| 47 |
highlightIdx++;
|
| 48 |
ignoreCursorHighlight = true;
|
| 49 |
}
|
| 50 |
+
const n = featuredModels.length + otherModels.length;
|
| 51 |
highlightIdx = ((highlightIdx % n) + n) % n;
|
| 52 |
scrollToResult(scrollLogicalPosition);
|
| 53 |
}
|
|
|
|
| 78 |
dispatch("close");
|
| 79 |
}
|
| 80 |
}
|
| 81 |
+
|
| 82 |
+
function filterModels(query: string) {
|
| 83 |
+
featuredModels = models.filter(m =>
|
| 84 |
+
query
|
| 85 |
+
? FEATUED_MODELS_IDS.includes(m.id) && m.id.toLocaleLowerCase().includes(query.toLocaleLowerCase().trim())
|
| 86 |
+
: FEATUED_MODELS_IDS.includes(m.id)
|
| 87 |
+
);
|
| 88 |
+
|
| 89 |
+
otherModels = models.filter(m =>
|
| 90 |
+
query
|
| 91 |
+
? !FEATUED_MODELS_IDS.includes(m.id) && m.id.toLocaleLowerCase().includes(query.toLocaleLowerCase().trim())
|
| 92 |
+
: !FEATUED_MODELS_IDS.includes(m.id)
|
| 93 |
+
);
|
| 94 |
+
}
|
| 95 |
</script>
|
| 96 |
|
| 97 |
<svelte:window on:keydown={handleKeydown} on:mousemove={() => (ignoreCursorHighlight = false)} />
|
|
|
|
| 112 |
autofocus
|
| 113 |
class="flex h-10 w-full rounded-md bg-transparent py-3 text-sm placeholder-gray-400 outline-none"
|
| 114 |
placeholder="Search models ..."
|
| 115 |
+
on:input={e => filterModels(e.currentTarget.value)}
|
| 116 |
/>
|
| 117 |
</div>
|
| 118 |
<div class="max-h-[300px] overflow-y-auto overflow-x-hidden">
|