()
| 44 | } |
| 45 | |
| 46 | function getConfiguredCustomModelOptions(): ModelOption[] { |
| 47 | const configuredModels = getConfiguredCustomModels() as unknown[] | undefined |
| 48 | if (!configuredModels?.length) { |
| 49 | return [] |
| 50 | } |
| 51 | |
| 52 | return configuredModels.flatMap(model => { |
| 53 | if (typeof model === 'string' && model.length > 0) { |
| 54 | return [{ value: model, label: model, description: 'Custom model' }] |
| 55 | } |
| 56 | |
| 57 | if (!model || typeof model !== 'object') { |
| 58 | return [] |
| 59 | } |
| 60 | |
| 61 | const config = model as Record<string, unknown> |
| 62 | const value = config.model ?? config.value ?? config.id ?? config.name |
| 63 | if (typeof value !== 'string' || value.length === 0) { |
| 64 | return [] |
| 65 | } |
| 66 | |
| 67 | const label = |
| 68 | typeof config.label === 'string' && config.label.length > 0 |
| 69 | ? config.label |
| 70 | : value |
| 71 | const description = |
| 72 | typeof config.description === 'string' && config.description.length > 0 |
| 73 | ? config.description |
| 74 | : 'Custom model' |
| 75 | |
| 76 | return [{ value, label, description }] |
| 77 | }) |
| 78 | } |
| 79 | |
| 80 | export function getDefaultOptionForUser(fastMode = false): ModelOption { |
| 81 | if (process.env.USER_TYPE === 'ant') { |
no test coverage detected