enh: reintroduce model order/default models

This commit is contained in:
Timothy Jaeryang Baek
2024-11-26 00:55:58 -08:00
parent 29fac5ecca
commit 5fac25a002
12 changed files with 407 additions and 66 deletions
-20
View File
@@ -25,26 +25,6 @@ export const getModels = async (token: string = '', base: boolean = false) => {
}
let models = res?.data ?? [];
models = models
.filter((models) => models)
// Sort the models
.sort((a, b) => {
// Compare case-insensitively by name for models without position property
const lowerA = a.name.toLowerCase();
const lowerB = b.name.toLowerCase();
if (lowerA < lowerB) return -1;
if (lowerA > lowerB) return 1;
// If same case-insensitively, sort by original strings,
// lowercase will come before uppercase due to ASCII values
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0; // They are equal
});
console.log(models);
return models;
};