fixes issue with perplexity model used by default (now sonar-pro in all cases). Fixes an issue preventing analyzeTaskComplexity to work as designed. Fixes an issue that prevented parse-prd from working. Stubs in the test for analyzeTaskComplexity to be done later.
This commit is contained in:
@@ -305,7 +305,7 @@ async function generateSubtasksWithPerplexity(task, numSubtasks = 3, nextSubtask
|
||||
log('info', `Researching context for task ${task.id}: ${task.title}`);
|
||||
const perplexityClient = getPerplexityClient();
|
||||
|
||||
const PERPLEXITY_MODEL = process.env.PERPLEXITY_MODEL || 'sonar-small-online';
|
||||
const PERPLEXITY_MODEL = process.env.PERPLEXITY_MODEL || 'sonar-pro';
|
||||
const researchLoadingIndicator = startLoadingIndicator('Researching best practices with Perplexity AI...');
|
||||
|
||||
// Formulate research query based on task
|
||||
@@ -493,13 +493,13 @@ function parseSubtasksFromText(text, startId, expectedCount, parentTaskId) {
|
||||
|
||||
/**
|
||||
* Generate a prompt for complexity analysis
|
||||
* @param {Array} tasksData - Tasks data
|
||||
* @param {Object} tasksData - Tasks data object containing tasks array
|
||||
* @returns {string} Generated prompt
|
||||
*/
|
||||
function generateComplexityAnalysisPrompt(tasksData) {
|
||||
return `Analyze the complexity of the following tasks and provide recommendations for subtask breakdown:
|
||||
|
||||
${tasksData.map(task => `
|
||||
${tasksData.tasks.map(task => `
|
||||
Task ID: ${task.id}
|
||||
Title: ${task.title}
|
||||
Description: ${task.description}
|
||||
|
||||
@@ -52,10 +52,27 @@ function registerCommands(programInstance) {
|
||||
programInstance
|
||||
.command('parse-prd')
|
||||
.description('Parse a PRD file and generate tasks')
|
||||
.argument('<file>', 'Path to the PRD file')
|
||||
.argument('[file]', 'Path to the PRD file')
|
||||
.option('-o, --output <file>', 'Output file path', 'tasks/tasks.json')
|
||||
.option('-n, --num-tasks <number>', 'Number of tasks to generate', '10')
|
||||
.action(async (file, options) => {
|
||||
if (!file) {
|
||||
console.log(chalk.yellow('No PRD file specified.'));
|
||||
console.log(boxen(
|
||||
chalk.white.bold('Parse PRD Help') + '\n\n' +
|
||||
chalk.cyan('Usage:') + '\n' +
|
||||
` task-master parse-prd <prd-file.txt> [options]\n\n` +
|
||||
chalk.cyan('Options:') + '\n' +
|
||||
' -o, --output <file> Output file path (default: "tasks/tasks.json")\n' +
|
||||
' -n, --num-tasks <number> Number of tasks to generate (default: 10)\n\n' +
|
||||
chalk.cyan('Example:') + '\n' +
|
||||
' task-master parse-prd requirements.txt --num-tasks 15\n\n' +
|
||||
chalk.yellow('Note: This command will generate tasks from a PRD document and will overwrite any existing tasks.json file.'),
|
||||
{ padding: 1, borderColor: 'blue', borderStyle: 'round' }
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
const numTasks = parseInt(options.numTasks, 10);
|
||||
const outputPath = options.output;
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ The changes described in the prompt should be applied to ALL tasks in the list.`
|
||||
log('info', 'Using Perplexity AI for research-backed task updates');
|
||||
|
||||
// Call Perplexity AI using format consistent with ai-services.js
|
||||
const perplexityModel = process.env.PERPLEXITY_MODEL || 'sonar-small-online';
|
||||
const perplexityModel = process.env.PERPLEXITY_MODEL || 'sonar-pro';
|
||||
const result = await perplexity.chat.completions.create({
|
||||
model: perplexityModel,
|
||||
messages: [
|
||||
@@ -1756,7 +1756,7 @@ Your response must be a clean JSON array only, following exactly this format:
|
||||
DO NOT include any text before or after the JSON array. No explanations, no markdown formatting.`;
|
||||
|
||||
const result = await perplexity.chat.completions.create({
|
||||
model: PERPLEXITY_MODEL,
|
||||
model: process.env.PERPLEXITY_MODEL || 'sonar-pro',
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
@@ -1767,8 +1767,8 @@ DO NOT include any text before or after the JSON array. No explanations, no mark
|
||||
content: researchPrompt
|
||||
}
|
||||
],
|
||||
temperature: TEMPERATURE,
|
||||
max_tokens: MAX_TOKENS,
|
||||
temperature: CONFIG.temperature,
|
||||
max_tokens: CONFIG.maxTokens,
|
||||
});
|
||||
|
||||
// Extract the response text
|
||||
@@ -1889,7 +1889,13 @@ DO NOT include any text before or after the JSON array. No explanations, no mark
|
||||
// 3. Replace single quotes with double quotes for property values
|
||||
cleanedResponse = cleanedResponse.replace(/:(\s*)'([^']*)'(\s*[,}])/g, ':$1"$2"$3');
|
||||
|
||||
// 4. Add a special fallback option if we're still having issues
|
||||
// 4. Fix unterminated strings - common with LLM responses
|
||||
const untermStringPattern = /:(\s*)"([^"]*)(?=[,}])/g;
|
||||
cleanedResponse = cleanedResponse.replace(untermStringPattern, ':$1"$2"');
|
||||
|
||||
// 5. Fix multi-line strings by replacing newlines
|
||||
cleanedResponse = cleanedResponse.replace(/:(\s*)"([^"]*)\n([^"]*)"/g, ':$1"$2 $3"');
|
||||
|
||||
try {
|
||||
complexityAnalysis = JSON.parse(cleanedResponse);
|
||||
console.log(chalk.green("Successfully parsed JSON after fixing common issues"));
|
||||
@@ -2006,7 +2012,7 @@ Your response must be a clean JSON array only, following exactly this format:
|
||||
DO NOT include any text before or after the JSON array. No explanations, no markdown formatting.`;
|
||||
|
||||
const result = await perplexity.chat.completions.create({
|
||||
model: PERPLEXITY_MODEL,
|
||||
model: process.env.PERPLEXITY_MODEL || 'sonar-pro',
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
@@ -2017,8 +2023,8 @@ DO NOT include any text before or after the JSON array. No explanations, no mark
|
||||
content: missingTasksResearchPrompt
|
||||
}
|
||||
],
|
||||
temperature: TEMPERATURE,
|
||||
max_tokens: MAX_TOKENS,
|
||||
temperature: CONFIG.temperature,
|
||||
max_tokens: CONFIG.maxTokens,
|
||||
});
|
||||
|
||||
// Extract the response
|
||||
|
||||
@@ -391,7 +391,7 @@ function displayHelp() {
|
||||
`${chalk.dim('Optional')}${chalk.reset('')}`],
|
||||
[`${chalk.yellow('PERPLEXITY_MODEL')}${chalk.reset('')}`,
|
||||
`${chalk.white('Perplexity model to use')}${chalk.reset('')}`,
|
||||
`${chalk.dim('Default: sonar-small-online')}${chalk.reset('')}`],
|
||||
`${chalk.dim('Default: sonar-pro')}${chalk.reset('')}`],
|
||||
[`${chalk.yellow('DEBUG')}${chalk.reset('')}`,
|
||||
`${chalk.white('Enable debug logging')}${chalk.reset('')}`,
|
||||
`${chalk.dim(`Default: ${CONFIG.debug}`)}${chalk.reset('')}`],
|
||||
|
||||
Reference in New Issue
Block a user