fix(ai, config): Correct Anthropic API calls and improve model config UI
Resolves persistent 404 'Not Found' errors when calling Anthropic models via the Vercel AI SDK. The primary issue was likely related to incorrect or missing API headers. - Refactors Anthropic provider (src/ai-providers/anthropic.js) to use the standard 'anthropic-version' header instead of potentially outdated/incorrect beta headers when creating the client instance. - Updates the default fallback model ID in .taskmasterconfig to 'claude-3-5-sonnet-20241022'. - Fixes the interactive model setup (task-master models --setup) in scripts/modules/commands.js to correctly filter and default the main model selection. - Improves the cost display in the 'task-master models' command output to explicitly show 'Free' for models with zero cost. - Updates description for the 'id' parameter in the 'set_task_status' MCP tool definition for clarity. - Updates list of models and costs
This commit is contained in:
@@ -1659,6 +1659,18 @@ function registerCommands(programInstance) {
|
||||
|
||||
console.log(chalk.cyan.bold('\nInteractive Model Setup:'));
|
||||
|
||||
const getMainChoicesAndDefault = () => {
|
||||
const mainChoices = allModelsForSetup.filter((modelChoice) =>
|
||||
availableModelsForSetup
|
||||
.find((m) => m.modelId === modelChoice.value.id)
|
||||
?.allowedRoles?.includes('main')
|
||||
);
|
||||
const defaultIndex = mainChoices.findIndex(
|
||||
(m) => m.value.id === currentModels.main?.modelId
|
||||
);
|
||||
return { choices: mainChoices, default: defaultIndex };
|
||||
};
|
||||
|
||||
// Get all available models, including active ones
|
||||
const allModelsForSetup = availableModelsForSetup.map((model) => ({
|
||||
name: `${model.provider} / ${model.modelId}`,
|
||||
@@ -1716,6 +1728,8 @@ function registerCommands(programInstance) {
|
||||
|
||||
const researchPromptData = getResearchChoicesAndDefault();
|
||||
const fallbackPromptData = getFallbackChoicesAndDefault();
|
||||
// Call the helper function for main model choices
|
||||
const mainPromptData = getMainChoicesAndDefault();
|
||||
|
||||
// Add cancel option for all prompts
|
||||
const cancelOption = {
|
||||
@@ -1726,7 +1740,7 @@ function registerCommands(programInstance) {
|
||||
const mainModelChoices = [
|
||||
cancelOption,
|
||||
new inquirer.Separator(),
|
||||
...allModelsForSetup
|
||||
...mainPromptData.choices
|
||||
];
|
||||
|
||||
const researchModelChoices = [
|
||||
@@ -1758,7 +1772,7 @@ function registerCommands(programInstance) {
|
||||
name: 'mainModel',
|
||||
message: 'Select the main model for generation/updates:',
|
||||
choices: mainModelChoices,
|
||||
default: findDefaultIndex(currentModels.main?.modelId) + 2 // +2 for cancel option and separator
|
||||
default: mainPromptData.default + 2 // +2 for cancel option and separator
|
||||
},
|
||||
{
|
||||
type: 'list',
|
||||
@@ -2001,6 +2015,12 @@ function registerCommands(programInstance) {
|
||||
|
||||
const formatCost = (costObj) => {
|
||||
if (!costObj) return 'N/A';
|
||||
|
||||
// Check if both input and output costs are 0 and return "Free"
|
||||
if (costObj.input === 0 && costObj.output === 0) {
|
||||
return chalk.green('Free');
|
||||
}
|
||||
|
||||
const formatSingleCost = (costValue) => {
|
||||
if (costValue === null || costValue === undefined) return 'N/A';
|
||||
const isInteger = Number.isInteger(costValue);
|
||||
|
||||
Reference in New Issue
Block a user