mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
ui define common helpers
This commit is contained in:
parent
0f9abf05f4
commit
4dd9bd1bf7
1 changed files with 12 additions and 10 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import { modelAvailableCall } from "../networking";
|
||||
|
||||
|
||||
|
|
@ -48,13 +47,14 @@ export const getModelDisplayName = (model: string) => {
|
|||
console.log("getModelDisplayName", model);
|
||||
if (model.endsWith('/*')) {
|
||||
const provider = model.replace('/*', '');
|
||||
return `All ${provider} Models`;
|
||||
return `All ${provider} models`;
|
||||
}
|
||||
return model;
|
||||
};
|
||||
|
||||
export const unfurlWildcardModelsInList = (teamModels: string[], allModels: string[]): string[] => {
|
||||
const result: string[] = [];
|
||||
const wildcardDisplayNames: string[] = [];
|
||||
const expandedModels: string[] = [];
|
||||
console.log("teamModels", teamModels);
|
||||
console.log("allModels", allModels);
|
||||
|
||||
|
|
@ -67,14 +67,16 @@ export const unfurlWildcardModelsInList = (teamModels: string[], allModels: stri
|
|||
const matchingModels = allModels.filter(model =>
|
||||
model.startsWith(provider + '/')
|
||||
);
|
||||
|
||||
result.push(...matchingModels);
|
||||
} else {
|
||||
// For non-wildcard models, add them directly
|
||||
result.push(teamModel);
|
||||
expandedModels.push(...matchingModels);
|
||||
wildcardDisplayNames.push(teamModel);
|
||||
}
|
||||
else {
|
||||
expandedModels.push(teamModel);
|
||||
}
|
||||
});
|
||||
|
||||
// Remove duplicates and return
|
||||
return result.filter((item, index) => result.indexOf(item) === index);
|
||||
// Combine arrays with wildcard display names first, then remove duplicates
|
||||
return [...wildcardDisplayNames, ...expandedModels].filter((item, index, array) =>
|
||||
array.indexOf(item) === index
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue