|
@@ -4,21 +4,34 @@ export function collectModelTable(
|
|
|
models: readonly LLMModel[],
|
|
|
customModels: string,
|
|
|
) {
|
|
|
- const modelTable: Record<string, boolean> = {};
|
|
|
+ const modelTable: Record<
|
|
|
+ string,
|
|
|
+ { available: boolean; name: string; displayName: string }
|
|
|
+ > = {};
|
|
|
|
|
|
// default models
|
|
|
- models.forEach((m) => (modelTable[m.name] = m.available));
|
|
|
+ models.forEach(
|
|
|
+ (m) =>
|
|
|
+ (modelTable[m.name] = {
|
|
|
+ ...m,
|
|
|
+ displayName: m.name,
|
|
|
+ }),
|
|
|
+ );
|
|
|
|
|
|
// server custom models
|
|
|
customModels
|
|
|
.split(",")
|
|
|
.filter((v) => !!v && v.length > 0)
|
|
|
.map((m) => {
|
|
|
- if (m.startsWith("+")) {
|
|
|
- modelTable[m.slice(1)] = true;
|
|
|
- } else if (m.startsWith("-")) {
|
|
|
- modelTable[m.slice(1)] = false;
|
|
|
- } else modelTable[m] = true;
|
|
|
+ const available = !m.startsWith("-");
|
|
|
+ const nameConfig =
|
|
|
+ m.startsWith("+") || m.startsWith("-") ? m.slice(1) : m;
|
|
|
+ const [name, displayName] = nameConfig.split(":");
|
|
|
+ modelTable[name] = {
|
|
|
+ name,
|
|
|
+ displayName: displayName || name,
|
|
|
+ available,
|
|
|
+ };
|
|
|
});
|
|
|
return modelTable;
|
|
|
}
|
|
@@ -31,10 +44,7 @@ export function collectModels(
|
|
|
customModels: string,
|
|
|
) {
|
|
|
const modelTable = collectModelTable(models, customModels);
|
|
|
- const allModels = Object.keys(modelTable).map((m) => ({
|
|
|
- name: m,
|
|
|
- available: modelTable[m],
|
|
|
- }));
|
|
|
+ const allModels = Object.values(modelTable);
|
|
|
|
|
|
return allModels;
|
|
|
}
|