MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / pickDraftModel

Function pickDraftModel

src/llm/speculative.ts:88–107  ·  view source on GitHub ↗
(targetModelId: string, availableModelIds: string[])

Source from the content-addressed store, hash-verified

86 * Returns null when nothing compatible is available.
87 */
88export 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.

Callers 2

index.tsFile · 0.85

Calls 2

suggestDraftFamilyFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected