fix: de-duplicate model tags case-insensitively (#18716)
* fix: de-duplicate model tags case-insensitively This change updates the `setTags` function in the `Models.svelte` component and the `onMount` function in the `Selector.svelte` component to convert all model tags to lowercase before removing duplicates. This ensures that tags with different capitalization (e.g., "Best" and "best") are treated as a single tag, preventing duplicate entries in the tag filter dropdown on both the workspace models page and the new chat page. * Update Selector.svelte * refac
This commit is contained in:
2 files changed
+11
-8
No files matched your search
@@ -312,13 +312,16 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (items) {
|
if (items) {
|
||||||
tags = items
|
tags = Array.from(
|
||||||
.filter((item) => !(item.model?.info?.meta?.hidden ?? false))
|
new Set(
|
||||||
.flatMap((item) => item.model?.tags ?? [])
|
items
|
||||||
.map((tag) => tag.name);
|
.filter((item) => !(item.model?.info?.meta?.hidden ?? false))
|
||||||
|
.flatMap((item) => item.model?.tags ?? [])
|
||||||
// Remove duplicates and sort
|
.map((tag) => tag.name.toLowerCase())
|
||||||
tags = Array.from(new Set(tags)).sort((a, b) => a.localeCompare(b));
|
)
|
||||||
|
)
|
||||||
|
.sort((a, b) => a.localeCompare(b))
|
||||||
|
.map((tag) => capitalizeFirstLetter(tag));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@
|
|||||||
tags = models
|
tags = models
|
||||||
.filter((model) => !(model?.meta?.hidden ?? false))
|
.filter((model) => !(model?.meta?.hidden ?? false))
|
||||||
.flatMap((model) => model?.meta?.tags ?? [])
|
.flatMap((model) => model?.meta?.tags ?? [])
|
||||||
.map((tag) => tag.name);
|
.map((tag) => tag.name.toLowerCase());
|
||||||
|
|
||||||
// Remove duplicates and sort
|
// Remove duplicates and sort
|
||||||
tags = Array.from(new Set(tags)).sort((a, b) => a.localeCompare(b));
|
tags = Array.from(new Set(tags)).sort((a, b) => a.localeCompare(b));
|
||||||
|
|||||||
Reference in new issue
Block a user