diff --git a/scripts/init.js b/scripts/init.js index 65f36fc8..8009e4a3 100755 --- a/scripts/init.js +++ b/scripts/init.js @@ -623,7 +623,7 @@ function createProjectStructure( ...replacements } ); - + // Update config.json with correct maxTokens values from supported-models.json const configPath = path.join(targetDir, TASKMASTER_CONFIG_FILE); if (updateConfigMaxTokens(configPath)) { diff --git a/scripts/modules/update-config-tokens.js b/scripts/modules/update-config-tokens.js index 403bf35c..14e68b2d 100644 --- a/scripts/modules/update-config-tokens.js +++ b/scripts/modules/update-config-tokens.js @@ -20,29 +20,33 @@ export function updateConfigMaxTokens(configPath) { try { // Load supported models const supportedModelsPath = path.join(__dirname, 'supported-models.json'); - const supportedModels = JSON.parse(fs.readFileSync(supportedModelsPath, 'utf-8')); - + const supportedModels = JSON.parse( + fs.readFileSync(supportedModelsPath, 'utf-8') + ); + // Load config const config = JSON.parse(fs.readFileSync(configPath, 'utf-8')); - + // Update each role's maxTokens if the model exists in supported-models.json const roles = ['main', 'research', 'fallback']; - + for (const role of roles) { if (config.models && config.models[role]) { const provider = config.models[role].provider; const modelId = config.models[role].modelId; - + // Find the model in supported models if (supportedModels[provider]) { - const modelData = supportedModels[provider].find(m => m.id === modelId); + const modelData = supportedModels[provider].find( + (m) => m.id === modelId + ); if (modelData && modelData.max_tokens) { config.models[role].maxTokens = modelData.max_tokens; } } } } - + // Write back the updated config fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); return true; @@ -50,4 +54,4 @@ export function updateConfigMaxTokens(configPath) { console.error('Error updating config maxTokens:', error.message); return false; } -} \ No newline at end of file +}