(modelIds: string[])
| 3205 | * dynamically-discovered provider models) are left in their original order at the end. |
| 3206 | */ |
| 3207 | export function orderModelIdsByReleaseDate(modelIds: string[]): string[] { |
| 3208 | const groups = new Map<string, string[]>() |
| 3209 | const unknown: string[] = [] |
| 3210 | |
| 3211 | for (const id of modelIds) { |
| 3212 | const meta = MODEL_CATALOG_INDEX.get(id.toLowerCase()) |
| 3213 | if (!meta) { |
| 3214 | unknown.push(id) |
| 3215 | continue |
| 3216 | } |
| 3217 | const bucket = groups.get(meta.providerId) |
| 3218 | if (bucket) bucket.push(id) |
| 3219 | else groups.set(meta.providerId, [id]) |
| 3220 | } |
| 3221 | |
| 3222 | const ordered: string[] = [] |
| 3223 | for (const bucket of groups.values()) { |
| 3224 | bucket.sort((a, b) => { |
| 3225 | const ma = MODEL_CATALOG_INDEX.get(a.toLowerCase())! |
| 3226 | const mb = MODEL_CATALOG_INDEX.get(b.toLowerCase())! |
| 3227 | if (ma.releaseTime !== mb.releaseTime) return mb.releaseTime - ma.releaseTime |
| 3228 | return ma.declIndex - mb.declIndex |
| 3229 | }) |
| 3230 | ordered.push(...bucket) |
| 3231 | } |
| 3232 | ordered.push(...unknown) |
| 3233 | return ordered |
| 3234 | } |
| 3235 | |
| 3236 | export const DYNAMIC_MODEL_PROVIDERS = [ |
| 3237 | 'ollama', |
no test coverage detected