( choices: ModelChoice[], model: SDKModel )
| 293 | } |
| 294 | |
| 295 | function disambiguateDuplicateLabels( |
| 296 | choices: ModelChoice[], |
| 297 | model: SDKModel |
| 298 | ): ModelChoice[] { |
| 299 | const labelCounts = choices.reduce((counts, choice) => { |
| 300 | counts.set(choice.label, (counts.get(choice.label) ?? 0) + 1) |
| 301 | return counts |
| 302 | }, new Map<string, number>()) |
| 303 | |
| 304 | return choices.map((choice) => { |
| 305 | if ((labelCounts.get(choice.label) ?? 0) <= 1) { |
| 306 | return choice |
| 307 | } |
| 308 | |
| 309 | const paramsLabel = formatParamsLabel(choice.value.params ?? [], model) |
| 310 | return paramsLabel |
| 311 | ? { ...choice, label: `${choice.label} - ${paramsLabel}` } |
| 312 | : choice |
| 313 | }) |
| 314 | } |
| 315 | |
| 316 | function dedupeModelChoices(choices: ModelChoice[]) { |
| 317 | const bySelection = new Map<string, ModelChoice>() |
no test coverage detected