(targetModelId: string, availableModelIds: string[])
| 86 | * Returns null when nothing compatible is available. |
| 87 | */ |
| 88 | export function pickDraftModel(targetModelId: string, availableModelIds: string[]): string | null { |
| 89 | const suggestion = suggestDraftFamily(targetModelId); |
| 90 | if (!suggestion) return null; |
| 91 | |
| 92 | const lowerTarget = targetModelId.toLowerCase(); |
| 93 | // For each size hint (smallest first), find a same-family model that contains it. |
| 94 | for (const hint of suggestion.draftHints) { |
| 95 | for (const id of availableModelIds) { |
| 96 | const lower = id.toLowerCase(); |
| 97 | if (lower === lowerTarget) continue; // never the target itself |
| 98 | // Must share the family root and contain the size hint. |
| 99 | const familyRule = FAMILY_RULES.find(r => r.family === suggestion.family)!; |
| 100 | if (familyRule.match.test(id) && lower.includes(hint)) { |
| 101 | logger.info('Auto-selected draft model', { target: targetModelId, draft: id, family: suggestion.family }); |
| 102 | return id; |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | return null; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Recommended draft lookahead (number of speculative tokens per step) by task. |
no test coverage detected